blob: 6ff3105f9c849f2202b3ab31b7ed22684dd26674 [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:
Chet Lanctot186b5732013-03-18 10:26:30 -0700153#ifdef WLAN_FEATURE_11W
154 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
155#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 n = AUTH_WPA2_PSK;
157 break;
158#ifdef FEATURE_WLAN_WAPI
159 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
160 n = AUTH_WAPI_CERT;
161 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
163 n = AUTH_WAPI_PSK;
164 break;
165#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 default:
167 break;
168 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 return (n);
170}
Jeff Johnson295189b2012-06-20 16:38:30 -0700171int diagEncTypeFromCSRType(eCsrEncryptionType encType)
172{
173 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700174 switch(encType)
175 {
176 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
177 case eCSR_ENCRYPT_TYPE_WEP40:
178 n = ENC_MODE_WEP40;
179 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
181 case eCSR_ENCRYPT_TYPE_WEP104:
182 n = ENC_MODE_WEP104;
183 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700184 case eCSR_ENCRYPT_TYPE_TKIP:
185 n = ENC_MODE_TKIP;
186 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700187 case eCSR_ENCRYPT_TYPE_AES:
188 n = ENC_MODE_AES;
189 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700190#ifdef FEATURE_WLAN_WAPI
191 case eCSR_ENCRYPT_TYPE_WPI:
192 n = ENC_MODE_SMS4;
193 break;
194#endif /* FEATURE_WLAN_WAPI */
195 default:
196 break;
197 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700198 return (n);
199}
Jeff Johnson295189b2012-06-20 16:38:30 -0700200#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700201static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
202static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700203static void initConfigParam(tpAniSirGlobal pMac);
204static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
205 eCsrRoamCompleteResult Result, void *Context );
206static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
207 tCsrRoamProfile *pProfile,
208 tANI_BOOLEAN *pfSameIbss );
209static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
210static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700211 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
212static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700213eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
214static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
215eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
216eHalStatus csrRoamClose(tpAniSirGlobal pMac);
217void csrRoamMICErrorTimerHandler(void *pv);
218void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
219tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
220
221static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
222static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
223static void csrRoamRoamingTimerHandler(void *pv);
224eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
225eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
226static void csrRoamIbssJoinTimerHandler(void *pv);
227eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
228eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
229static void csrRoamWaitForKeyTimeOutHandler(void *pv);
230
231static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700232static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700233static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
234eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
235 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
236 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
237 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
238 tANI_U8 *pKeyRsc );
239static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
240 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
241 tCsrRoamProfile *pProfile );
242void csrRoamStatisticsTimerHandler(void *pv);
243void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700244static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
245VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
246 v_U8_t rssiNotification,
247 void * context);
248static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
249void csrRoamVccTrigger(tpAniSirGlobal pMac);
250eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
251/*
252 pStaEntry is no longer invalid upon the return of this function.
253*/
254static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700255static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700256static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700257tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
258 tDblLinkList *pStaList,
259 tCsrStatsClientReqInfo *pStaEntry);
260void csrRoamStatsClientTimerHandler(void *pv);
261tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
262 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
263void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
264 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700265void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700266void csrRoamTlStatsTimerHandler(void *pv);
267void csrRoamPeStatsTimerHandler(void *pv);
268tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
269void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
270tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
271eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
272static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
273static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
274static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
275static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
276 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
277//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
278static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
279void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
280#ifdef FEATURE_WLAN_BTAMP_UT_RF
281void csrRoamJoinRetryTimerHandler(void *pv);
282#endif
283extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700284extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700285static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700286void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
288//Initialize global variables
289static void csrRoamInitGlobals(tpAniSirGlobal pMac)
290{
291 if(pMac)
292 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800293 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
294 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700295 }
296 return;
297}
298
Jeff Johnson295189b2012-06-20 16:38:30 -0700299static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
300{
301 if(pMac)
302 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800303 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 }
305 return;
306}
Jeff Johnson295189b2012-06-20 16:38:30 -0700307eHalStatus csrOpen(tpAniSirGlobal pMac)
308{
309 eHalStatus status = eHAL_STATUS_SUCCESS;
310 static uNvTables nvTables;
311 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700312 v_REGDOMAIN_t regId;
313 tANI_U32 i;
314
315 do
316 {
317 /* Initialize CSR Roam Globals */
318 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
320 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
321
322 initConfigParam(pMac);
323 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
324 break;
325 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
326 break;
327 pMac->roam.nextRoamId = 1; //Must not be 0
328 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
329 break;
330 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
331 break;
332 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
333 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
335 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
336 {
337 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
338 nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
339 status = eHAL_STATUS_SUCCESS;
340 }
341 else
342 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800343 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 //hardcoded for now
345 pMac->scan.countryCodeDefault[0] = 'U';
346 pMac->scan.countryCodeDefault[1] = 'S';
347 pMac->scan.countryCodeDefault[2] = 'I';
348 //status = eHAL_STATUS_SUCCESS;
349 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700350 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault, &regId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 WDA_SetRegDomain(pMac, regId);
353 pMac->scan.domainIdDefault = regId;
354 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
356 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
357 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700358 }while(0);
359
360 return (status);
361}
362
Jeff Johnson295189b2012-06-20 16:38:30 -0700363eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
364{
365 eHalStatus status = eHAL_STATUS_SUCCESS;
366 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
367 v_REGDOMAIN_t regId;
368 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 if(NULL == apCntryCode)
370 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800371 smsLog( pMac, LOGW, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 return eHAL_STATUS_FAILURE;
373 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700374 smsLog( pMac, LOGW, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700375 /* To get correct Regulatory domain from NV table
376 * 2 character Country code should be used
377 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700378 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
379/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700381
382 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800384 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700385 return eHAL_STATUS_FAILURE;
386 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700387*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700388 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId);
389 if (status != eHAL_STATUS_SUCCESS)
390 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700391 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 return status;
393 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 status = WDA_SetRegDomain(hHal, regId);
395 if (status != eHAL_STATUS_SUCCESS)
396 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700397 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700398 return status;
399 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700400 pMac->scan.domainIdDefault = regId;
401 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700402 /* Clear CC field */
403 palFillMemory( pMac->hHdd,
404 pMac->scan.countryCodeDefault,
405 WNI_CFG_COUNTRY_CODE_LEN,
406 0 );
407 /* Copy 2 or 3 bytes country code */
408 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
409 apCntryCode, cntryCodeLength );
Jeff Johnson295189b2012-06-20 16:38:30 -0700410 /* If 2 bytes country code, 3rd byte must be filled with space */
411 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
412 {
413 palFillMemory( pMac->hHdd,
414 pMac->scan.countryCodeDefault + 2,
415 1,
416 0x20 );
417 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700418 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
419 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
420 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700421 return status;
422}
Jeff Johnson295189b2012-06-20 16:38:30 -0700423eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
424{
425 eHalStatus status = eHAL_STATUS_SUCCESS;
426 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
427 tANI_U8 index = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700428 palCopyMemory( pMac->hHdd, pParam->Csr11dinfo.countryCode,
429 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN );
Jeff Johnson295189b2012-06-20 16:38:30 -0700430 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
431 {
432 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
433 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
434 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
435 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
436 }
437 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
438
439 return status;
440}
Jeff Johnson295189b2012-06-20 16:38:30 -0700441eHalStatus csrClose(tpAniSirGlobal pMac)
442{
443 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800444
Jeff Johnson295189b2012-06-20 16:38:30 -0700445 csrStop(pMac);
446 csrRoamClose(pMac);
447 csrScanClose(pMac);
448 csrLLClose(&pMac->roam.statsClientReqList);
449 csrLLClose(&pMac->roam.peStatsReqList);
450 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700451 /* DeInit Globals */
452 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 return (status);
454}
Jeff Johnson295189b2012-06-20 16:38:30 -0700455eHalStatus csrStart(tpAniSirGlobal pMac)
456{
457 eHalStatus status = eHAL_STATUS_SUCCESS;
458 tANI_U32 i;
459
460 do
461 {
462 //save the global vos context
463 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
464 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
465 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
466
467 status = csrRoamStart(pMac);
468 if(!HAL_STATUS_SUCCESS(status)) break;
469 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
470 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
471 if(!HAL_STATUS_SUCCESS(status)) break;
472 pMac->roam.sPendingCommands = 0;
473 csrScanEnable(pMac);
474#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
475 status = csrNeighborRoamInit(pMac);
476#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
477 pMac->roam.tlStatsReqInfo.numClient = 0;
478 pMac->roam.tlStatsReqInfo.periodicity = 0;
479 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
480 //init the link quality indication also
481 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
482 if(!HAL_STATUS_SUCCESS(status))
483 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800484 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 break;
486 }
487 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700488#if defined(ANI_LOGDUMP)
489 csrDumpInit(pMac);
490#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700491 return (status);
492}
493
Jeff Johnson295189b2012-06-20 16:38:30 -0700494eHalStatus csrStop(tpAniSirGlobal pMac)
495{
496 tANI_U32 sessionId;
497 tANI_U32 i;
498
499 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
500 {
501 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
502 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700503 csrScanDisable(pMac);
504 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
505 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
507
508#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
509 csrNeighborRoamClose(pMac);
510#endif
511 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 // deregister from PMC since we register during csrStart()
513 // (ignore status since there is nothing we can do if it fails)
514 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 //Reset the domain back to the deault
516 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800517 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700518
519 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
520 {
521 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP ,i );
522 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
523 }
524
525 return (eHAL_STATUS_SUCCESS);
526}
527
Jeff Johnson295189b2012-06-20 16:38:30 -0700528eHalStatus csrReady(tpAniSirGlobal pMac)
529{
530 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 csrScanGetSupportedChannels( pMac );
532 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
533 //use it to init the background scan list
534 csrInitBGScanChannelList(pMac);
535 /* HDD issues the init scan */
536 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800537 /* If the gScanAgingTime is set to '0' then scan results aging timeout
538 based on timer feature is not enabled*/
539 if(0 != pMac->scan.scanResultCfgAgingTime )
540 {
541 csrScanStartResultCfgAgingTimer(pMac);
542 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 //Store the AC weights in TL for later use
544 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 status = csrInitChannelList( pMac );
546 if ( ! HAL_STATUS_SUCCESS( status ) )
547 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800548 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 status );
550 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 return (status);
552}
Jeff Johnson295189b2012-06-20 16:38:30 -0700553void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
554{
555 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
557 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
558}
Jeff Johnson295189b2012-06-20 16:38:30 -0700559void csrSetGlobalCfgs( tpAniSirGlobal pMac )
560{
Jeff Johnsone7245742012-09-05 17:12:55 -0700561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
563 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
564 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
565 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
566 NULL, eANI_BOOLEAN_FALSE);
567 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700568 /* 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
569 * Once session is established we will use the session related params stored in PE session for CB mode
570 */
571 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
573
574 //Update the operating mode to configured value during initialization,
575 //So that client can advertise full capabilities in Probe request frame.
576 csrSetDefaultDot11Mode( pMac );
577}
578
Jeff Johnson295189b2012-06-20 16:38:30 -0700579eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
580{
581 eHalStatus status = eHAL_STATUS_SUCCESS;
582 tANI_U32 i;
583 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 do
585 {
586 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
587 {
588 pSession = CSR_GET_SESSION( pMac, i );
589 pSession->roamingTimerInfo.pMac = pMac;
590 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
591 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700592 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
593 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
594 status = palTimerAlloc(pMac->hHdd, &pMac->roam.hTimerWaitForKey, csrRoamWaitForKeyTimeOutHandler,
595 &pMac->roam.WaitForKeyTimerInfo);
596 if(!HAL_STATUS_SUCCESS(status))
597 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800598 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 break;
600 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 status = palTimerAlloc(pMac->hHdd, &pMac->roam.tlStatsReqInfo.hTlStatsTimer, csrRoamTlStatsTimerHandler, pMac);
602 if(!HAL_STATUS_SUCCESS(status))
603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800604 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700605 return eHAL_STATUS_FAILURE;
606 }
607 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 return (status);
609}
610
Jeff Johnson295189b2012-06-20 16:38:30 -0700611eHalStatus csrRoamClose(tpAniSirGlobal pMac)
612{
613 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
615 {
616 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
617 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700618 palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey);
619 palTimerFree(pMac->hHdd, pMac->roam.hTimerWaitForKey);
Jeff Johnson295189b2012-06-20 16:38:30 -0700620 palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
621 palTimerFree(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700622 return (eHAL_STATUS_SUCCESS);
623}
624
Jeff Johnson295189b2012-06-20 16:38:30 -0700625eHalStatus csrRoamStart(tpAniSirGlobal pMac)
626{
627 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 return (eHAL_STATUS_SUCCESS);
629}
630
Jeff Johnson295189b2012-06-20 16:38:30 -0700631void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
632{
633 csrRoamStopRoamingTimer(pMac, sessionId);
634 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
635 csrRoamDeregStatisticsReq(pMac);
636}
Jeff Johnson295189b2012-06-20 16:38:30 -0700637eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
638{
639 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800640 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 {
642 status = eHAL_STATUS_SUCCESS;
643 *pState = pMac->roam.roamSession[sessionId].connectState;
644 }
645 return (status);
646}
647
Jeff Johnson295189b2012-06-20 16:38:30 -0700648eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
649{
650 eHalStatus status = eHAL_STATUS_FAILURE;
651 tANI_U32 size = 0;
652 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700653
654 if(!pSession)
655 {
656 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
657 return eHAL_STATUS_FAILURE;
658 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700659
660 if(pProfile)
661 {
662 if(pSession->pConnectBssDesc)
663 {
664 do
665 {
666 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
667 if(size)
668 {
669 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile->pBssDesc, size);
670 if(HAL_STATUS_SUCCESS(status))
671 {
672 palCopyMemory(pMac->hHdd, pProfile->pBssDesc, pSession->pConnectBssDesc, size);
673 }
674 else
675 break;
676 }
677 else
678 {
679 pProfile->pBssDesc = NULL;
680 }
681 pProfile->AuthType = pSession->connectedProfile.AuthType;
682 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
683 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
684 pProfile->BSSType = pSession->connectedProfile.BSSType;
685 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
686 pProfile->CBMode = pSession->connectedProfile.CBMode;
687 palCopyMemory(pMac->hHdd, &pProfile->bssid, &pSession->connectedProfile.bssid, sizeof(tCsrBssid));
688 palCopyMemory(pMac->hHdd, &pProfile->SSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
689#ifdef WLAN_FEATURE_VOWIFI_11R
690 if (pSession->connectedProfile.MDID.mdiePresent)
691 {
692 pProfile->MDID.mdiePresent = 1;
693 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
694 }
695 else
696 {
697 pProfile->MDID.mdiePresent = 0;
698 pProfile->MDID.mobilityDomain = 0;
699 }
700#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700701#ifdef FEATURE_WLAN_CCX
702 pProfile->isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 if (csrIsAuthTypeCCX(pSession->connectedProfile.AuthType))
704 {
705 palCopyMemory( pMac->hHdd, pProfile->ccxCckmInfo.krk,
706 pSession->connectedProfile.ccxCckmInfo.krk, CSR_KRK_KEY_LEN );
707 pProfile->ccxCckmInfo.reassoc_req_num=
708 pSession->connectedProfile.ccxCckmInfo.reassoc_req_num;
709 pProfile->ccxCckmInfo.krk_plumbed =
710 pSession->connectedProfile.ccxCckmInfo.krk_plumbed;
711 }
712#endif
713 }while(0);
714 }
715 }
716
717 return (status);
718}
719
Jeff Johnson295189b2012-06-20 16:38:30 -0700720eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
721{
722 eHalStatus status = eHAL_STATUS_FAILURE;
723
724 if(csrIsConnStateConnected(pMac, sessionId))
725 {
726 if(pProfile)
727 {
728 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
729 }
730 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 return (status);
732}
Jeff Johnson295189b2012-06-20 16:38:30 -0700733eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
734{
735 eHalStatus status = eHAL_STATUS_SUCCESS;
736
737 if(pProfile->pBssDesc)
738 {
739 palFreeMemory(pMac->hHdd, pProfile->pBssDesc);
740 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700741 if(pProfile->pAddIEAssoc)
742 {
743 palFreeMemory(pMac->hHdd, pProfile->pAddIEAssoc);
744 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamConnectedProfile));
746 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
747 return (status);
748}
749
Jeff Johnson295189b2012-06-20 16:38:30 -0700750static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
751{
752 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700753 if( pConnectedInfo->pbFrames )
754 {
755 palFreeMemory( pMac->hHdd, pConnectedInfo->pbFrames );
756 pConnectedInfo->pbFrames = NULL;
757 }
758 pConnectedInfo->nBeaconLength = 0;
759 pConnectedInfo->nAssocReqLength = 0;
760 pConnectedInfo->nAssocRspLength = 0;
761 pConnectedInfo->staId = 0;
762#ifdef WLAN_FEATURE_VOWIFI_11R
763 pConnectedInfo->nRICRspLength = 0;
764#endif
765#ifdef FEATURE_WLAN_CCX
766 pConnectedInfo->nTspecIeLength = 0;
767#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 return ( status );
769}
770
Jeff Johnson295189b2012-06-20 16:38:30 -0700771
772
Jeff Johnsone7245742012-09-05 17:12:55 -0700773
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700774void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
775{
776 csrReinitPreauthCmd(pMac, pCommand);
777 csrReleaseCommand( pMac, pCommand );
778}
779
Jeff Johnson295189b2012-06-20 16:38:30 -0700780void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
781{
782 csrReinitRoamCmd(pMac, pCommand);
783 csrReleaseCommand( pMac, pCommand );
784}
785
Jeff Johnson295189b2012-06-20 16:38:30 -0700786void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
787{
788 csrReinitScanCmd(pMac, pCommand);
789 csrReleaseCommand( pMac, pCommand );
790}
791
Jeff Johnson295189b2012-06-20 16:38:30 -0700792void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
793{
794 csrReinitWmStatusChangeCmd(pMac, pCommand);
795 csrReleaseCommand( pMac, pCommand );
796}
797
Jeff Johnson295189b2012-06-20 16:38:30 -0700798void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
799{
800 palZeroMemory(pMac->hHdd, &pCommand->u.setKeyCmd, sizeof(tSetKeyCmd));
801}
802
Jeff Johnson295189b2012-06-20 16:38:30 -0700803void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
804{
805 palZeroMemory(pMac->hHdd, &pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd));
806}
807
Jeff Johnson295189b2012-06-20 16:38:30 -0700808void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
809{
810 csrReinitSetKeyCmd(pMac, pCommand);
811 csrReleaseCommand( pMac, pCommand );
812}
Jeff Johnson295189b2012-06-20 16:38:30 -0700813void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
814{
815 csrReinitRemoveKeyCmd(pMac, pCommand);
816 csrReleaseCommand( pMac, pCommand );
817}
Jeff Johnson295189b2012-06-20 16:38:30 -0700818void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
819{
820
821 if( eSmeCsrCommandMask & pCommand->command )
822 {
823 switch (pCommand->command)
824 {
825 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800826 // We need to inform the requester before dropping the scan command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800827 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback 0x%X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700828 __func__, pCommand->u.scanCmd.reason, (unsigned int)pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700829 if (NULL != pCommand->u.scanCmd.callback)
830 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800831 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
833 }
834 csrReleaseCommandScan( pMac, pCommand );
835 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 case eSmeCommandRoam:
837 csrReleaseCommandRoam( pMac, pCommand );
838 break;
839
840 case eSmeCommandWmStatusChange:
841 csrReleaseCommandWmStatusChange( pMac, pCommand );
842 break;
843
844 case eSmeCommandSetKey:
845 csrReleaseCommandSetKey( pMac, pCommand );
846 break;
847
848 case eSmeCommandRemoveKey:
849 csrReleaseCommandRemoveKey( pMac, pCommand );
850 break;
851
852 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800853 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 csrReleaseCommand( pMac, pCommand );
855 break;
856 }
857 }
858}
859
Jeff Johnson295189b2012-06-20 16:38:30 -0700860void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
861{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800862 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]", NewSubstate, pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700863
Jeff Johnson295189b2012-06-20 16:38:30 -0700864 if(pMac->roam.curSubState[sessionId] == NewSubstate)
865 {
866 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700867 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 pMac->roam.curSubState[sessionId] = NewSubstate;
869}
870
Jeff Johnson295189b2012-06-20 16:38:30 -0700871eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
872{
873 eCsrRoamState PreviousState;
874
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800875 smsLog( pMac, LOG1, "CSR RoamState: [ %d <== %d ]", NewRoamState, pMac->roam.curState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700876
877 PreviousState = pMac->roam.curState[sessionId];
878
879 if ( NewRoamState != pMac->roam.curState[sessionId] )
880 {
881 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
882 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
883 {
884 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
885 }
886
887 pMac->roam.curState[sessionId] = NewRoamState;
888 }
889 return( PreviousState );
890}
891
Jeff Johnson295189b2012-06-20 16:38:30 -0700892void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_U8 catOffset)
893{
894 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 if(catOffset)
896 {
897 pMac->roam.configParam.bCatRssiOffset = catOffset;
898 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
899 {
900 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)CSR_BEST_RSSI_VALUE - (int)(i * catOffset);
901 }
902 }
903}
904
Jeff Johnson295189b2012-06-20 16:38:30 -0700905static void initConfigParam(tpAniSirGlobal pMac)
906{
907 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
909 pMac->roam.configParam.channelBondingMode24GHz = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
910 pMac->roam.configParam.channelBondingMode5GHz = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700911
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
913 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
914 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
915 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
916 pMac->roam.configParam.HeartbeatThresh24 = 40;
917 pMac->roam.configParam.HeartbeatThresh50 = 40;
918 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
919 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
920 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700921 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 pMac->roam.configParam.RTSThreshold = 2346;
923 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
924 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
925 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
926 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
927 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
928 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
929 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
930 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
931 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
932 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
933 {
934 pMac->roam.configParam.BssPreferValue[i] = i;
935 }
936 csrAssignRssiForCategory(pMac, CSR_DEFAULT_RSSI_DB_GAP);
937 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
938 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
939 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
941 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
942 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
943 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
944 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
945 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800946 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
947 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700948#ifdef WLAN_AP_STA_CONCURRENCY
949 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
950 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
951 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
952 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
953 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Vinay Malekal05fdc812012-12-17 13:04:30 -0800954 pMac->roam.configParam.nNumChanCombinedConc = CSR_NUM_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700955#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700956 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
957 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
958 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
959 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700960#ifdef WLAN_FEATURE_VOWIFI_11R
961 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
962#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700963#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
964 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
965 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
966 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
967 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
968 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
969 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
970 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
971 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
972 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
973 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
974 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -0800975 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700976#endif
Jeff Johnsone7245742012-09-05 17:12:55 -0700977#ifdef WLAN_FEATURE_11AC
978 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
979#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700980
981 pMac->roam.configParam.addTSWhenACMIsOff = 0;
982 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -0700983
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700984 //Remove this code once SLM_Sessionization is supported
985 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -0700986 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700987
Jeff Johnsone7245742012-09-05 17:12:55 -0700988}
Jeff Johnson295189b2012-06-20 16:38:30 -0700989eCsrBand csrGetCurrentBand(tHalHandle hHal)
990{
991 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
992 return pMac->roam.configParam.bandCapability;
993}
Srinivas Girigowdade697412013-02-14 16:31:48 -0800994
995#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
996tANI_BOOLEAN csrIsChannelInCountryValidList(tpAniSirGlobal pMac, tANI_U8 channel)
997{
998 /* Get country code from CFG */
999 tANI_U8 *pCountryCode = pMac->scan.countryCodeCurrent;
1000 tANI_U8 i = 0;
1001 v_BOOL_t retVal = FALSE;
1002 tANI_U8 *pCountryValidChannelList = pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
1003 tANI_U8 *pNumChannels = &pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
1004
1005 /* Compare against KR valid list */
1006 if ((0 == strncmp(pCountryCode, "KR", 2)) &&
1007 (NULL != pCountryValidChannelList))
1008 {
1009 for (i = 0; i <(*pNumChannels); i++)
1010 {
1011 if (channel == pCountryValidChannelList[i])
1012 {
1013 retVal = TRUE;
1014 break;
1015 }
1016 }
1017 }
1018 else
1019 {
1020 retVal = csrRoamIsChannelValid(pMac, channel);
1021 }
1022
1023 return retVal;
1024}
1025
1026void csr_SetRevision(tpAniSirGlobal pMac, tANI_U8 revision)
1027{
1028 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1029 pNeighborRoamInfo->cfgParams.countryChannelInfo.revision = revision;
1030}
1031
1032/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001033 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001034*/
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001035eHalStatus csrFlushBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001036{
1037 eHalStatus status = eHAL_STATUS_SUCCESS;
1038 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1039
1040 /* Free up the memory first (if required) */
1041 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1042 {
1043 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1044 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001045 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001046 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001047 return status;
1048}
1049
1050
1051
1052/*
1053 This function flushes the roam scan cache and creates fresh cache
1054 based on the input channel list
1055*/
1056eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1057 const tANI_U8 *pChannelList,
1058 const tANI_U8 numChannels)
1059{
1060 eHalStatus status = eHAL_STATUS_SUCCESS;
1061 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1062
Srinivas Girigowdade697412013-02-14 16:31:48 -08001063 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1064
1065 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1066 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1067
1068 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1069 {
1070 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1071 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1072 return eHAL_STATUS_RESOURCES;
1073 }
1074
1075 /* Update the roam global structure */
1076 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1077 pChannelList,
1078 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1079 return status;
1080}
1081
1082/* This function modifies the bgscan channel list set via config ini or
1083 runtime, whenever the band changes.
1084 if the band is auto, then no operation is performed on the channel list
1085 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1086 if the band is 5G, then make sure channel list contains only 5G valid channels
1087*/
1088eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1089 eCsrBand eBand)
1090{
1091 eHalStatus status = eHAL_STATUS_SUCCESS;
1092 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1093 tANI_U8 outNumChannels = 0;
1094 tANI_U8 inNumChannels = 0;
1095 tANI_U8 *inPtr = NULL;
1096 tANI_U8 i = 0;
1097 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1098
1099 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1100
1101 {
1102 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1103 "No update required for channel list "
1104 "either cfg.ini channel list is not set up or "
1105 "auto band (Band %d)", eBand);
1106 return status;
1107 }
1108
1109 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1110 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1111 if (eCSR_BAND_24 == eBand)
1112 {
1113 for (i = 0; i < inNumChannels; i++)
1114 {
1115 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrIsChannelInCountryValidList(pMac, inPtr[i]))
1116 {
1117 ChannelList[outNumChannels++] = inPtr[i];
1118 }
1119 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001120 csrFlushBgScanRoamChannelList(pMac);
1121 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001122 }
1123 else if (eCSR_BAND_5G == eBand)
1124 {
1125 for (i = 0; i < inNumChannels; i++)
1126 {
1127 /* Add 5G Non-DFS channel */
1128 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1129 csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1130 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1131 {
1132 ChannelList[outNumChannels++] = inPtr[i];
1133 }
1134 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001135 csrFlushBgScanRoamChannelList(pMac);
1136 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001137 }
1138 else if (eCSR_BAND_ALL == eBand)
1139 {
1140 for (i = 0; i < inNumChannels; i++)
1141 {
1142 if (csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1143 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1144 {
1145 ChannelList[outNumChannels++] = inPtr[i];
1146 }
1147 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001148 csrFlushBgScanRoamChannelList(pMac);
1149 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001150 }
1151 else
1152 {
1153 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1154 "Invalid band, No operation carried out (Band %d)", eBand);
1155 status = eHAL_STATUS_INVALID_PARAMETER;
1156 }
1157
1158 return status;
1159}
1160
1161/*
1162 This function initializes the valid channel list based on country code
1163*/
1164eHalStatus csrInitCountryValidChannelList(tpAniSirGlobal pMac,
1165 tANI_U8 Revision)
1166{
1167 eHalStatus status = eHAL_STATUS_SUCCESS;
1168 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001169 tANI_U8 **pOutChannelList = &pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001170 tANI_U8 *pNumChannels = &pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
1171 const tANI_U8 *pChannelList = NULL;
1172
1173 if (SME_KR_3 == Revision)
1174 {
1175 pChannelList = KR_3;
1176 *pNumChannels = sizeof(KR_3)/sizeof(KR_3[0]);
1177 }
1178 else if (SME_KR_24 == Revision)
1179 {
1180 pChannelList = KR_24;
1181 *pNumChannels = sizeof(KR_24)/sizeof(KR_24[0]);
1182 }
1183 else if (SME_KR_25 == Revision)
1184 {
1185 pChannelList = KR_25;
1186 *pNumChannels = sizeof(KR_25)/sizeof(KR_25[0]);
1187 }
1188 else
1189 return eHAL_STATUS_INVALID_PARAMETER;
1190
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001191 /* Free any existing channel list */
1192 vos_mem_free(*pOutChannelList);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001193
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001194 *pOutChannelList = vos_mem_malloc(*pNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001195
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001196 if (NULL == *pOutChannelList)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001197 {
1198 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1199 *pNumChannels = 0;
1200 return eHAL_STATUS_RESOURCES;
1201 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001202 /* Update the roam global structure */
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001203 palCopyMemory(pMac->hHdd, *pOutChannelList, pChannelList, *pNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001204 return status;
1205}
1206
1207#endif
1208
Jeff Johnson295189b2012-06-20 16:38:30 -07001209eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1210{
1211 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1212 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001213 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1214 (eBand == eCSR_BAND_24))
1215 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001216 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001217 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001218 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001219 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 pMac->roam.configParam.uCfgDot11Mode, eBand);
1221 return eHAL_STATUS_INVALID_PARAMETER;
1222 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1224 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1225 (eBand == eCSR_BAND_5G))
1226 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001227 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001229 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001230 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 pMac->roam.configParam.uCfgDot11Mode, eBand);
1232 return eHAL_STATUS_INVALID_PARAMETER;
1233 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001234 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001235 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001236 pMac->roam.configParam.eBand = eBand;
1237 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001238 csrScanGetSupportedChannels( pMac );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001239#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1240 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
1241#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 status = csrInitGetChannels( pMac );
1243 if (eHAL_STATUS_SUCCESS == status)
1244 csrInitChannelList( hHal );
1245 return status;
1246}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001247
1248
Jeff Johnsone7245742012-09-05 17:12:55 -07001249/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1250 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1251 * Ideally we should have kept the ini value and enum value same and representing the same
1252 * cb values as in 11n standard i.e.
1253 * Set to 1 (SCA) if the secondary channel is above the primary channel
1254 * Set to 3 (SCB) if the secondary channel is below the primary channel
1255 * Set to 0 (SCN) if no secondary channel is present
1256 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1257 * 0 - secondary none
1258 * 1 - secondary LOW
1259 * 2 - secondary HIGH
1260 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1261 * The enum values are as follows:
1262 * PHY_SINGLE_CHANNEL_CENTERED = 0
1263 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1264 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1265 */
1266ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1267{
1268
1269 ePhyChanBondState phyCbState;
1270 switch (cbIniValue) {
1271 // secondary none
1272 case 0:
1273 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1274 break;
1275 // secondary LOW
1276 case 1:
1277 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1278 break;
1279 // secondary HIGH
1280 case 2:
1281 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1282 break;
1283#ifdef WLAN_FEATURE_11AC
1284 case 3:
1285 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1286 break;
1287 case 4:
1288 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1289 break;
1290 case 5:
1291 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1292 break;
1293 case 6:
1294 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1295 break;
1296 case 7:
1297 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1298 break;
1299 case 8:
1300 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1301 break;
1302 case 9:
1303 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1304 break;
1305#endif
1306 default:
1307 // If an invalid value is passed, disable CHANNEL BONDING
1308 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1309 break;
1310 }
1311 return phyCbState;
1312}
1313
1314v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1315{
1316
1317 v_U32_t cbIniValue;
1318 switch (phyCbState) {
1319 // secondary none
1320 case PHY_SINGLE_CHANNEL_CENTERED:
1321 cbIniValue = 0;
1322 break;
1323 // secondary LOW
1324 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1325 cbIniValue = 1;
1326 break;
1327 // secondary HIGH
1328 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1329 cbIniValue = 2;
1330 break;
1331#ifdef WLAN_FEATURE_11AC
1332 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1333 cbIniValue = 3;
1334 break;
1335 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1336 cbIniValue = 4;
1337 break;
1338 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1339 cbIniValue = 5;
1340 break;
1341 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1342 cbIniValue = 6;
1343 break;
1344 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1345 cbIniValue = 7;
1346 break;
1347 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1348 cbIniValue = 8;
1349 break;
1350 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1351 cbIniValue = 9;
1352 break;
1353#endif
1354 default:
1355 // return some invalid value
1356 cbIniValue = 10;
1357 break;
1358 }
1359 return cbIniValue;
1360}
Jeff Johnson295189b2012-06-20 16:38:30 -07001361
1362eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1363{
1364 eHalStatus status = eHAL_STATUS_SUCCESS;
1365
1366 if(pParam)
1367 {
1368 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1369 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1370 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1371 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1372 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1373 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1374
1375 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001376 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1377
Jeff Johnsone7245742012-09-05 17:12:55 -07001378 /* channelBondingMode5GHz plays a dual role right now
1379 * 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
1380 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1381 */
1382 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001384 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001385 }
1386 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1387 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1388 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001389 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001390 }
1391 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1393 pMac->roam.configParam.phyMode = pParam->phyMode;
1394 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1395 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1396 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1397 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1398 pMac->roam.configParam.TxRate = pParam->TxRate;
1399 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1400 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1401 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1402 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1403 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 //if HDD passed down non zero values then only update,
1405 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001406 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 {
1408 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1409 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001410 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001411 {
1412 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1413 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001414 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 {
1416 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1417 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001418 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001419 {
1420 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1421 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001422 if (pParam->nActiveMaxChnTimeBtc)
1423 {
1424 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1425 }
1426 if (pParam->nActiveMinChnTimeBtc)
1427 {
1428 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1429 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001430#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001431 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001432 {
1433 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1434 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001435 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001436 {
1437 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1438 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001439 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001440 {
1441 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1442 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001443 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001444 {
1445 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1446 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001447 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001448 {
1449 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1450 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001451 if (pParam->nNumChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001452 {
1453 pMac->roam.configParam.nNumChanCombinedConc = pParam->nNumChanCombinedConc;
1454 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001455#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001456 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001457 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 {
1459 //Change the unit from second to microsecond
1460 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1462 {
1463 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1464 }
1465 else
1466 {
1467 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1468 }
1469 }
1470 else
1471 {
1472 pMac->roam.configParam.impsSleepTime = 0;
1473 }
1474 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1476 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 //if HDD passed down non zero values for age params, then only update,
1478 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001479 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 {
1481 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001483 if(pParam->scanAgeTimeNCNPS)
1484 {
1485 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001487 if(pParam->scanAgeTimeNCPS)
1488 {
1489 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 if(pParam->scanAgeTimeCNPS)
1492 {
1493 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1494 }
1495 if(pParam->scanAgeTimeCPS)
1496 {
1497 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1498 }
1499
1500 csrAssignRssiForCategory(pMac, pParam->bCatRssiOffset);
1501 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1502 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1503 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1504 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1505 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001506 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1507 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1509 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1510 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1511 //Assign this before calling CsrInit11dInfo
1512 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 if( csrIs11dSupported( pMac ) )
1514 {
1515 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1516 }
1517 else
1518 {
1519 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1520 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001521
1522 /* Initialize the power + channel information if 11h is enabled.
1523 If 11d is enabled this information has already been initialized */
1524 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1525 {
1526 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1527 }
1528
1529
Jeff Johnson295189b2012-06-20 16:38:30 -07001530#ifdef WLAN_FEATURE_VOWIFI_11R
1531 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001532 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001533#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001534#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001536 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001537 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001538 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001539 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001540 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001541 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001542 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001543#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001544#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1545 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
1546#endif
1547#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001548 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
1549#endif
1550
Jeff Johnson295189b2012-06-20 16:38:30 -07001551#ifdef FEATURE_WLAN_CCX
1552 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1553#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001554#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1555 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.neighborRoamConfig, &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001556 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1557 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1558 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1559 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1560 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1561 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1562 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1563 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001564 {
1565 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001566 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07001567 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1568 {
1569 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1570 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001571 smsLog( pMac, LOG1, "");
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 }
1573#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1575 pMac->scan.fValidateList = pParam->fValidateList;
1576 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1577 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001578 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001580 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1581 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1582 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1583 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1584 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1585 * single session
1586 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001587 //Remove this code once SLM_Sessionization is supported
1588 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001589 pMac->roam.configParam.doBMPSWorkaround = 0;
1590
Jeff Johnsone7245742012-09-05 17:12:55 -07001591#ifdef WLAN_FEATURE_11AC
1592 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001593 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001594 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001595#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001596 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 }
1598
1599 return status;
1600}
1601
Jeff Johnson295189b2012-06-20 16:38:30 -07001602eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1603{
1604 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 if(pParam)
1606 {
1607 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1608 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1609 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1610 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1611 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1612 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001613 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1614 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1616 pParam->phyMode = pMac->roam.configParam.phyMode;
1617 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1618 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1619 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1620 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1621 pParam->TxRate = pMac->roam.configParam.TxRate;
1622 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1623 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1624 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1625 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1626 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1628 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1629 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1630 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001631#ifdef WLAN_AP_STA_CONCURRENCY
1632 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1633 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1634 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1635 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1636 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001637 pParam->nNumChanCombinedConc = pMac->roam.configParam.nNumChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001638#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001639 //Change the unit from microsecond to second
1640 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1641 pParam->eBand = pMac->roam.configParam.eBand;
1642 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1643 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1644 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1645 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1646 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1647 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1648 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1649 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1650 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1651 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1652 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1653 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1654 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1656 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1657 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1658 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1660 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1661 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1662 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1663 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001664 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001665 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001666 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001667 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001668
1669#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1670 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1671#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001672#ifdef WLAN_FEATURE_11AC
1673 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001674 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001675 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001676#endif
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001677 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 csrSetChannels(pMac, pParam);
1679
1680 status = eHAL_STATUS_SUCCESS;
1681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 return (status);
1683}
1684
Jeff Johnson295189b2012-06-20 16:38:30 -07001685eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1686{
1687 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1688 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1689 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1690 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 do
1692 {
1693 if(eCSR_BAND_24 == eBand)
1694 {
1695 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1696 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1697 }
1698 if(eCSR_BAND_5G == eBand)
1699 {
1700 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1701 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1702 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1703 )
1704 {
1705 break;
1706 }
1707 }
1708 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1709 {
1710 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1711 }
1712 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1713 {
1714 newPhyMode = eCSR_DOT11_MODE_AUTO;
1715 }
1716 else
1717 {
1718 //Check for dual band and higher capability first
1719 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1720 {
1721 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1722 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1723 }
1724 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1725 {
1726 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1727 if(eCSR_BAND_24 == eBand) break;
1728 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1729 eBand = eCSR_BAND_5G;
1730 }
1731 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1732 {
1733 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1734 if(eCSR_BAND_5G == eBand) break;
1735 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1736 eBand = eCSR_BAND_24;
1737 }
1738 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1739 {
1740 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1741 if(eCSR_BAND_5G == eBand) break;
1742 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1743 eBand = eCSR_BAND_24;
1744 }
1745 else if(eCSR_DOT11_MODE_11n & phyMode)
1746 {
1747 newPhyMode = eCSR_DOT11_MODE_11n;
1748 }
1749 else if(eCSR_DOT11_MODE_abg & phyMode)
1750 {
1751 newPhyMode = eCSR_DOT11_MODE_abg;
1752 }
1753 else if(eCSR_DOT11_MODE_11a & phyMode)
1754 {
1755 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1756 {
1757 if(eCSR_BAND_ALL == eBand)
1758 {
1759 newPhyMode = eCSR_DOT11_MODE_abg;
1760 }
1761 else
1762 {
1763 //bad setting
1764 break;
1765 }
1766 }
1767 else
1768 {
1769 newPhyMode = eCSR_DOT11_MODE_11a;
1770 eBand = eCSR_BAND_5G;
1771 }
1772 }
1773 else if(eCSR_DOT11_MODE_11g & phyMode)
1774 {
1775 newPhyMode = eCSR_DOT11_MODE_11g;
1776 eBand = eCSR_BAND_24;
1777 }
1778 else if(eCSR_DOT11_MODE_11b & phyMode)
1779 {
1780 newPhyMode = eCSR_DOT11_MODE_11b;
1781 eBand = eCSR_BAND_24;
1782 }
1783 else
1784 {
1785 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001786 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 newPhyMode = eCSR_DOT11_MODE_AUTO;
1788 }
1789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 //Done validating
1791 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 //Now we need to check whether a restart is needed.
1793 if(eBand != pMac->roam.configParam.eBand)
1794 {
1795 fRestartNeeded = eANI_BOOLEAN_TRUE;
1796 break;
1797 }
1798 if(newPhyMode != pMac->roam.configParam.phyMode)
1799 {
1800 fRestartNeeded = eANI_BOOLEAN_TRUE;
1801 break;
1802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 if(HAL_STATUS_SUCCESS(status))
1805 {
1806 pMac->roam.configParam.eBand = eBand;
1807 pMac->roam.configParam.phyMode = newPhyMode;
1808 if(pfRestartNeeded)
1809 {
1810 *pfRestartNeeded = fRestartNeeded;
1811 }
1812 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001813 return (status);
1814}
1815
Jeff Johnson295189b2012-06-20 16:38:30 -07001816void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
1817{
1818 tANI_U8 Index;
1819 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 // for dual band NICs, don't need to trim the channel list....
1821 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
1822 {
1823 // 2.4 GHz band operation requires the channel list to be trimmed to
1824 // the 2.4 GHz channels only...
1825 if ( CSR_IS_24_BAND_ONLY( pMac ) )
1826 {
1827 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
1828 Index++ )
1829 {
1830 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
1831 {
1832 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1833 cChannels++;
1834 }
1835 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1837 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1838 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1839 // only if we need to.
1840 //
1841 // The amount of memory to clear is the number of channesl that we trimmed
1842 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1843
1844 if ( pChannelList->numChannels > cChannels )
1845 {
1846 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1847 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1848
1849 }
1850
1851 pChannelList->numChannels = cChannels;
1852 }
1853 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
1854 {
1855 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
1856 {
1857 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
1858 {
1859 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1860 cChannels++;
1861 }
1862 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1864 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1865 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1866 // only if we need to.
1867 //
1868 // The amount of memory to clear is the number of channesl that we trimmed
1869 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1870 if ( pChannelList->numChannels > cChannels )
1871 {
1872 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1873 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1874 }
1875
1876 pChannelList->numChannels = cChannels;
1877 }
1878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001879}
Jeff Johnson295189b2012-06-20 16:38:30 -07001880#define INFRA_AP_DEFAULT_CHANNEL 6
1881eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
1882{
1883 tANI_U8 index= 0;
1884 eHalStatus status = eHAL_STATUS_FAILURE;
1885 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
1886 {
1887 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
1888 status = eHAL_STATUS_SUCCESS;
1889 break;
1890 }
1891 }
1892 return status;
1893}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001894
1895eHalStatus csrGet5GChannels(tpAniSirGlobal pMac)
1896{
1897 eHalStatus status = eHAL_STATUS_SUCCESS;
1898 tANI_U8 num20MHzChannelsFound = 0;
1899 VOS_STATUS vosStatus;
1900 tANI_U8 num40MHzChannelsFound = 0;
1901 tANI_U8 Index = 0;
1902 tANI_U8 channelList = 0;
1903
1904 // Updating the defaultpower Table for changed Domain Id
1905 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1906 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1907
1908 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1909 {
1910 smsLog( pMac, LOGE, FL("failed to get channels"));
1911 status = eHAL_STATUS_FAILURE;
1912 }
1913 else
1914 {
1915 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1916 {
1917 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1918 }
1919
1920 // Move the only 5GHZ channel list to the global data,
1921 // As 2.4GHZ list coming from the AP for the changed domain
1922 // structure -- this will be used as the scan list
1923 for(channelList = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1924 {
1925 // If Channel is 5GHz just break the for loop
1926 if(!(pMac->scan.base20MHzChannels.channelList[ channelList ] > 0 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 14))
1927 break;
1928 }
1929 // Update the 5G channels from nv.bin
1930 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1931 {
1932 if(pMac->scan.defaultPowerTable[Index].chanId >= 36 && pMac->scan.defaultPowerTable[Index].chanId <= 165)
1933 {
1934 pMac->scan.base20MHzChannels.channelList[ channelList ] = pMac->scan.defaultPowerTable[Index].chanId;
1935 channelList++;
1936 }
1937 }
1938
1939 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1940 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1941 // Filling the remaining index as Zero Just for causion
1942 for(Index = pMac->scan.base20MHzChannels.numChannels; Index < WNI_CFG_VALID_CHANNEL_LIST_LEN; Index++)
1943 pMac->scan.base20MHzChannels.channelList[ Index ] = 0;
1944 }
1945 return status;
1946}
1947
1948eHalStatus csrGet24GChannels(tpAniSirGlobal pMac)
1949{
1950 eHalStatus status = eHAL_STATUS_SUCCESS;
1951 tANI_U8 num20MHzChannelsFound = 0;
1952 VOS_STATUS vosStatus;
1953 tANI_U8 Index = 0;
1954 tANI_U8 num40MHzChannelsFound = 0;
1955 tANI_U8 channelList5GBackup[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}, nuum5GchannelListBackup;
1956 tANI_U8 channelList = 0;
1957
1958 // Read the scan channel list (including the power limit) from EEPROM
1959 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1960 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1961
1962 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1963 {
1964 smsLog( pMac, LOGE, FL("failed to get channels \n"));
1965 status = eHAL_STATUS_FAILURE;
1966 }
1967 else
1968 {
1969 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1970 {
1971 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1972 }
1973
1974 // Move the 2.4GHZ channel list only to the global data,
1975 // As 5GHz list been provided by AP as part of 11d IE
1976 // structure -- this will be used as the scan list
1977 for(channelList = 0, nuum5GchannelListBackup = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1978 {
1979 if(pMac->scan.base20MHzChannels.channelList[ channelList ] >= 36 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 165)
1980 {
1981 // First taking the 5GHz channel list backup
1982 channelList5GBackup[nuum5GchannelListBackup] = pMac->scan.base20MHzChannels.channelList[ channelList ];
1983 nuum5GchannelListBackup++;
1984 }
1985 }
1986 // Updating the 2.4GHz list
1987 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1988 {
1989 if(pMac->scan.defaultPowerTable[Index].chanId > 0 && pMac->scan.defaultPowerTable[Index].chanId <= 14)
1990 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[Index].chanId;
1991 }
1992 // Restoring the Backed up 5 GHZ channels
1993 for(channelList = 0;channelList < nuum5GchannelListBackup; channelList++ )
1994 {
1995 pMac->scan.base20MHzChannels.channelList[ Index ] = channelList5GBackup[channelList];
1996 Index++;
1997 }
1998
1999 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > Index) ? num20MHzChannelsFound : Index;
2000 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > Index) ? num20MHzChannelsFound : Index;
2001 }
2002 return (status);
2003}
2004
Jeff Johnson295189b2012-06-20 16:38:30 -07002005eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2006{
2007 eHalStatus status = eHAL_STATUS_SUCCESS;
2008 tANI_U8 num20MHzChannelsFound = 0;
2009 VOS_STATUS vosStatus;
2010 tANI_U8 Index = 0;
2011 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002012
Jeff Johnson295189b2012-06-20 16:38:30 -07002013
2014 //TODO: this interface changed to include the 40MHz channel list
2015 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2016 // Read the scan channel list (including the power limit) from EEPROM
2017 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2018 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2019 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002021 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002022 status = eHAL_STATUS_FAILURE;
2023 }
2024 else
2025 {
2026 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2027 {
2028 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2029 }
2030 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2031 // Move the channel list to the global data
2032 // structure -- this will be used as the scan list
2033 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2034 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002035 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 }
2037 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2038 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2039 {
2040 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2041 }
2042 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2043 {
2044 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2045 }
2046 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002048 return (status);
2049}
2050
Jeff Johnson295189b2012-06-20 16:38:30 -07002051eHalStatus csrInitChannelList( tHalHandle hHal )
2052{
2053 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2054 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2056 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002057 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2058 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002060 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002061
2062 return (status);
2063}
Jeff Johnson295189b2012-06-20 16:38:30 -07002064eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2065 tCsrUpdateConfigParam *pUpdateConfigParam)
2066{
2067 eHalStatus status = eHAL_STATUS_FAILURE;
2068 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2070 status = CsrInit11dInfo(pMac, ps11dinfo);
2071 return status;
2072}
2073
Jeff Johnson295189b2012-06-20 16:38:30 -07002074static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2075{
2076 eHalStatus status = eHAL_STATUS_FAILURE;
2077 tANI_U8 index;
2078 tANI_U32 count=0;
2079 tSirMacChanInfo *pChanInfo;
2080 tSirMacChanInfo *pChanInfoStart;
2081 tANI_BOOLEAN applyConfig = TRUE;
2082
2083 if(!ps11dinfo)
2084 {
2085 return (status);
2086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2088 {
2089 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2090 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
2091 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
2092 if(!HAL_STATUS_SUCCESS(status)) return (status);
2093 }
2094 else
2095 {
2096 //No change
2097 return (eHAL_STATUS_SUCCESS);
2098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 //legacy maintenance
2100 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
2101 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2102 if(!HAL_STATUS_SUCCESS(status)) return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 //Tush: at csropen get this initialized with default, during csr reset if this
2104 // already set with some value no need initilaize with default again
2105 if(0 == pMac->scan.countryCodeCurrent[0])
2106 {
2107 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
2108 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2109 if(!HAL_STATUS_SUCCESS(status)) return (status);
2110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002111 // need to add the max power channel list
2112 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2113 {
2114 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2115 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002116 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2117 {
2118 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2119 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2120 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2121 pChanInfo++;
2122 count++;
2123 }
2124 if(count)
2125 {
2126 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2127 }
2128 palFreeMemory(pMac->hHdd, pChanInfoStart);
2129 }
2130 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2131 if( HAL_STATUS_SUCCESS(status) )
2132 {
2133 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2134 {
2135 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2136 {
2137 applyConfig = FALSE;
2138 }
2139 }
2140
2141 if(TRUE == applyConfig)
2142 {
2143 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002144 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002145 }
2146
2147 }
2148 return (status);
2149}
2150/* Initialize the Channel + Power List in the local cache and in the CFG */
2151eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2152{
2153 tANI_U8 index;
2154 tANI_U32 count=0;
2155 tSirMacChanInfo *pChanInfo;
2156 tSirMacChanInfo *pChanInfoStart;
2157
2158 if(!ps11dinfo || !pMac)
2159 {
2160 return eHAL_STATUS_FAILURE;
2161 }
2162
2163 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2164 {
2165 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2166 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002167
2168 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2169 {
2170 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2171 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2172 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2173 pChanInfo++;
2174 count++;
2175 }
2176 if(count)
2177 {
2178 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2179 }
2180 palFreeMemory(pMac->hHdd, pChanInfoStart);
2181 }
2182
Jeff Johnsone7245742012-09-05 17:12:55 -07002183 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002184}
2185
2186//pCommand may be NULL
2187//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2188void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2189{
2190 tListElem *pEntry, *pNextEntry;
2191 tSmeCmd *pDupCommand;
2192 tDblLinkList localList;
2193
2194 vos_mem_zero(&localList, sizeof(tDblLinkList));
2195 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2196 {
2197 smsLog(pMac, LOGE, FL(" failed to open list"));
2198 return;
2199 }
2200 csrLLLock( &pMac->sme.smeCmdPendingList );
2201 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2202 while( pEntry )
2203 {
2204 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2205 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 // Remove the previous command if..
2207 // - the new roam command is for the same RoamReason...
2208 // - the new roam command is a NewProfileList.
2209 // - the new roam command is a Forced Dissoc
2210 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2211 if (
2212 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2213 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002214 /* This peermac check is requried for Softap/GO scenarios
2215 * For STA scenario below OR check will suffice as pCommand will
2216 * always be NULL for STA scenarios
2217 */
2218 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2220 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2221 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2222 ||
2223 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002224 ( (sessionId == pDupCommand->sessionId) &&
2225 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 ((eCsrForcedDisassoc == eRoamReason) ||
2227 (eCsrHddIssued == eRoamReason))
2228 )
2229 )
2230 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002231 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 // Remove the 'stale' roam command from the pending list...
2233 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2234 {
2235 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2236 }
2237 }
2238 pEntry = pNextEntry;
2239 }
2240 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2241
2242 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2243 {
2244 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2245 //Tell caller that the command is cancelled
2246 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2247 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2248 csrReleaseCommandRoam(pMac, pDupCommand);
2249 }
2250 csrLLClose(&localList);
2251}
Jeff Johnson295189b2012-06-20 16:38:30 -07002252eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2253 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2254{
2255 eHalStatus status = eHAL_STATUS_SUCCESS;
2256#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2257 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2258#endif
2259 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2261 {
2262 pSession = CSR_GET_SESSION( pMac, sessionId );
2263 }
2264 else
2265 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002266 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002267 VOS_ASSERT(0);
2268 return eHAL_STATUS_FAILURE;
2269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002270 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2271 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002272 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002274 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2275 /*
2276 * Decrement bRefAssocStartCnt for FT reassoc failure.
2277 * Reason: For FT reassoc failures, we first call
2278 * csrRoamCallCallback before notifying a failed roam
2279 * completion through csrRoamComplete. The latter in
2280 * turn calls csrRoamProcessResults which tries to
2281 * once again call csrRoamCallCallback if bRefAssocStartCnt
2282 * is non-zero. Since this is redundant for FT reassoc
2283 * failure, decrement bRefAssocStartCnt.
2284 */
2285 pSession->bRefAssocStartCnt--;
2286 }
2287
Jeff Johnson295189b2012-06-20 16:38:30 -07002288 if ( (pSession == NULL) ||
2289 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2290 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002291 smsLog(pMac, LOG1, "Session ID is not valid");
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 return eHAL_STATUS_FAILURE;
2293 }
2294
2295 if(NULL != pSession->callback)
2296 {
2297 if( pRoamInfo )
2298 {
2299 pRoamInfo->sessionId = (tANI_U8)sessionId;
2300 }
2301
2302 /* avoid holding the global lock when making the roaming callback , original change came
2303 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2304 is possible on other OS ports where the callback may need to take locks to protect
2305 HDD state
2306 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2307 that may actually depend on the lock being held */
2308 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2309 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2310 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2311 }
2312 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2313 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2314#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2315 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
2316 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2317 {
2318 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2319 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2320 if(NULL != pRoamInfo->pBssDesc)
2321 {
2322 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2323 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2324 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2326 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2327 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
2328 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2329 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2330 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2333 {
2334 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2335 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2336 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002338 if(eCSR_ROAM_RESULT_FORCED == u2)
2339 {
2340 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2341 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2342 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002344 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2345 {
2346 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2347 connectionStatus.reason = eCSR_REASON_DISASSOC;
2348 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2349 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2351 {
2352 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2353 connectionStatus.reason = eCSR_REASON_DEAUTH;
2354 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002356#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2357
2358 return (status);
2359}
Jeff Johnson295189b2012-06-20 16:38:30 -07002360// Returns whether handoff is currently in progress or not
2361tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2362{
2363#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2364 return csrNeighborRoamIsHandoffInProgress(pMac);
2365#else
2366 return eANI_BOOLEAN_FALSE;
2367#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002368}
Jeff Johnson295189b2012-06-20 16:38:30 -07002369eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2370 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2371{
2372 eHalStatus status = eHAL_STATUS_SUCCESS;
2373 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2374 tANI_U16 reasonCode;
2375 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002376
2377 if(!pSession)
2378 {
2379 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2380 return eHAL_STATUS_FAILURE;
2381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002382
2383 //Restore AC weight in case we change it
2384 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2385 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002386 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 -07002387 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2388 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2389 }
2390
2391 if ( fMICFailure )
2392 {
2393 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2394 }
2395 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2396 {
2397 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002398 }
2399 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 {
2401 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002403#ifdef WLAN_FEATURE_VOWIFI_11R
2404 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2405 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2406 {
2407 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2408 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002409 }
2410 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002411#endif
2412 if(pSession->pConnectBssDesc)
2413 {
2414 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2415 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002416
Jeff Johnson295189b2012-06-20 16:38:30 -07002417
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002418 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2419 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2420 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2421
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2423
2424 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2425
2426 if(HAL_STATUS_SUCCESS(status))
2427 {
2428 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002429#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2430 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2431 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2432 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002433 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2435 }
2436#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002437 }
2438 else
2439 {
2440 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2441 }
2442
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 return (status);
2444}
Jeff Johnson295189b2012-06-20 16:38:30 -07002445
Jeff Johnson295189b2012-06-20 16:38:30 -07002446/* ---------------------------------------------------------------------------
2447 \fn csrRoamIssueDisassociateStaCmd
2448 \brief csr function that HDD calls to disassociate a associated station
2449 \param sessionId - session Id for Soft AP
2450 \param pPeerMacAddr - MAC of associated station to delete
2451 \param reason - reason code, be one of the tSirMacReasonCodes
2452 \return eHalStatus
2453 ---------------------------------------------------------------------------*/
2454eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2455 tANI_U32 sessionId,
2456 tANI_U8 *pPeerMacAddr,
2457 tANI_U32 reason)
2458{
2459 eHalStatus status = eHAL_STATUS_SUCCESS;
2460 tSmeCmd *pCommand;
2461
2462 do
2463 {
2464 pCommand = csrGetCommandBuffer( pMac );
2465 if ( !pCommand )
2466 {
2467 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2468 status = eHAL_STATUS_RESOURCES;
2469 break;
2470 }
2471 pCommand->command = eSmeCommandRoam;
2472 pCommand->sessionId = (tANI_U8)sessionId;
2473 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2474 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2475 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2476 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2477 if( !HAL_STATUS_SUCCESS( status ) )
2478 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002479 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 csrReleaseCommandRoam( pMac, pCommand );
2481 }
2482 }while(0);
2483
2484 return status;
2485}
2486
2487
Jeff Johnson295189b2012-06-20 16:38:30 -07002488/* ---------------------------------------------------------------------------
2489 \fn csrRoamIssueDeauthSta
2490 \brief csr function that HDD calls to delete a associated station
2491 \param sessionId - session Id for Soft AP
2492 \param pPeerMacAddr - MAC of associated station to delete
2493 \param reason - reason code, be one of the tSirMacReasonCodes
2494 \return eHalStatus
2495 ---------------------------------------------------------------------------*/
2496eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2497 tANI_U32 sessionId,
2498 tANI_U8 *pPeerMacAddr,
2499 tANI_U32 reason)
2500{
2501 eHalStatus status = eHAL_STATUS_SUCCESS;
2502 tSmeCmd *pCommand;
2503
2504 do
2505 {
2506 pCommand = csrGetCommandBuffer( pMac );
2507 if ( !pCommand )
2508 {
2509 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2510 status = eHAL_STATUS_RESOURCES;
2511 break;
2512 }
2513 pCommand->command = eSmeCommandRoam;
2514 pCommand->sessionId = (tANI_U8)sessionId;
2515 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2516 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2517 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2518 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2519 if( !HAL_STATUS_SUCCESS( status ) )
2520 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002521 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 csrReleaseCommandRoam( pMac, pCommand );
2523 }
2524 }while(0);
2525
2526 return status;
2527}
Jeff Johnson295189b2012-06-20 16:38:30 -07002528eHalStatus
2529csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2530 tANI_BOOLEAN bEnable )
2531{
2532 eHalStatus status = eHAL_STATUS_FAILURE;
2533 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2534 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 if (!pSession)
2536 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002537 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 return (status);
2539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002540 if (pSession->pConnectBssDesc)
2541 {
2542 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2543 }
2544 else
2545 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002546 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002547 return (status);
2548 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002549 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = %02x-%02x-%02x-%02x-%02x-%02x, Enable = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2551 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] , bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2553 return (status);
2554}
Jeff Johnson295189b2012-06-20 16:38:30 -07002555eHalStatus
2556csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2557 VOS_MODULE_ID modId, void *pUsrContext,
2558 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2559{
2560 eHalStatus status = eHAL_STATUS_SUCCESS;
2561 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2562 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 if (!pSession)
2564 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002565 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 return (status);
2567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 if(pSession->pConnectBssDesc)
2569 {
2570 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2571 }
2572 else
2573 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002574 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 return (status);
2576 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002577 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2579 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2581 return (status);
2582}
Jeff Johnson295189b2012-06-20 16:38:30 -07002583eHalStatus
2584csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2585 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2586{
2587 eHalStatus status = eHAL_STATUS_SUCCESS;
2588 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2589 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2590
2591 if (!pSession)
2592 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002593 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 return (status);
2595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 if(pSession->pConnectBssDesc)
2597 {
2598 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2599 }
2600 else
2601 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002602 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 return (status);
2604 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002605 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2607 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2608
2609 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2610
2611 return (status);
2612}
Jeff Johnson295189b2012-06-20 16:38:30 -07002613eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2614{
2615 eHalStatus status = eHAL_STATUS_SUCCESS;
2616 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2617 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002618
2619 if (!pSession)
2620 {
2621 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2622 return eHAL_STATUS_FAILURE;
2623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002624
2625 if(pSession->pConnectBssDesc)
2626 {
2627 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2628 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002629 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2631 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2633
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302634 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002635 if(!HAL_STATUS_SUCCESS(status))
2636 {
2637 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2638 }
2639
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 return (status);
2641}
2642
Jeff Johnson295189b2012-06-20 16:38:30 -07002643eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2644{
2645 eHalStatus status = eHAL_STATUS_SUCCESS;
2646 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2647 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002648
2649 if(!pSession)
2650 {
2651 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2652 return eHAL_STATUS_FAILURE;
2653 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002654
2655 // If no BSS description was found in this connection (happens with start IBSS), then
2656 // nix the BSS description that we keep around for the connected BSS) and get out...
2657 if(NULL == pBssDesc)
2658 {
2659 csrFreeConnectBssDesc(pMac, sessionId);
2660 }
2661 else
2662 {
2663 size = pBssDesc->length + sizeof( pBssDesc->length );
2664 if(NULL != pSession->pConnectBssDesc)
2665 {
2666 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2667 {
2668 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2669 csrFreeConnectBssDesc(pMac, sessionId);
2670 }
2671 }
2672 if(NULL == pSession->pConnectBssDesc)
2673 {
2674 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2675 }
2676 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2677 {
2678 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2679 }
2680 }
2681
2682 return (status);
2683}
2684
Jeff Johnson295189b2012-06-20 16:38:30 -07002685eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2686 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2687 tDot11fBeaconIEs *pIes)
2688{
2689 eHalStatus status = eHAL_STATUS_SUCCESS;
2690 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302692 if (pIes == NULL)
2693 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002694
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 do
2696 {
2697 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2698 //get qos
2699 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2700 //get SSID
2701 if(pIes->SSID.present)
2702 {
2703 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2704 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2705 }
2706 else
2707 pBssConfig->SSID.length = 0;
2708 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2709 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002710 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 //Return failed if profile doesn't have an SSID either.
2712 if(pProfile->SSIDs.numOfSSIDs == 0)
2713 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002714 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 status = eHAL_STATUS_FAILURE;
2716 break;
2717 }
2718 }
2719 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2720 {
2721 pBssConfig->eBand = eCSR_BAND_5G;
2722 }
2723 else
2724 {
2725 pBssConfig->eBand = eCSR_BAND_24;
2726 }
2727 //phymode
2728 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2729 {
2730 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2731 }
2732 else
2733 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002734 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 //force it
2736 if(eCSR_BAND_24 == pBssConfig->eBand)
2737 {
2738 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2739 }
2740 else
2741 {
2742 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2743 }
2744 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 //Qos
2746 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2747 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2748 {
2749 //Joining BSS is not 11n capable and WMM is disabled on client.
2750 //Disable QoS and WMM
2751 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2752 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302753
2754 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302755 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302756 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2757 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2758 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2759 {
2760 //Joining BSS is 11n capable and WMM is disabled on AP.
2761 //Assume all HT AP's are QOS AP's and enable WMM
2762 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2763 }
2764
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 //auth type
2766 switch( pProfile->negotiatedAuthType )
2767 {
2768 default:
2769 case eCSR_AUTH_TYPE_WPA:
2770 case eCSR_AUTH_TYPE_WPA_PSK:
2771 case eCSR_AUTH_TYPE_WPA_NONE:
2772 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2773 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2774 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 case eCSR_AUTH_TYPE_SHARED_KEY:
2776 pBssConfig->authType = eSIR_SHARED_KEY;
2777 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002778 case eCSR_AUTH_TYPE_AUTOSWITCH:
2779 pBssConfig->authType = eSIR_AUTO_SWITCH;
2780 break;
2781 }
2782 //short slot time
2783 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2784 {
2785 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2786 }
2787 else
2788 {
2789 pBssConfig->uShortSlotTime = 0;
2790 }
2791 if(pBssConfig->BssCap.ibss)
2792 {
2793 //We don't support 11h on IBSS
2794 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2795 }
2796 else
2797 {
2798 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2799 }
2800 //power constraint
2801 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2802 //heartbeat
2803 if ( CSR_IS_11A_BSS( pBssDesc ) )
2804 {
2805 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2806 }
2807 else
2808 {
2809 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2810 }
2811 //Join timeout
2812 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002813 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 if ( pBssDesc->beaconInterval )
2815 {
2816 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002817 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 }
2819 else
2820 {
2821 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2822 }
2823 //validate CB
2824 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2825 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 return (status);
2827}
2828
Jeff Johnson295189b2012-06-20 16:38:30 -07002829static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2830 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2831{
2832 eHalStatus status = eHAL_STATUS_SUCCESS;
2833 tANI_U8 operationChannel = 0;
2834 tANI_U8 qAPisEnabled = FALSE;
2835 //SSID
2836 pBssConfig->SSID.length = 0;
2837 if(pProfile->SSIDs.numOfSSIDs)
2838 {
2839 //only use the first one
2840 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2841 }
2842 else
2843 {
2844 //SSID must present
2845 return eHAL_STATUS_FAILURE;
2846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 //Settomg up the capabilities
2848 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2849 {
2850 pBssConfig->BssCap.ibss = 1;
2851 }
2852 else
2853 {
2854 pBssConfig->BssCap.ess = 1;
2855 }
2856 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2857 {
2858 pBssConfig->BssCap.privacy = 1;
2859 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 pBssConfig->eBand = pMac->roam.configParam.eBand;
2861 //phymode
2862 if(pProfile->ChannelInfo.ChannelList)
2863 {
2864 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2865 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2867 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 //QOS
2869 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 if ( pBssConfig->BssCap.ess == 1 )
2871 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 /*For Softap case enable WMM*/
2873 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2874 qAPisEnabled = TRUE;
2875 }
2876 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2878 qAPisEnabled = TRUE;
2879 } else {
2880 qAPisEnabled = FALSE;
2881 }
2882 } else {
2883 qAPisEnabled = TRUE;
2884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2886 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2887 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2888 )
2889 {
2890 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2891 } else {
2892 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2893 }
2894
2895 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08002896 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 {
2898 default:
2899 case eCSR_AUTH_TYPE_WPA:
2900 case eCSR_AUTH_TYPE_WPA_PSK:
2901 case eCSR_AUTH_TYPE_WPA_NONE:
2902 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2903 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2904 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 case eCSR_AUTH_TYPE_SHARED_KEY:
2906 pBssConfig->authType = eSIR_SHARED_KEY;
2907 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 case eCSR_AUTH_TYPE_AUTOSWITCH:
2909 pBssConfig->authType = eSIR_AUTO_SWITCH;
2910 break;
2911 }
2912 //short slot time
2913 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
2914 {
2915 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2916 }
2917 else
2918 {
2919 pBssConfig->uShortSlotTime = 0;
2920 }
2921 //power constraint. We don't support 11h on IBSS
2922 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2923 pBssConfig->uPowerLimit = 0;
2924 //heartbeat
2925 if ( eCSR_BAND_5G == pBssConfig->eBand )
2926 {
2927 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2928 }
2929 else
2930 {
2931 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2932 }
2933 //Join timeout
2934 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002935
Jeff Johnson295189b2012-06-20 16:38:30 -07002936 return (status);
2937}
Jeff Johnson295189b2012-06-20 16:38:30 -07002938static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
2939{
2940 eHalStatus status = eHAL_STATUS_FAILURE;
2941 tDot11fBeaconIEs *pIes = NULL;
2942
2943 do
2944 {
2945 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
2946 {
2947 //err msg
2948 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002949 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 break;
2951 }
2952 //check if the AP is QAP & it supports APSD
2953 if( CSR_IS_QOS_BSS(pIes) )
2954 {
2955 return eHAL_STATUS_SUCCESS;
2956 }
2957 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 return status;
2959}
2960
Jeff Johnson295189b2012-06-20 16:38:30 -07002961void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
2962{
Jeff Johnson295189b2012-06-20 16:38:30 -07002963 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
2964 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
2965 // See !!Note: below in this function...
2966 tANI_U32 PrivacyEnabled = 0;
2967 tANI_U32 RsnEnabled = 0;
2968 tANI_U32 WepDefaultKeyId = 0;
2969 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
2970 tANI_U32 Key0Length = 0;
2971 tANI_U32 Key1Length = 0;
2972 tANI_U32 Key2Length = 0;
2973 tANI_U32 Key3Length = 0;
2974
2975 // Reserve for the biggest key
2976 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
2977 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
2978 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
2979 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
2980
2981 switch ( pProfile->negotiatedUCEncryptionType )
2982 {
2983 case eCSR_ENCRYPT_TYPE_NONE:
2984
2985 // for NO encryption, turn off Privacy and Rsn.
2986 PrivacyEnabled = 0;
2987 RsnEnabled = 0;
2988
2989 // WEP key length and Wep Default Key ID don't matter in this case....
2990
2991 // clear out the WEP keys that may be hanging around.
2992 Key0Length = 0;
2993 Key1Length = 0;
2994 Key2Length = 0;
2995 Key3Length = 0;
2996
2997 break;
2998
2999 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3000
3001 // Privacy is ON. NO RSN for Wep40 static key.
3002 PrivacyEnabled = 1;
3003 RsnEnabled = 0;
3004
3005 // Set the Wep default key ID.
3006 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 // Wep key size if 5 bytes (40 bits).
3008 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3009
3010 // set encryption keys in the CFG database or clear those that are not present in this profile.
3011 if ( pProfile->Keys.KeyLength[0] )
3012 {
3013 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
3014 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3015 }
3016 else
3017 {
3018 Key0Length = 0;
3019 }
3020
3021 if ( pProfile->Keys.KeyLength[1] )
3022 {
3023 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
3024 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
3025 }
3026 else
3027 {
3028 Key1Length = 0;
3029 }
3030
3031 if ( pProfile->Keys.KeyLength[2] )
3032 {
3033 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
3034 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3035 }
3036 else
3037 {
3038 Key2Length = 0;
3039 }
3040
3041 if ( pProfile->Keys.KeyLength[3] )
3042 {
3043 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
3044 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3045 }
3046 else
3047 {
3048 Key3Length = 0;
3049 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 break;
3051
3052 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3053
3054 // Privacy is ON. NO RSN for Wep40 static key.
3055 PrivacyEnabled = 1;
3056 RsnEnabled = 0;
3057
3058 // Set the Wep default key ID.
3059 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3060
3061 // Wep key size if 13 bytes (104 bits).
3062 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3063
3064 // set encryption keys in the CFG database or clear those that are not present in this profile.
3065 if ( pProfile->Keys.KeyLength[0] )
3066 {
3067 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3068 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3069 }
3070 else
3071 {
3072 Key0Length = 0;
3073 }
3074
3075 if ( pProfile->Keys.KeyLength[1] )
3076 {
3077 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3078 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3079 }
3080 else
3081 {
3082 Key1Length = 0;
3083 }
3084
3085 if ( pProfile->Keys.KeyLength[2] )
3086 {
3087 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3088 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3089 }
3090 else
3091 {
3092 Key2Length = 0;
3093 }
3094
3095 if ( pProfile->Keys.KeyLength[3] )
3096 {
3097 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3098 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3099 }
3100 else
3101 {
3102 Key3Length = 0;
3103 }
3104
3105 break;
3106
3107 case eCSR_ENCRYPT_TYPE_WEP40:
3108 case eCSR_ENCRYPT_TYPE_WEP104:
3109 case eCSR_ENCRYPT_TYPE_TKIP:
3110 case eCSR_ENCRYPT_TYPE_AES:
3111#ifdef FEATURE_WLAN_WAPI
3112 case eCSR_ENCRYPT_TYPE_WPI:
3113#endif /* FEATURE_WLAN_WAPI */
3114 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3115 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3116 PrivacyEnabled = (0 != fPrivacy);
3117
3118 // turn on RSN enabled for WPA associations
3119 RsnEnabled = 1;
3120
3121 // WEP key length and Wep Default Key ID don't matter in this case....
3122
3123 // clear out the static WEP keys that may be hanging around.
3124 Key0Length = 0;
3125 Key1Length = 0;
3126 Key2Length = 0;
3127 Key3Length = 0;
3128
3129 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 default:
3131 PrivacyEnabled = 0;
3132 RsnEnabled = 0;
3133 break;
3134 }
3135
3136 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3137 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3138 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3139 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3140 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3141 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3142 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3143 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3144}
3145
Jeff Johnson295189b2012-06-20 16:38:30 -07003146static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3147{
3148 tANI_U32 len = 0;
3149 if(pSSID->length <= WNI_CFG_SSID_LEN)
3150 {
3151 len = pSSID->length;
3152 }
3153 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3154}
3155
Jeff Johnson295189b2012-06-20 16:38:30 -07003156eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3157{
3158 eHalStatus status = eHAL_STATUS_SUCCESS;
3159 tANI_U32 QoSEnabled;
3160 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 // set the CFG enable/disable variables based on the qosType being configured...
3162 switch( qosType )
3163 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3165 QoSEnabled = FALSE;
3166 WmeEnabled = TRUE;
3167 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3169 QoSEnabled = FALSE;
3170 WmeEnabled = TRUE;
3171 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003172 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3173 QoSEnabled = FALSE;
3174 WmeEnabled = TRUE;
3175 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3177 QoSEnabled = TRUE;
3178 WmeEnabled = FALSE;
3179 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 case eCSR_MEDIUM_ACCESS_11e_HCF:
3181 QoSEnabled = TRUE;
3182 WmeEnabled = FALSE;
3183 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 default:
3185 case eCSR_MEDIUM_ACCESS_DCF:
3186 QoSEnabled = FALSE;
3187 WmeEnabled = FALSE;
3188 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 }
3190 //save the WMM setting for later use
3191 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3193 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 return (status);
3195}
Jeff Johnson295189b2012-06-20 16:38:30 -07003196static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3197 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3198{
3199 eHalStatus status = eHAL_STATUS_FAILURE;
3200 int i;
3201 eCsrCfgDot11Mode cfgDot11Mode;
3202 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
3204 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003206
3207 if( NULL != pIes )
3208 {
3209 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 // Originally, we thought that for 11a networks, the 11a rates are always
3211 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3212 // appear in the Operational Rate set. Consequently, in either case, we
3213 // would blindly put the rates we support into our Operational Rate set
3214 // (including the basic rates, which we have already verified are
3215 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 // However, it turns out that this is not always the case. Some AP's
3217 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3218 // too. Now, we're a little more careful:
3219 pDstRate = pOpRateSet->rate;
3220 if(pIes->SuppRates.present)
3221 {
3222 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3223 {
3224 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3225 {
3226 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003227 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003228 }
3229 }
3230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3232 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3233 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3234 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3235 {
3236 // If there are Extended Rates in the beacon, we will reflect those
3237 // extended rates that we support in out Extended Operational Rate
3238 // set:
3239 pDstRate = pExRateSet->rate;
3240 if(pIes->ExtSuppRates.present)
3241 {
3242 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3243 {
3244 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3245 {
3246 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3247 pExRateSet->numRates++;
3248 }
3249 }
3250 }
3251 }
3252 }//Parsing BSSDesc
3253 else
3254 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003255 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 }
3257 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3258 return status;
3259}
3260
3261static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3262 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3263{
3264 int i;
3265 tANI_U8 *pDstRate;
3266 eCsrCfgDot11Mode cfgDot11Mode;
3267 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3268 tANI_U32 OperationalRatesLength = 0;
3269 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3270 tANI_U32 ExtendedOperationalRatesLength = 0;
3271 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3272 tANI_U32 ProprietaryOperationalRatesLength = 0;
3273 tANI_U32 PropRatesEnable = 0;
3274 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3275 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003276 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 if( NULL != pIes )
3278 {
3279 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 // Originally, we thought that for 11a networks, the 11a rates are always
3281 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3282 // appear in the Operational Rate set. Consequently, in either case, we
3283 // would blindly put the rates we support into our Operational Rate set
3284 // (including the basic rates, which we have already verified are
3285 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 // However, it turns out that this is not always the case. Some AP's
3287 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3288 // too. Now, we're a little more careful:
3289 pDstRate = OperationalRates;
3290 if(pIes->SuppRates.present)
3291 {
3292 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3293 {
3294 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3295 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3296 {
3297 *pDstRate++ = pIes->SuppRates.rates[ i ];
3298 OperationalRatesLength++;
3299 }
3300 }
3301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3303 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3304 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3305 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3306 {
3307 // If there are Extended Rates in the beacon, we will reflect those
3308 // extended rates that we support in out Extended Operational Rate
3309 // set:
3310 pDstRate = ExtendedOperationalRates;
3311 if(pIes->ExtSuppRates.present)
3312 {
3313 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3314 {
3315 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3316 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3317 {
3318 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3319 ExtendedOperationalRatesLength++;
3320 }
3321 }
3322 }
3323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 // Enable proprietary MAC features if peer node is Airgo node and STA
3325 // user wants to use them
3326 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3327 {
3328 PropRatesEnable = 1;
3329 }
3330 else
3331 {
3332 PropRatesEnable = 0;
3333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003334 // For ANI network companions, we need to populate the proprietary rate
3335 // set with any proprietary rates we found in the beacon, only if user
3336 // allows them...
3337 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3338 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3339 {
3340 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3341 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3342 {
3343 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3344 }
3345 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3346 }
3347 else {
3348 // No proprietary modes...
3349 ProprietaryOperationalRatesLength = 0;
3350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 /* Get MCS Rate */
3352 pDstRate = MCSRateIdxSet;
3353 if ( pIes->HTCaps.present )
3354 {
3355 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3356 {
3357 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3358 {
3359 MCSRateLength++;
3360 *pDstRate++ = i;
3361 }
3362 }
3363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003364 // Set the operational rate set CFG variables...
3365 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3366 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3367 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3368 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3369 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3370 ProprietaryOperationalRates,
3371 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3372 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3373 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3374 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3375 }//Parsing BSSDesc
3376 else
3377 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003378 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 }
3380}
3381
Jeff Johnson295189b2012-06-20 16:38:30 -07003382static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3383 tCsrRoamProfile *pProfile )
3384{
3385 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3386 { 8,
3387 { SIR_MAC_RATE_6,
3388 SIR_MAC_RATE_9,
3389 SIR_MAC_RATE_12,
3390 SIR_MAC_RATE_18,
3391 SIR_MAC_RATE_24,
3392 SIR_MAC_RATE_36,
3393 SIR_MAC_RATE_48,
3394 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3396 { 4,
3397 { SIR_MAC_RATE_1,
3398 SIR_MAC_RATE_2,
3399 SIR_MAC_RATE_5_5,
3400 SIR_MAC_RATE_11 } } };
3401
3402
3403 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3404 { SIR_MAC_RATE_72,
3405 SIR_MAC_RATE_96,
3406 SIR_MAC_RATE_108 } };
3407 eCsrCfgDot11Mode cfgDot11Mode;
3408 eCsrBand eBand;
3409 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3410 tANI_U32 OperationalRatesLength = 0;
3411 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3412 tANI_U32 ExtendedOperationalRatesLength = 0;
3413 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3414 tANI_U32 ProprietaryOperationalRatesLength = 0;
3415 tANI_U32 PropRatesEnable = 0;
3416 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 if(pProfile->ChannelInfo.ChannelList)
3418 {
3419 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3420 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3423 // networks, the 11b rates appear in the Operational Rate set. In either case,
3424 // we can blindly put the rates we support into our Operational Rate set
3425 // (including the basic rates, which we have already verified are supported
3426 // earlier in the roaming decision).
3427 if ( eCSR_BAND_5G == eBand )
3428 {
3429 // 11a rates into the Operational Rate Set.
3430 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3431 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3432 palCopyMemory( pMac->hHdd, OperationalRates,
3433 DefaultSupportedRates11a.supportedRateSet.rate,
3434 OperationalRatesLength );
3435
3436 // Nothing in the Extended rate set.
3437 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 // populate proprietary rates if user allows them
3439 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3440 {
3441 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3442 sizeof(*DefaultSupportedPropRates.propRate);
3443 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3444 DefaultSupportedPropRates.propRate,
3445 ProprietaryOperationalRatesLength );
3446 }
3447 else
3448 {
3449 // No proprietary modes
3450 ProprietaryOperationalRatesLength = 0;
3451 }
3452 }
3453 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3454 {
3455 // 11b rates into the Operational Rate Set.
3456 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3457 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3458 palCopyMemory( pMac->hHdd, OperationalRates,
3459 DefaultSupportedRates11b.supportedRateSet.rate,
3460 OperationalRatesLength );
3461 // Nothing in the Extended rate set.
3462 ExtendedOperationalRatesLength = 0;
3463 // No proprietary modes
3464 ProprietaryOperationalRatesLength = 0;
3465 }
3466 else
3467 {
3468 // 11G
3469
3470 // 11b rates into the Operational Rate Set.
3471 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3472 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3473 palCopyMemory( pMac->hHdd, OperationalRates,
3474 DefaultSupportedRates11b.supportedRateSet.rate,
3475 OperationalRatesLength );
3476
3477 // 11a rates go in the Extended rate set.
3478 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3479 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3480 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3481 DefaultSupportedRates11a.supportedRateSet.rate,
3482 ExtendedOperationalRatesLength );
3483
3484 // populate proprietary rates if user allows them
3485 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3486 {
3487 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3488 sizeof(*DefaultSupportedPropRates.propRate);
3489 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3490 DefaultSupportedPropRates.propRate,
3491 ProprietaryOperationalRatesLength );
3492 }
3493 else
3494 {
3495 // No proprietary modes
3496 ProprietaryOperationalRatesLength = 0;
3497 }
3498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3500 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3501 {
3502 PropRatesEnable = 1;
3503 }
3504 else
3505 {
3506 PropRatesEnable = 0;
3507 }
3508
3509 // Set the operational rate set CFG variables...
3510 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3511 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3512 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3513 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3514 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3515 ProprietaryOperationalRates,
3516 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3517 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003518}
Jeff Johnson295189b2012-06-20 16:38:30 -07003519void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3520{
3521 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003522
Jeff Johnson295189b2012-06-20 16:38:30 -07003523 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3524 tANI_U32 sessionId;
3525 tSmeCmd *pCommand = NULL;
3526
3527 if(NULL == pEntry)
3528 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003529 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 return;
3531 }
3532 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3533 sessionId = pCommand->sessionId;
3534
3535 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3536 {
3537 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3538 }
3539}
3540
Jeff Johnson295189b2012-06-20 16:38:30 -07003541//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3542tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3543{
3544 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3545 {
3546 return (WNI_CFG_PHY_MODE_11B);
3547 }
3548 else
3549 {
3550 if(eCSR_BAND_24 == band)
3551 return (WNI_CFG_PHY_MODE_11G);
3552 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 return (WNI_CFG_PHY_MODE_11A);
3554}
Jeff Johnson295189b2012-06-20 16:38:30 -07003555
Jeff Johnsone7245742012-09-05 17:12:55 -07003556
3557#ifdef WLAN_FEATURE_11AC
3558ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3559{
3560 switch ( aniCBMode )
3561 {
3562 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3563 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3564 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3565 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3566 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3567 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3568 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3569 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3570 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003571 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003572 return PHY_SINGLE_CHANNEL_CENTERED;
3573 }
3574}
3575#endif
3576
Jeff Johnson295189b2012-06-20 16:38:30 -07003577//pIes may be NULL
3578eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3579 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3580 tDot11fBeaconIEs *pIes)
3581{
3582 eHalStatus status = eHAL_STATUS_SUCCESS;
3583 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3584 tANI_U8 channel = 0;
3585 //Make sure we have the domain info for the BSS we try to connect to.
3586 //Do we need to worry about sequence for OSs that are not Windows??
3587 if(pBssDesc)
3588 {
3589 if(csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
3590 {
3591 //Make sure the 11d info from this BSSDesc can be applied
3592 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3593 csrApplyCountryInformation( pMac, TRUE );
3594 }
Kiran4a17ebe2013-01-31 10:43:43 -08003595 if ((csrIs11dSupported (pMac)) && pIes)
3596 {
3597 if (!pIes->Country.present)
3598 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003601 //Qos
3602 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3603 //SSID
3604 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3605 //fragment threshold
3606 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3607 //RTS threshold
3608 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3609
3610 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3611
3612 //Auth type
3613 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3614 //encryption type
3615 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3616 //short slot time
3617 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 //11d
3619 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3620 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3621 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 /*//11h
3623 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3624 */
3625 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3626 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003627
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile))
3629 {
3630 channel = pProfile->operationChannel;
3631 }
3632 else
3633 {
3634 if(pBssDesc)
3635 {
3636 channel = pBssDesc->channelId;
3637 }
3638 }
3639 if(0 != channel)
3640 {
3641 if(CSR_IS_CHANNEL_24GHZ(channel))
3642 {//for now if we are on 2.4 Ghz, CB will be always disabled
3643 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3644 }
3645 else
3646 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003647 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 }
3649 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003650#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003651 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3652 // in function csrConvertCBIniValueToPhyCBState()
3653 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3654 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003655 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003656 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003657 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003658 }
3659 else
3660 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003661 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003662 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003663 }
3664 else
3665#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3667 //Rate
3668 //Fixed Rate
3669 if(pBssDesc)
3670 {
3671 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3672 }
3673 else
3674 {
3675 csrSetCfgRateSetFromProfile(pMac, pProfile);
3676 }
3677 //Make this the last CFG to set. The callback will trigger a join_req
3678 //Join time out
3679 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3680
3681 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003682 return (status);
3683}
3684
Jeff Johnson295189b2012-06-20 16:38:30 -07003685eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3686 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3687{
3688 eHalStatus status;
3689 tBssConfigParam *pBssConfig;
3690 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003691
3692 if(!pSession)
3693 {
3694 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3695 return eHAL_STATUS_FAILURE;
3696 }
3697
Jeff Johnson295189b2012-06-20 16:38:30 -07003698 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3699 if(HAL_STATUS_SUCCESS(status))
3700 {
3701 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3702 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3703 if(HAL_STATUS_SUCCESS(status))
3704 {
3705 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003706 /* This will allow to pass cbMode during join req */
3707 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 //For IBSS, we need to prepare some more information
3709 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003710 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 )
3712 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003713 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 }
3715 // If we are in an IBSS, then stop the IBSS...
3716 ////Not worry about WDS connection for now
3717 if ( csrIsConnStateIbss( pMac, sessionId ) )
3718 {
3719 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3720 }
3721 else
3722 {
3723 // if we are in an Infrastructure association....
3724 if ( csrIsConnStateInfra( pMac, sessionId ) )
3725 {
3726 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3727 // across SSIDs (roaming to a new SSID)... //
3728 //Not worry about WDS connection for now
3729 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
3730 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
3731 {
3732 // then we need to disassociate from the Infrastructure network...
3733 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
3734 }
3735 else
3736 {
3737 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3738 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
3739 if ( pBssDesc )
3740 {
3741 // Set parameters for this Bss.
3742 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3743 }
3744 }
3745 }
3746 else
3747 {
3748 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3749 // Nothing to stop.
3750 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 )
3753 {
3754 // Set parameters for this Bss.
3755 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3756 }
3757 }
3758 }
3759 }//Success getting BSS config info
3760 palFreeMemory(pMac->hHdd, pBssConfig);
3761 }//Allocate memory
3762
3763 return (status);
3764}
3765
Jeff Johnson295189b2012-06-20 16:38:30 -07003766eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3767 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3768{
3769 eCsrJoinState eRoamState = eCsrContinueRoaming;
3770 eHalStatus status;
3771 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3772 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3773 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003774
3775 if(!pSession)
3776 {
3777 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3778 return (eCsrStopRoaming);
3779 }
3780
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 if( CSR_IS_WDS_STA( pProfile ) )
3782 {
3783 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3784 if( !HAL_STATUS_SUCCESS( status ) )
3785 {
3786 eRoamState = eCsrStopRoaming;
3787 }
3788 }
3789 else
3790 {
3791 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3792 {
3793 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3794 return (eCsrStopRoaming);
3795 }
3796 if ( csrIsInfraBssDesc( pBssDesc ) )
3797 {
3798 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3799 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3800 // have changed and handle the changes (without disturbing the current association).
3801
3802 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3803 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3804 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3805 )
3806 {
3807 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3808 // with Authenticating first. To force this, stop the current association (Disassociate) and
3809 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3810 // a new Association.
3811 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3812 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003813 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d"), pProfile->AuthType, pProfile->EncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3815 {
3816 eRoamState = eCsrReassocToSelfNoCapChange;
3817 }
3818 else
3819 {
3820 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 //The key changes
3822 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3823 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3824 if(HAL_STATUS_SUCCESS(status))
3825 {
3826 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003827 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 //Reapply the config including Keys so reassoc is happening.
3829 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, &bssConfig, pIesLocal);
3830 if(!HAL_STATUS_SUCCESS(status))
3831 {
3832 eRoamState = eCsrStopRoaming;
3833 }
3834 }
3835 else
3836 {
3837 eRoamState = eCsrStopRoaming;
3838 }
3839 }//same profile
3840 }
3841 else
3842 {
3843 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
3844 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3845 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003846 smsLog(pMac, LOGW, FL(" fail to issue disassociate"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 eRoamState = eCsrStopRoaming;
3848 }
3849 }
3850 }
3851 else
3852 {
3853 // note: we used to pre-auth here with open authentication networks but that was not working so well.
3854 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
3855 // work much better.
3856 //
3857 //
3858 // stop the existing network before attempting to join the new network...
3859 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3860 {
3861 eRoamState = eCsrStopRoaming;
3862 }
3863 }
3864 }//Infra
3865 else
3866 {
3867 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3868 {
3869 eRoamState = eCsrStopRoaming;
3870 }
3871 }
3872 if( pIesLocal && !pScanResult->pvIes )
3873 {
3874 palFreeMemory(pMac->hHdd, pIesLocal);
3875 }
3876 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 return( eRoamState );
3878}
3879
Jeff Johnson295189b2012-06-20 16:38:30 -07003880eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3881 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3882{
3883 eHalStatus status = eHAL_STATUS_SUCCESS;
3884 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3886 roamInfo.pBssDesc = pBssDesc;
3887 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3888 return (status);
3889}
Jeff Johnson295189b2012-06-20 16:38:30 -07003890//In case no matching BSS is found, use whatever default we can find
3891static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3892{
3893 //Need to get all negotiated types in place first
3894 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003895 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 {
3897 default:
3898 case eCSR_AUTH_TYPE_WPA:
3899 case eCSR_AUTH_TYPE_WPA_PSK:
3900 case eCSR_AUTH_TYPE_WPA_NONE:
3901 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3902 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3903 break;
3904
3905 case eCSR_AUTH_TYPE_SHARED_KEY:
3906 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
3907 break;
3908
3909 case eCSR_AUTH_TYPE_AUTOSWITCH:
3910 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
3911 break;
3912 }
3913 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
3914 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3915 //In this case, the multicast encryption needs to follow the uncast ones.
3916 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
3917 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3918}
3919
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07003920
3921static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
3922{
3923 switch(pCommand->u.roamCmd.roamReason)
3924 {
3925 case eCsrLostLink1:
3926 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
3927 break;
3928 case eCsrLostLink2:
3929 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
3930 break;
3931 case eCsrLostLink3:
3932 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
3933 break;
3934 default:
3935 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
3936 pCommand->u.roamCmd.roamReason);
3937 break;
3938 }
3939}
3940
Jeff Johnson295189b2012-06-20 16:38:30 -07003941static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
3942{
3943 eHalStatus status;
3944 tCsrScanResult *pScanResult = NULL;
3945 eCsrJoinState eRoamState = eCsrStopRoaming;
3946 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
3947 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
3948 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
3949#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3950 v_U8_t acm_mask = 0;
3951#endif
3952 tANI_U32 sessionId = pCommand->sessionId;
3953 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3954 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
3955 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003956
3957 if(!pSession)
3958 {
3959 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3960 return (eCsrStopRoaming);
3961 }
3962
Jeff Johnson295189b2012-06-20 16:38:30 -07003963 do
3964 {
3965 // Check for Cardbus eject condition, before trying to Roam to any BSS
3966 //***if( !balIsCardPresent(pAdapter) ) break;
3967
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07003968 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
3969 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 if(NULL != pBSSList)
3971 {
3972 // When handling AP's capability change, continue to associate to
3973 // same BSS and make sure pRoamBssEntry is not Null.
3974 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
3975 {
3976 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
3977 {
3978 //Try the first BSS
3979 pCommand->u.roamCmd.pLastRoamBss = NULL;
3980 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
3981 }
3982 else
3983 {
3984 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3985 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3986 {
3987 //Done with all the BSSs
3988 //In this case, will tell HDD the completion
3989 break;
3990 }
3991 else
3992 {
3993 //We need to indicate to HDD that we are done with this one.
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07003994 //palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
3996 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
3997 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
3998 pRoamInfo = &roamInfo;
3999 }
4000 }
4001 while(pCommand->u.roamCmd.pRoamBssEntry)
4002 {
4003 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 /*If concurrency enabled take the concurrent connected channel first. */
4005 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004006 if (vos_concurrent_sessions_running() &&
4007 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 {
4009 concurrentChannel =
4010 csrGetConcurrentOperationChannel(pMac);
4011 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004012 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 if ((concurrentChannel) &&
4014 (concurrentChannel ==
4015 pScanResult->Result.BssDescriptor.channelId))
4016 {
4017 //make this 0 because we do not want the
4018 //below check to pass as we don't want to
4019 //connect on other channel
4020 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4021 FL("Concurrent channel match =%d"),
4022 concurrentChannel);
4023 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 }
4025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004026
4027 if (!concurrentChannel)
4028 {
4029
4030 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4031 sessionId, &pScanResult->Result.BssDescriptor,
4032 pCommand->u.roamCmd.roamId)))
4033 {
4034 //Ok to roam this
4035 break;
4036 }
4037 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004038 else
4039 {
4040 eRoamState = eCsrStopRoamingDueToConcurrency;
4041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4043 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4044 {
4045 //Done with all the BSSs
4046 fDone = eANI_BOOLEAN_TRUE;
4047 break;
4048 }
4049 }
4050 if(fDone)
4051 {
4052 break;
4053 }
4054 }
4055 }
4056 //We have something to roam, tell HDD when it is infra.
4057 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4058 //For WDS, the indication is eCSR_ROAM_WDS_IND
4059 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4060 {
4061 if(pRoamInfo)
4062 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004063 if(pSession->bRefAssocStartCnt)
4064 {
4065 pSession->bRefAssocStartCnt--;
4066 //Complete the last association attemp because a new one is about to be tried
4067 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4068 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004070 }
4071 }
4072 /* If the roaming has stopped, not to continue the roaming command*/
4073 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4074 {
4075 //No need to complete roaming here as it already completes
4076 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4077 pCommand->u.roamCmd.roamReason);
4078 eRoamState = eCsrStopRoaming;
4079 csrSetAbortRoamingCommand(pMac, pCommand);
4080 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004081 }
4082 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4083 if(pScanResult)
4084 {
4085 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4087 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004088 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 fDone = eANI_BOOLEAN_TRUE;
4090 eRoamState = eCsrStopRoaming;
4091 break;
4092 }
4093 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4094 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4095 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4096 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4097 CSR_IS_QOS_BSS(pIesLocal) &&
4098 CSR_IS_UAPSD_BSS(pIesLocal) )
4099 {
4100#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4102 pIesLocal);
4103 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4104#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 }
4106 else
4107 {
4108 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4109 }
4110 if( pIesLocal && !pScanResult->Result.pvIes)
4111 {
4112 palFreeMemory(pMac->hHdd, pIesLocal);
4113 }
4114 }
4115 else
4116 {
4117 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4118 }
4119 roamInfo.pProfile = pProfile;
4120 pSession->bRefAssocStartCnt++;
4121 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4122 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4125 {
4126 // If this is a start IBSS profile, then we need to start the IBSS.
4127 if ( CSR_IS_START_IBSS(pProfile) )
4128 {
4129 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 // Attempt to start this IBSS...
4131 csrRoamAssignDefaultParam( pMac, pCommand );
4132 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4133 if(HAL_STATUS_SUCCESS(status))
4134 {
4135 if ( fSameIbss )
4136 {
4137 eRoamState = eCsrStartIbssSameIbss;
4138 }
4139 else
4140 {
4141 eRoamState = eCsrContinueRoaming;
4142 }
4143 }
4144 else
4145 {
4146 //it somehow fail need to stop
4147 eRoamState = eCsrStopRoaming;
4148 }
4149 break;
4150 }
4151 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 )
4154 {
4155 // Attempt to start this WDS...
4156 csrRoamAssignDefaultParam( pMac, pCommand );
4157 /* For AP WDS, we dont have any BSSDescription */
4158 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4159 if(HAL_STATUS_SUCCESS(status))
4160 {
4161 eRoamState = eCsrContinueRoaming;
4162 }
4163 else
4164 {
4165 //it somehow fail need to stop
4166 eRoamState = eCsrStopRoaming;
4167 }
4168 }
4169 else
4170 {
4171 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004172 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 eRoamState = eCsrStopRoaming;
4174 break;
4175 }
4176 }
4177 else //We have BSS
4178 {
4179 //Need to assign these value because they are used in csrIsSameProfile
4180 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4181 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4182 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4183 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4184 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4185 {
4186 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4187 {
4188 eRoamState = eCsrStartIbssSameIbss;
4189 break;
4190 }
4191 }
4192 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4193 {
4194 //trying to connect to the one already connected
4195 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4196 eRoamState = eCsrReassocToSelfNoCapChange;
4197 break;
4198 }
4199 // Attempt to Join this Bss...
4200 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4201 break;
4202 }
4203
4204 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4206 {
4207 //Need to indicate association_completion if association_start has been done
4208 if(pSession->bRefAssocStartCnt > 0)
4209 {
4210 pSession->bRefAssocStartCnt--;
4211 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004212 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4214 eCSR_ROAM_ASSOCIATION_COMPLETION,
4215 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4216 }
4217 }
4218
4219 return( eRoamState );
4220}
4221
Jeff Johnson295189b2012-06-20 16:38:30 -07004222static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4223{
4224 eHalStatus status = eHAL_STATUS_SUCCESS;
4225 eCsrJoinState RoamState;
4226 tANI_U32 sessionId = pCommand->sessionId;
4227
Jeff Johnson295189b2012-06-20 16:38:30 -07004228 //***if( hddIsRadioStateOn( pAdapter ) )
4229 {
4230 // Attept to join a Bss...
4231 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004232
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004234 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 {
4236 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 // and if connected in Infrastructure mode...
4238 if ( csrIsConnStateInfra(pMac, sessionId) )
4239 {
4240 //... then we need to issue a disassociation
4241 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4242 if(!HAL_STATUS_SUCCESS(status))
4243 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004244 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 //roam command is completed by caller in the failed case
4246 fComplete = eANI_BOOLEAN_TRUE;
4247 }
4248 }
4249 else if( csrIsConnStateIbss(pMac, sessionId) )
4250 {
4251 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4252 if(!HAL_STATUS_SUCCESS(status))
4253 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004254 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 //roam command is completed by caller in the failed case
4256 fComplete = eANI_BOOLEAN_TRUE;
4257 }
4258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4260 {
4261 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4262 if(!HAL_STATUS_SUCCESS(status))
4263 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004264 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 //roam command is completed by caller in the failed case
4266 fComplete = eANI_BOOLEAN_TRUE;
4267 }
4268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004269 else
4270 {
4271 fComplete = eANI_BOOLEAN_TRUE;
4272 }
4273 if(fComplete)
4274 {
4275 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004276 if(eCsrStopRoamingDueToConcurrency == RoamState)
4277 {
4278 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4279 }
4280 else
4281 {
4282 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4283 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 }
4285 }
4286 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4287 {
4288 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4289 }
4290 else if ( eCsrStartIbssSameIbss == RoamState )
4291 {
4292 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4293 }
4294 }//hddIsRadioStateOn
4295
4296 return status;
4297}
Jeff Johnson295189b2012-06-20 16:38:30 -07004298eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4299{
4300 tANI_U32 sessionId;
4301 tCsrRoamSession *pSession;
4302 tCsrScanResult *pScanResult = NULL;
4303 tSirBssDescription *pBssDesc = NULL;
4304 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004305 sessionId = pCommand->sessionId;
4306 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004307
4308 if(!pSession)
4309 {
4310 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4311 return eHAL_STATUS_FAILURE;
4312 }
4313
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4315 {
4316 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004317 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4319 return eHAL_STATUS_FAILURE;
4320 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004321 if (pCommand->u.roamCmd.pRoamBssEntry)
4322 {
4323 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4324 pBssDesc = &pScanResult->Result.BssDescriptor;
4325 }
4326 else
4327 {
4328 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004329 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004330 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4331 return eHAL_STATUS_FAILURE;
4332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004333 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4334 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4335 return status;
4336}
4337
Jeff Johnson295189b2012-06-20 16:38:30 -07004338eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4339{
4340 eHalStatus status = eHAL_STATUS_SUCCESS;
4341 tCsrRoamInfo roamInfo;
4342 tANI_U32 sessionId = pCommand->sessionId;
4343 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004344
4345 if(!pSession)
4346 {
4347 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4348 return eHAL_STATUS_FAILURE;
4349 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004350
4351 switch ( pCommand->u.roamCmd.roamReason )
4352 {
4353 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004355 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 case eCsrSmeIssuedDisassocForHandoff:
4358 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4359#if 0 // TODO : Confirm this change
4360 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4361#else
4362 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4363#endif
4364
4365 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004367 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004368 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004372 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004373 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004374 case eCsrHddIssuedReassocToSameAP:
4375 case eCsrSmeIssuedReassocToSameAP:
4376 {
4377 tDot11fBeaconIEs *pIes = NULL;
4378
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 if( pSession->pConnectBssDesc )
4380 {
4381 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4382 if(!HAL_STATUS_SUCCESS(status) )
4383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004384 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004385 }
4386 else
4387 {
4388 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4389 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4390 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4392 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4393 pSession->bRefAssocStartCnt++;
4394 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4395 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4396
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004397 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004398 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4399 &pCommand->u.roamCmd.roamProfile );
4400 if(!HAL_STATUS_SUCCESS(status))
4401 {
4402 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004403 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004404 }
4405
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 palFreeMemory(pMac->hHdd, pIes);
4407 pIes = NULL;
4408 }
4409 }
4410 break;
4411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004413 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004414 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4415 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4416 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004417 case eCsrSmeIssuedFTReassoc:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004418 smsLog(pMac, LOGE, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004419 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4420 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004421
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 case eCsrStopBss:
4423 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4424 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4425 break;
4426
4427 case eCsrForcedDisassocSta:
4428 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4429 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4430 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4431 pCommand->u.roamCmd.reason);
4432 break;
4433
4434 case eCsrForcedDeauthSta:
4435 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4436 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4437 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4438 pCommand->u.roamCmd.reason);
4439 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004440
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004441 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004442 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004443 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4444 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004445 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004446
4447 default:
4448 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4449
4450 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4451 {
4452 //Remember the roaming profile
4453 csrFreeRoamProfile(pMac, sessionId);
4454 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4455 {
4456 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4457 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4458 }
4459 }
4460
4461 //At this point, original uapsd_mask is saved in pCurRoamProfile
4462 //uapsd_mask in the pCommand may change from this point on.
4463
4464 // Attempt to roam with the new scan results (if we need to..)
4465 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004466 if(!HAL_STATUS_SUCCESS(status))
4467 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004468 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 break;
4471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 return (status);
4473}
4474
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004475void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4476{
4477 pCommand->u.roamCmd.pLastRoamBss = NULL;
4478 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4479 //Because u.roamCmd is union and share with scanCmd and StatusChange
4480 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4481}
4482
Jeff Johnson295189b2012-06-20 16:38:30 -07004483void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4484{
4485 if(pCommand->u.roamCmd.fReleaseBssList)
4486 {
4487 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4488 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4489 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4490 }
4491 if(pCommand->u.roamCmd.fReleaseProfile)
4492 {
4493 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4494 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4495 }
4496 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4497 //Because u.roamCmd is union and share with scanCmd and StatusChange
4498 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4499}
4500
Jeff Johnson295189b2012-06-20 16:38:30 -07004501void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4502{
4503 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4504}
Jeff Johnson295189b2012-06-20 16:38:30 -07004505void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4506{
4507 tListElem *pEntry;
4508 tSmeCmd *pCommand;
4509 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004510 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4512 if ( pEntry )
4513 {
4514 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 // If the head of the queue is Active and it is a ROAM command, remove
4516 // and put this on the Free queue.
4517 if ( eSmeCommandRoam == pCommand->command )
4518 {
4519 //we need to process the result first before removing it from active list because state changes
4520 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4521 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4522 if( fReleaseCommand )
4523 {
4524 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4525 {
4526 csrReleaseCommandRoam( pMac, pCommand );
4527 }
4528 else
4529 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004530 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004531 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 }
4533 }
4534 else
4535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004536 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004537 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 }
4539 }
4540 else
4541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004542 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 }
4544 }
4545 else
4546 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004547 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 if( fReleaseCommand )
4550 {
4551 smeProcessPendingQueue( pMac );
4552 }
4553}
4554
Jeff Johnson295189b2012-06-20 16:38:30 -07004555void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4556{
4557 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004558 if(!pSession)
4559 {
4560 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4561 return;
4562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4564 pSession->NumPmkidCandidate = 0;
4565}
Jeff Johnson295189b2012-06-20 16:38:30 -07004566#ifdef FEATURE_WLAN_WAPI
4567void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4568{
4569 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004570 if(!pSession)
4571 {
4572 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4573 return;
4574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4576 pSession->NumBkidCandidate = 0;
4577}
4578#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004579extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4580
Jeff Johnson295189b2012-06-20 16:38:30 -07004581static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4582 tSirBssDescription *pSirBssDesc,
4583 tDot11fBeaconIEs *pIes)
4584{
4585 eHalStatus status = eHAL_STATUS_SUCCESS;
4586 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4587 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004588
4589 if(!pSession)
4590 {
4591 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4592 return eHAL_STATUS_FAILURE;
4593 }
4594
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 if((eCSR_AUTH_TYPE_WPA == authType) ||
4596 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4597 (eCSR_AUTH_TYPE_RSN == authType) ||
4598 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4599#if defined WLAN_FEATURE_VOWIFI_11R
4600 ||
4601 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4602 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4603#endif /* FEATURE_WLAN_WAPI */
4604#ifdef FEATURE_WLAN_WAPI
4605 ||
4606 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4607 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4608#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004609#ifdef WLAN_FEATURE_11W
4610 ||
4611 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4612#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004613 )
4614 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004617 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 }
4619 if( pIesLocal )
4620 {
4621 tANI_U32 nIeLen;
4622 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004623 if((eCSR_AUTH_TYPE_RSN == authType) ||
4624#if defined WLAN_FEATURE_VOWIFI_11R
4625 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4626 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4627#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004628#if defined WLAN_FEATURE_11W
4629 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4630#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4632 {
4633 if(pIesLocal->RSN.present)
4634 {
4635 //Calculate the actual length
4636 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4637 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4638 + 2 //akm_suite_count
4639 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4640 + 2; //reserved
4641 if( pIesLocal->RSN.pmkid_count )
4642 {
4643 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4644 }
4645 //nIeLen doesn't count EID and length fields
4646 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4647 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004648 palZeroMemory(pMac->hHdd, pSession->pWpaRsnRspIE, nIeLen + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4650 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4651 //copy upto akm_suites
4652 pIeBuf = pSession->pWpaRsnRspIE + 2;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004653 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, sizeof(pIesLocal->RSN.version));
4654 pIeBuf += sizeof(pIesLocal->RSN.version);
4655 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.gp_cipher_suite, sizeof(pIesLocal->RSN.gp_cipher_suite));
4656 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
4657 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count, sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
4658 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 if( pIesLocal->RSN.pwise_cipher_suite_count )
4660 {
4661 //copy pwise_cipher_suites
4662 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4663 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4664 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4665 }
4666 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4667 pIeBuf += 2;
4668 if( pIesLocal->RSN.akm_suite_count )
4669 {
4670 //copy akm_suites
4671 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4672 pIesLocal->RSN.akm_suite_count * 4);
4673 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4674 }
4675 //copy the rest
4676 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4677 pIesLocal->RSN.akm_suite_count * 4,
4678 2 + pIesLocal->RSN.pmkid_count * 4);
4679 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4680 }
4681 }
4682 }
4683 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4684 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4685 {
4686 if(pIesLocal->WPA.present)
4687 {
4688 //Calculate the actual length
4689 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4690 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4691 + 2 //auth_suite_count
4692 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4693 // The WPA capabilities follows the Auth Suite (two octects)--
4694 // this field is optional, and we always "send" zero, so just
4695 // remove it. This is consistent with our assumptions in the
4696 // frames compiler; c.f. bug 15234:
4697 //nIeLen doesn't count EID and length fields
4698 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4699 {
4700 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4701 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4702 pIeBuf = pSession->pWpaRsnRspIE + 2;
4703 //Copy WPA OUI
4704 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4705 pIeBuf += 4;
4706 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4707 pIesLocal->WPA.unicast_cipher_count * 4);
4708 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4709 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4710 pIesLocal->WPA.auth_suite_count * 4);
4711 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4712 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4713 }
4714 }
4715 }
4716#ifdef FEATURE_WLAN_WAPI
4717 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4718 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4719 {
4720 if(pIesLocal->WAPI.present)
4721 {
4722 //Calculate the actual length
4723 nIeLen = 4 //version + akm_suite_count
4724 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4725 + 2 //pwise_cipher_suite_count
4726 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4727 + 6; //gp_cipher_suite + preauth + reserved
4728 if( pIesLocal->WAPI.bkid_count )
4729 {
4730 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4731 }
4732
4733 //nIeLen doesn't count EID and length fields
4734 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4735 {
4736 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4737 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4738 pIeBuf = pSession->pWapiRspIE + 2;
4739 //copy upto akm_suite_count
4740 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 4);
4741 pIeBuf += 4;
4742 if( pIesLocal->WAPI.akm_suite_count )
4743 {
4744 //copy akm_suites
4745 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4746 pIesLocal->WAPI.akm_suite_count * 4);
4747 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4748 }
4749 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4750 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004751 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4752 {
4753 //copy pwise_cipher_suites
4754 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4755 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4756 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4757 }
4758 //gp_cipher_suite + preauth + reserved + bkid_count
4759 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.multicast_cipher_suite, 8);
4760 pIeBuf += 8;
4761 if( pIesLocal->WAPI.bkid_count )
4762 {
4763 //copy akm_suites
4764 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4765 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4766 }
4767 pSession->nWapiRspIeLength = nIeLen + 2;
4768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 }
4770 }
4771#endif /* FEATURE_WLAN_WAPI */
4772 if( !pIes )
4773 {
4774 //locally allocated
4775 palFreeMemory(pMac->hHdd, pIesLocal);
4776 }
4777 }
4778 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004779 return (status);
4780}
4781
Jeff Johnson295189b2012-06-20 16:38:30 -07004782static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4783{
4784 v_U8_t bACWeights[WLANTL_MAX_AC];
4785 v_U8_t paramBk, paramBe, paramVi, paramVo;
4786 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004787 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4788 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4789 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4790 //This doesn't address the case where the lower AC needs a real higher weight
4791 if( pIEs->WMMParams.present )
4792 {
4793 //no change to the lowest ones
4794 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4795 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4796 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4797 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4798 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4799 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4800 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4801 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4802 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4803 {
4804 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4805 fWeightChange = VOS_TRUE;
4806 }
4807 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4808 {
4809 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4810 fWeightChange = VOS_TRUE;
4811 }
4812 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4813 {
4814 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4815 fWeightChange = VOS_TRUE;
4816 }
4817 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4818 {
4819 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4820 fWeightChange = VOS_TRUE;
4821 }
4822 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4823 {
4824 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4825 fWeightChange = VOS_TRUE;
4826 }
4827 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4828 {
4829 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4830 fWeightChange = VOS_TRUE;
4831 }
4832 if(fWeightChange)
4833 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004834 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07004835 bACWeights[2], bACWeights[3]);
4836 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4837 }
4838 }
4839}
Jeff Johnson295189b2012-06-20 16:38:30 -07004840#ifdef WLAN_FEATURE_VOWIFI_11R
4841//Returns whether the current association is a 11r assoc or not
4842tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4843{
4844#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4845 return csrNeighborRoamIs11rAssoc(pMac);
4846#else
4847 return eANI_BOOLEAN_FALSE;
4848#endif
4849}
4850#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004851#ifdef FEATURE_WLAN_CCX
4852//Returns whether the current association is a CCX assoc or not
4853tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4854{
4855#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4856 return csrNeighborRoamIsCCXAssoc(pMac);
4857#else
4858 return eANI_BOOLEAN_FALSE;
4859#endif
4860}
4861#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004862#ifdef FEATURE_WLAN_LFR
4863//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304864tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004865{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304866 tCsrRoamSession *pSession = NULL;
4867
4868 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4869 {
4870 pSession = CSR_GET_SESSION( pMac, sessionId );
4871 if (NULL != pSession->pCurRoamProfile)
4872 {
4873 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4874 {
4875 return eANI_BOOLEAN_FALSE;
4876 }
4877 }
4878 }
4879
Madan Mohan Koyyalamudi9ce36ec2012-10-15 16:03:17 -07004880 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07004881 (!csrIsConcurrentSessionRunning(pMac)));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004882}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004883#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4884//Returns whether "FW based BG scan" is currently enabled...or not
4885tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
4886{
4887 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
4888}
4889#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004890#endif
4891
Jeff Johnson295189b2012-06-20 16:38:30 -07004892//Return true means the command can be release, else not
4893static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4894 eCsrRoamCompleteResult Result, void *Context )
4895{
4896 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4897 tSirBssDescription *pSirBssDesc = NULL;
4898 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4899 tCsrScanResult *pScanResult = NULL;
4900 tCsrRoamInfo roamInfo;
4901 sme_QosAssocInfo assocInfo;
4902 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
4903 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
4904 tDot11fBeaconIEs *pIes = NULL;
4905 tANI_U32 sessionId = pCommand->sessionId;
4906 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4907 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4908 eRoamCmdStatus roamStatus;
4909 eCsrRoamResult roamResult;
4910 eHalStatus status;
4911 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004912 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004913
Jeff Johnson32d95a32012-09-10 13:15:23 -07004914 if(!pSession)
4915 {
4916 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4917 return eANI_BOOLEAN_FALSE;
4918 }
4919
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004920 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07004921 switch( Result )
4922 {
4923 case eCsrJoinSuccess:
4924 // reset the IDLE timer
4925 // !!
4926 // !! fall through to the next CASE statement here is intentional !!
4927 // !!
4928 case eCsrReassocSuccess:
4929 if(eCsrReassocSuccess == Result)
4930 {
4931 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
4932 }
4933 else
4934 {
4935 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
4936 }
4937 // Success Join Response from LIM. Tell NDIS we are connected and save the
4938 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004939 smsLog(pMac, LOGW, FL("receives association indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4941 //always free the memory here
4942 if(pSession->pWpaRsnRspIE)
4943 {
4944 pSession->nWpaRsnRspIeLength = 0;
4945 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
4946 pSession->pWpaRsnRspIE = NULL;
4947 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004948#ifdef FEATURE_WLAN_WAPI
4949 if(pSession->pWapiRspIE)
4950 {
4951 pSession->nWapiRspIeLength = 0;
4952 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
4953 pSession->pWapiRspIE = NULL;
4954 }
4955#endif /* FEATURE_WLAN_WAPI */
4956#ifdef FEATURE_WLAN_BTAMP_UT_RF
4957 //Reset counter so no join retry is needed.
4958 pSession->maxRetryCount = 0;
4959 csrRoamStopJoinRetryTimer(pMac, sessionId);
4960#endif
4961 /* This creates problem since we have not saved the connected profile.
4962 So moving this after saving the profile
4963 */
4964 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
4965 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4966 {
4967 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
4968 }
4969 else
4970 {
4971 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
4972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 //Use the last connected bssdesc for reassoc-ing to the same AP.
4974 //NOTE: What to do when reassoc to a different AP???
4975 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
4976 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
4977 {
4978 pSirBssDesc = pSession->pConnectBssDesc;
4979 if(pSirBssDesc)
4980 {
4981 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4982 }
4983 }
4984 else
4985 {
4986
4987 if(pCommand->u.roamCmd.pRoamBssEntry)
4988 {
4989 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4990 if(pScanResult != NULL)
4991 {
4992 pSirBssDesc = &pScanResult->Result.BssDescriptor;
4993 //this can be NULL
4994 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
4995 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4996 }
4997 }
4998 }
4999 if( pSirBssDesc )
5000 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005001 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005002 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5003 //Save WPA/RSN IE
5004 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5005#ifdef FEATURE_WLAN_CCX
5006 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5007#endif
5008
5009 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5010 // substate change.
5011 // Moving even save profile above so that below mentioned conditon is also met.
5012 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5013 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5015 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5016 // will be dropped for the security context may not be set properly.
5017 //
5018 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5019 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5020 //
5021 // this reordering was done on titan_prod_usb branch and is being replicated here.
5022 //
5023
5024 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5025 !pProfile->bWPSAssociation)
5026 {
5027 // Issue the set Context request to LIM to establish the Unicast STA context
5028 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5029 pProfile->negotiatedUCEncryptionType,
5030 pSirBssDesc, &(pSirBssDesc->bssId),
5031 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5032 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005033 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5035 }
5036 // Issue the set Context request to LIM to establish the Broadcast STA context
5037 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5038 pSirBssDesc, &BroadcastMac,
5039 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5040 }
5041 else
5042 {
5043 //Need to wait for supplicant authtication
5044 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005045 //Set the subestate to WaitForKey in case authentiation is needed
5046 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5047
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 if(pProfile->bWPSAssociation)
5049 {
5050 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5051 }
5052 else
5053 {
5054 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5055 }
5056
5057 //Save sessionId in case of timeout
5058 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5059 //This time should be long enough for the rest of the process plus setting key
5060 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5061 {
5062 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005063 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005064 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5065 }
5066 }
5067
5068 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5069 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 if(Context)
5071 {
5072 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5073 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005074 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5075 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5076#ifdef WLAN_FEATURE_VOWIFI_11R
5077 len += pJoinRsp->parsedRicRspLen;
5078#endif /* WLAN_FEATURE_VOWIFI_11R */
5079#ifdef FEATURE_WLAN_CCX
5080 len += pJoinRsp->tspecIeLen;
5081#endif
5082 if(len)
5083 {
5084 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
5085 (void **)&pSession->connectedInfo.pbFrames, len)))
5086 {
5087 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
5088 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
5089 {
5090 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5091 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5092 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
5093#ifdef WLAN_FEATURE_VOWIFI_11R
5094 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
5095#endif /* WLAN_FEATURE_VOWIFI_11R */
5096#ifdef FEATURE_WLAN_CCX
5097 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
5098#endif
5099 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5100 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5101 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5102 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5103 }
5104 else
5105 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005106 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005107 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
5109 pSession->connectedInfo.pbFrames = NULL;
5110 }
5111 }
5112 }
5113 if(pCommand->u.roamCmd.fReassoc)
5114 {
5115 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5116 }
5117 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5118 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5119 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5120 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5121 }
5122 else
5123 {
5124 if(pCommand->u.roamCmd.fReassoc)
5125 {
5126 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5127 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5128 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5129 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5130 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5131 }
5132 }
5133#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5134 // Indicate SME-QOS with reassoc success event, only after
5135 // copying the frames
5136 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5137#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005138 roamInfo.pBssDesc = pSirBssDesc;
5139 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5140 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5141#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5142 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5143#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5144 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005145 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5146 //It may be better to let QoS do this????
5147 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5148 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005149 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005150 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5151 pmcStartUapsd( pMac, NULL, NULL );
5152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005153 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5154 if( pSession->bRefAssocStartCnt > 0 )
5155 {
5156 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005157 //Remove this code once SLM_Sessionization is supported
5158 //BMPS_WORKAROUND_NOT_NEEDED
5159 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005160 {
5161 pMac->roam.configParam.doBMPSWorkaround = 1;
5162 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005163 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5164 }
5165
5166 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 // reset the PMKID candidate list
5168 csrResetPMKIDCandidateList( pMac, sessionId );
5169 //Update TL's AC weight base on the current EDCA parameters
5170 //These parameters may change in the course of the connection, that sictuation
5171 //is not taken care here. This change is mainly to address a WIFI WMM test where
5172 //BE has a equal or higher TX priority than VI.
5173 //We only do this for infra link
5174 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5175 {
5176 csrCheckAndUpdateACWeight(pMac, pIes);
5177 }
5178#ifdef FEATURE_WLAN_WAPI
5179 // reset the BKID candidate list
5180 csrResetBKIDCandidateList( pMac, sessionId );
5181#endif /* FEATURE_WLAN_WAPI */
5182 }
5183 else
5184 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005185 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005186 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005187 csrScanCancelIdleScan(pMac);
5188 //Not to signal link up because keys are yet to be set.
5189 //The linkup function will overwrite the sub-state that we need to keep at this point.
5190 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5191 {
5192 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5193 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005194 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5195 //enough to let security and DHCP handshake succeed before entry into BMPS
5196 if (pmcShouldBmpsTimerRun(pMac))
5197 {
5198 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5199 != eHAL_STATUS_SUCCESS)
5200 {
5201 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5202 }
5203 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5204 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 break;
5206
Jeff Johnson295189b2012-06-20 16:38:30 -07005207 case eCsrStartBssSuccess:
5208 // on the StartBss Response, LIM is returning the Bss Description that we
5209 // are beaconing. Add this Bss Description to our scan results and
5210 // chain the Profile to this Bss Description. On a Start BSS, there was no
5211 // detected Bss description (no partner) so we issued the Start Bss to
5212 // start the Ibss without any Bss description. Lim was kind enough to return
5213 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005214 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5218 if( CSR_IS_IBSS( pProfile ) )
5219 {
5220 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5221 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005222 else if (CSR_IS_INFRA_AP(pProfile))
5223 {
5224 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 else
5227 {
5228 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5229 }
5230 if( !CSR_IS_WDS_STA( pProfile ) )
5231 {
5232 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005233 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5235 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005236 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005237 roamInfo.pBssDesc = pSirBssDesc;
5238 //We need to associate_complete it first, becasue Associate_start already indicated.
5239 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5240 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5241 break;
5242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005243 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 {
5245 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes );
5246 }
5247 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5248 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5249 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5250 if(pSirBssDesc)
5251 {
5252 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5253 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5254 }
5255 //We are doen with the IEs so free it
5256 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005257#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5258 {
5259 vos_log_ibss_pkt_type *pIbssLog;
5260 tANI_U32 bi;
5261
5262 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5263 if(pIbssLog)
5264 {
5265 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5266 {
5267 //We start the IBSS (didn't find any matched IBSS out there)
5268 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5269 }
5270 else
5271 {
5272 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5273 }
5274 if(pSirBssDesc)
5275 {
5276 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
5277 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5278 }
5279 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5280 {
5281 //***U8 is not enough for beacon interval
5282 pIbssLog->beaconInterval = (v_U8_t)bi;
5283 }
5284 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5285 }
5286 }
5287#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5288 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5289 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5291 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005292 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5293 csrRoamIssueSetContextReq( pMac, sessionId,
5294 pProfile->negotiatedMCEncryptionType,
5295 pSirBssDesc, &BroadcastMac,
5296 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5297 }
5298 }
5299 else
5300 {
5301 //Keep the state to eCSR_ROAMING_STATE_JOINING
5302 //Need to send join_req.
5303 if(pCommand->u.roamCmd.pRoamBssEntry)
5304 {
5305 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5306 {
5307 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5308 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5309 // Set the roaming substate to 'join attempt'...
5310 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005311 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005312 }
5313 }
5314 else
5315 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005316 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005317 VOS_ASSERT( 0 );
5318 }
5319 }
5320 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5321 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5322 //trigger the connection start indication in Vista
5323 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5324 {
5325 roamStatus = eCSR_ROAM_IBSS_IND;
5326 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5327 if( CSR_IS_WDS( pProfile ) )
5328 {
5329 roamStatus = eCSR_ROAM_WDS_IND;
5330 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005332 if( CSR_IS_INFRA_AP( pProfile ) )
5333 {
5334 roamStatus = eCSR_ROAM_INFRA_IND;
5335 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5336 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005337
5338 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5339 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5340 //trigger the connection start indication in Vista
5341 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5342 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5343 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5344 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5345 {
5346 //We start the IBSS (didn't find any matched IBSS out there)
5347 roamInfo.pBssDesc = pSirBssDesc;
5348 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005350 //Remove this code once SLM_Sessionization is supported
5351 //BMPS_WORKAROUND_NOT_NEEDED
5352 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005353 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005354 {
5355 pMac->roam.configParam.doBMPSWorkaround = 1;
5356 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005357
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5359 }
5360
5361 csrScanCancelIdleScan(pMac);
5362 //Only use this timer for ibss. BAP has its own timer for WDS
5363 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
5364 {
5365 //start the join IBSS timer
5366 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
5367 pSession->ibss_join_pending = TRUE;
5368 }
5369 if( HAL_STATUS_SUCCESS( status ) )
5370 {
5371 //Already sent join_req for the WDS station
5372 fReleaseCommand = eANI_BOOLEAN_FALSE;
5373 }
5374 else if( CSR_IS_WDS_STA( pProfile ) )
5375 {
5376 //need to send stop BSS because we fail to send join_req
5377 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5378 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5379 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5380 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005382 case eCsrStartBssFailure:
5383#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5384 {
5385 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005386 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5387 if(pIbssLog)
5388 {
5389 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5390 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5391 }
5392 }
5393#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005394 roamStatus = eCSR_ROAM_IBSS_IND;
5395 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5396 if( CSR_IS_WDS( pProfile ) )
5397 {
5398 roamStatus = eCSR_ROAM_WDS_IND;
5399 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005401 if( CSR_IS_INFRA_AP( pProfile ) )
5402 {
5403 roamStatus = eCSR_ROAM_INFRA_IND;
5404 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 if(Context)
5407 {
5408 pSirBssDesc = (tSirBssDescription *)Context;
5409 }
5410 else
5411 {
5412 pSirBssDesc = NULL;
5413 }
5414 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5415 roamInfo.pBssDesc = pSirBssDesc;
5416 //We need to associate_complete it first, becasue Associate_start already indicated.
5417 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5418 csrSetDefaultDot11Mode( pMac );
5419 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 case eCsrSilentlyStopRoaming:
5421 // We are here because we try to start the same IBSS
5422 //No message to PE
5423 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005424 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5426 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5427 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5428 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5429 if( roamInfo.pBssDesc )
5430 {
5431 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5432 }
5433 //Since there is no change in the current state, simply pass back no result otherwise
5434 //HDD may be mistakenly mark to disconnected state.
5435 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5436 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005437 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 case eCsrSilentlyStopRoamingSaveState:
5439 //We are here because we try to connect to the same AP
5440 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005441 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005442 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5443
5444 //to aviod resetting the substate to NONE
5445 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5446 //No need to change substate to wai_for_key because there is no state change
5447 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5448 if( roamInfo.pBssDesc )
5449 {
5450 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005452 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5453 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5454 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5455 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5456 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5457 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5458 roamInfo.staId = pSession->connectedInfo.staId;
5459 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 pSession->bRefAssocStartCnt--;
5462 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5463 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5464 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5465 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005466 case eCsrReassocFailure:
5467#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5468 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5469#endif
5470 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005471 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005472 csrFreeConnectBssDesc(pMac, sessionId);
5473 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5474 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5475 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5476 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5477 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5478 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5479 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5480 eCSR_ROAM_WDS_IND,
5481 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5482 //Need to issue stop_bss
5483 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005484 case eCsrJoinFailure:
5485 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005486 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 default:
5488 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005489 smsLog(pMac, LOGW, FL("receives no association indication"));
5490 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005491 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5493 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5494 {
5495 //do not free for the other profiles as we need to send down stop BSS later
5496 csrFreeConnectBssDesc(pMac, sessionId);
5497 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5498 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5499 csrSetDefaultDot11Mode( pMac );
5500 }
5501
5502 switch( pCommand->u.roamCmd.roamReason )
5503 {
5504 // If this transition is because of an 802.11 OID, then we transition
5505 // back to INIT state so we sit waiting for more OIDs to be issued and
5506 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005507 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005508 case eCsrSmeIssuedAssocToSimilarAP:
5509 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005510 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5512 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5513 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5514 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5515 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005516 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tCsrBssid));
5517
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 /* Defeaturize this later if needed */
5519#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5520 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5521 if (csrRoamIsHandoffInProgress(pMac))
5522 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 /* Should indicate neighbor roam algorithm about the connect failure here */
5524 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005526#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005527 if(pSession->bRefAssocStartCnt > 0)
5528 {
5529 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005530 if(eCsrJoinFailureDueToConcurrency == Result)
5531 {
5532 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5533 eCSR_ROAM_ASSOCIATION_COMPLETION,
5534 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5535 }
5536 else
5537 {
5538 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 eCSR_ROAM_ASSOCIATION_COMPLETION,
5540 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005543 else
5544 {
5545 /* bRefAssocStartCnt is not incremented when
5546 * eRoamState == eCsrStopRoamingDueToConcurrency
5547 * in csrRoamJoinNextBss API. so handle this in
5548 * else case by sending assoc failure
5549 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005550 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005551 pCommand->u.scanCmd.roamId,
5552 eCSR_ROAM_ASSOCIATION_FAILURE,
5553 eCSR_ROAM_RESULT_FAILURE);
5554 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005555 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005556#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5557 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5558#endif
5559 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5560 csrScanStartIdleScan(pMac);
5561#ifdef FEATURE_WLAN_BTAMP_UT_RF
5562 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5563 //BT activity and not able to recevie WLAN traffic. Retry the join
5564 if( CSR_IS_WDS_STA(pProfile) )
5565 {
5566 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5567 }
5568#endif
5569 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 case eCsrHddIssuedReassocToSameAP:
5571 case eCsrSmeIssuedReassocToSameAP:
5572 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5573
5574 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5575#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5576 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5577#endif
5578 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5579 csrScanStartIdleScan(pMac);
5580 break;
5581 case eCsrForcedDisassoc:
5582 case eCsrForcedDeauth:
5583 case eCsrSmeIssuedIbssJoinFailure:
5584 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5585
5586 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5587 {
5588 // Notify HDD that IBSS join failed
5589 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5590 }
5591 else
5592 {
5593 csrRoamCallCallback(pMac, sessionId, NULL,
5594 pCommand->u.roamCmd.roamId,
5595 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5596 }
5597#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5598 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5599#endif
5600 csrRoamLinkDown(pMac, sessionId);
5601 csrScanStartIdleScan(pMac);
5602 break;
5603 case eCsrForcedIbssLeave:
5604 csrRoamCallCallback(pMac, sessionId, NULL,
5605 pCommand->u.roamCmd.roamId,
5606 eCSR_ROAM_IBSS_LEAVE,
5607 eCSR_ROAM_RESULT_IBSS_STOP);
5608 break;
5609 case eCsrForcedDisassocMICFailure:
5610 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5611
5612 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5613#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5614 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5615#endif
5616 csrScanStartIdleScan(pMac);
5617 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005618 case eCsrStopBss:
5619 csrRoamCallCallback(pMac, sessionId, NULL,
5620 pCommand->u.roamCmd.roamId,
5621 eCSR_ROAM_INFRA_IND,
5622 eCSR_ROAM_RESULT_INFRA_STOPPED);
5623 break;
5624 case eCsrForcedDisassocSta:
5625 case eCsrForcedDeauthSta:
5626 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5627 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5628 {
5629 pSession = CSR_GET_SESSION(pMac, sessionId);
5630 if (!pSession)
5631 break;
5632
5633 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5634 {
5635 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5636 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5637 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5638 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5639 roamInfo.statusCode = eSIR_SME_SUCCESS;
5640 status = csrRoamCallCallback(pMac, sessionId,
5641 &roamInfo, pCommand->u.roamCmd.roamId,
5642 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5643 }
5644 }
5645 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 case eCsrLostLink1:
5647 // if lost link roam1 failed, then issue lost link Scan2 ...
5648 csrScanRequestLostLink2(pMac, sessionId);
5649 break;
5650 case eCsrLostLink2:
5651 // if lost link roam2 failed, then issue lost link scan3 ...
5652 csrScanRequestLostLink3(pMac, sessionId);
5653 break;
5654 case eCsrLostLink3:
5655 default:
5656 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5657
5658 //We are done with one round of lostlink roaming here
5659 csrScanHandleFailedLostlink3(pMac, sessionId);
5660 break;
5661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 break;
5663 }
5664 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005665 return ( fReleaseCommand );
5666}
5667
Jeff Johnson295189b2012-06-20 16:38:30 -07005668eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5669{
5670 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005671 return (status);
5672}
5673
Jeff Johnson295189b2012-06-20 16:38:30 -07005674eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5675{
5676 eHalStatus status = eHAL_STATUS_SUCCESS;
5677 tANI_U32 size = 0;
5678
5679 do
5680 {
5681 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5682 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5683 {
5684 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5685 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5686 if(!HAL_STATUS_SUCCESS(status))
5687 {
5688 break;
5689 }
5690 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5691 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5692 }
5693 if(pSrcProfile->SSIDs.numOfSSIDs)
5694 {
5695 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5696 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5697 if(!HAL_STATUS_SUCCESS(status))
5698 {
5699 break;
5700 }
5701 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5702 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5703 }
5704 if(pSrcProfile->nWPAReqIELength)
5705 {
5706 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5707 if(!HAL_STATUS_SUCCESS(status))
5708 {
5709 break;
5710 }
5711 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5712 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5713 }
5714 if(pSrcProfile->nRSNReqIELength)
5715 {
5716 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5717 if(!HAL_STATUS_SUCCESS(status))
5718 {
5719 break;
5720 }
5721 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5722 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5723 }
5724#ifdef FEATURE_WLAN_WAPI
5725 if(pSrcProfile->nWAPIReqIELength)
5726 {
5727 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5728 if(!HAL_STATUS_SUCCESS(status))
5729 {
5730 break;
5731 }
5732 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5733 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5734 }
5735#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005736 if(pSrcProfile->nAddIEScanLength)
5737 {
5738 status = palAllocateMemory(pMac->hHdd,
5739 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5740 if(!HAL_STATUS_SUCCESS(status))
5741 {
5742 break;
5743 }
5744 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5745 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5746 pSrcProfile->nAddIEScanLength);
5747 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 if(pSrcProfile->nAddIEAssocLength)
5749 {
5750 status = palAllocateMemory(pMac->hHdd,
5751 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5752 if(!HAL_STATUS_SUCCESS(status))
5753 {
5754 break;
5755 }
5756 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5757 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5758 pSrcProfile->nAddIEAssocLength);
5759 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005760 if(pSrcProfile->ChannelInfo.ChannelList)
5761 {
5762 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5763 if(!HAL_STATUS_SUCCESS(status))
5764 {
5765 break;
5766 }
5767 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5768 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5769 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 pDstProfile->AuthType = pSrcProfile->AuthType;
5771 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5772 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5773 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5774 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5775 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07005776#ifdef WLAN_FEATURE_11W
5777 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
5778 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
5779 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
5780#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 pDstProfile->BSSType = pSrcProfile->BSSType;
5782 pDstProfile->phyMode = pSrcProfile->phyMode;
5783 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5784
5785#ifdef FEATURE_WLAN_WAPI
5786 if(csrIsProfileWapi(pSrcProfile))
5787 {
5788 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5789 {
5790 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5791 }
5792 }
5793#endif /* FEATURE_WLAN_WAPI */
5794 pDstProfile->CBMode = pSrcProfile->CBMode;
5795 /*Save the WPS info*/
5796 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5797 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005798 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 pDstProfile->privacy = pSrcProfile->privacy;
5800 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5801 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5802 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5803 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5804 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5805 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5806 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5807 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5808 pDstProfile->wps_state = pSrcProfile->wps_state;
5809 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005811#ifdef WLAN_FEATURE_VOWIFI_11R
5812 if (pSrcProfile->MDID.mdiePresent)
5813 {
5814 pDstProfile->MDID.mdiePresent = 1;
5815 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5816 }
5817#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 }while(0);
5819
5820 if(!HAL_STATUS_SUCCESS(status))
5821 {
5822 csrReleaseProfile(pMac, pDstProfile);
5823 pDstProfile = NULL;
5824 }
5825
5826 return (status);
5827}
Jeff Johnson295189b2012-06-20 16:38:30 -07005828eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5829{
5830 eHalStatus status = eHAL_STATUS_SUCCESS;
5831 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5832 do
5833 {
5834 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5835 if(pSrcProfile->bssid)
5836 {
5837 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5838 if(!HAL_STATUS_SUCCESS(status))
5839 {
5840 break;
5841 }
5842 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5843 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5844 }
5845 if(pSrcProfile->SSID.ssId)
5846 {
5847 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5848 if(!HAL_STATUS_SUCCESS(status))
5849 {
5850 break;
5851 }
5852 pDstProfile->SSIDs.numOfSSIDs = 1;
5853 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5854 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5855 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5856 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005857 if(pSrcProfile->nAddIEAssocLength)
5858 {
5859 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5860 if(!HAL_STATUS_SUCCESS(status))
5861 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005862 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005863 break;
5864 }
5865 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5866 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5867 pSrcProfile->nAddIEAssocLength);
5868 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5870 if(!HAL_STATUS_SUCCESS(status))
5871 {
5872 break;
5873 }
5874 pDstProfile->ChannelInfo.numOfChannels = 1;
5875 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 pDstProfile->AuthType.numEntries = 1;
5877 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
5878 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
5879 pDstProfile->EncryptionType.numEntries = 1;
5880 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
5881 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
5882 pDstProfile->mcEncryptionType.numEntries = 1;
5883 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
5884 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
5885 pDstProfile->BSSType = pSrcProfile->BSSType;
5886 pDstProfile->CBMode = pSrcProfile->CBMode;
5887 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5888#ifdef WLAN_FEATURE_VOWIFI_11R
5889 if (pSrcProfile->MDID.mdiePresent)
5890 {
5891 pDstProfile->MDID.mdiePresent = 1;
5892 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5893 }
5894#endif
5895
5896 }while(0);
5897
5898 if(!HAL_STATUS_SUCCESS(status))
5899 {
5900 csrReleaseProfile(pMac, pDstProfile);
5901 pDstProfile = NULL;
5902 }
5903
5904 return (status);
5905}
5906
Jeff Johnson295189b2012-06-20 16:38:30 -07005907eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5908 tScanResultHandle hBSSList,
5909 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
5910 tANI_BOOLEAN fClearScan)
5911{
5912 eHalStatus status = eHAL_STATUS_SUCCESS;
5913 tSmeCmd *pCommand;
5914
5915 pCommand = csrGetCommandBuffer(pMac);
5916 if(NULL == pCommand)
5917 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005918 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 status = eHAL_STATUS_RESOURCES;
5920 }
5921 else
5922 {
5923 if( fClearScan )
5924 {
5925 csrScanCancelIdleScan(pMac);
5926 csrScanAbortMacScanNotForConnect(pMac);
5927 }
5928 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5929 if(NULL == pProfile)
5930 {
5931 //We can roam now
5932 //Since pProfile is NULL, we need to build our own profile, set everything to default
5933 //We can only support open and no encryption
5934 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
5935 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5936 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
5937 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5938 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
5939 }
5940 else
5941 {
5942 //make a copy of the profile
5943 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5944 if(HAL_STATUS_SUCCESS(status))
5945 {
5946 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5947 }
5948 }
5949 pCommand->command = eSmeCommandRoam;
5950 pCommand->sessionId = (tANI_U8)sessionId;
5951 pCommand->u.roamCmd.hBSSList = hBSSList;
5952 pCommand->u.roamCmd.roamId = roamId;
5953 pCommand->u.roamCmd.roamReason = reason;
5954 //We need to free the BssList when the command is done
5955 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
5956 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
5958 FL("CSR PERSONA=%d"),
5959 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5961 if( !HAL_STATUS_SUCCESS( status ) )
5962 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005963 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 csrReleaseCommandRoam( pMac, pCommand );
5965 }
5966 }
5967
5968 return (status);
5969}
Jeff Johnson295189b2012-06-20 16:38:30 -07005970eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5971 tCsrRoamModifyProfileFields *pMmodProfileFields,
5972 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5973{
5974 eHalStatus status = eHAL_STATUS_SUCCESS;
5975 tSmeCmd *pCommand;
5976
5977 pCommand = csrGetCommandBuffer(pMac);
5978 if(NULL == pCommand)
5979 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005980 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 status = eHAL_STATUS_RESOURCES;
5982 }
5983 else
5984 {
5985 csrScanCancelIdleScan(pMac);
5986 csrScanAbortMacScanNotForConnect(pMac);
5987 if(pProfile)
5988 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 //This is likely trying to reassoc to different profile
5990 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5991 //make a copy of the profile
5992 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5993 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 }
5995 else
5996 {
5997 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
5998 //how to update WPA/WPA2 info in roamProfile??
5999 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006001 if(HAL_STATUS_SUCCESS(status))
6002 {
6003 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6004 }
6005 pCommand->command = eSmeCommandRoam;
6006 pCommand->sessionId = (tANI_U8)sessionId;
6007 pCommand->u.roamCmd.roamId = roamId;
6008 pCommand->u.roamCmd.roamReason = reason;
6009 //We need to free the BssList when the command is done
6010 //For reassoc there is no BSS list, so the boolean set to false
6011 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6012 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6013 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6015 if( !HAL_STATUS_SUCCESS( status ) )
6016 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006017 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6019 csrReleaseCommandRoam( pMac, pCommand );
6020 }
6021 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 return (status);
6023}
6024
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006025eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6026 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
6027// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6028{
6029 eHalStatus status = eHAL_STATUS_SUCCESS;
6030 tSmeCmd *pCommand;
6031
6032 pCommand = csrGetCommandBuffer(pMac);
6033 if(NULL == pCommand)
6034 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006035 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006036 status = eHAL_STATUS_RESOURCES;
6037 }
6038 else
6039 {
6040 if(pBssDescription)
6041 {
6042 //copy over the parameters we need later
6043 pCommand->command = eSmeCommandRoam;
6044 pCommand->sessionId = (tANI_U8)sessionId;
6045 pCommand->u.roamCmd.roamReason = reason;
6046 //this is the important parameter
6047 //in this case we are using this field for the "next" BSS
6048 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6049 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6050 if( !HAL_STATUS_SUCCESS( status ) )
6051 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006052 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006053 csrReleaseCommandPreauth( pMac, pCommand );
6054 }
6055 }
6056 else
6057 {
6058 //Return failure
6059 status = eHAL_STATUS_RESOURCES;
6060 }
6061 }
6062 return (status);
6063}
6064
6065eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6066{
6067 tListElem *pEntry;
6068 tSmeCmd *pCommand;
6069 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6070 if ( pEntry )
6071 {
6072 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6073 if ( (eSmeCommandRoam == pCommand->command) &&
6074 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6075 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006076 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006077 pCommand->command, pCommand->u.roamCmd.roamReason);
6078 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6079 csrReleaseCommandPreauth( pMac, pCommand );
6080 }
6081 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006082 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006083 pCommand->command, pCommand->u.roamCmd.roamReason);
6084 }
6085 }
6086 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006087 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006088 }
6089 smeProcessPendingQueue( pMac );
6090 return eHAL_STATUS_SUCCESS;
6091}
6092
Jeff Johnson295189b2012-06-20 16:38:30 -07006093eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6094 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6095{
6096 eHalStatus status = eHAL_STATUS_FAILURE;
6097 tScanResultHandle hBSSList;
6098 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006099 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6100 if(HAL_STATUS_SUCCESS(status))
6101 {
6102 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6103 if(pRoamId)
6104 {
6105 *pRoamId = roamId;
6106 }
6107 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6108 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6109 if(!HAL_STATUS_SUCCESS(status))
6110 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006111 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006112 csrScanResultPurge(pMac, hBSSList);
6113 }
6114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 return (status);
6116}
6117
Jeff Johnson295189b2012-06-20 16:38:30 -07006118eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6119 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6120{
6121 eHalStatus status = eHAL_STATUS_SUCCESS;
6122 tScanResultHandle hBSSList;
6123 tCsrScanResultFilter *pScanFilter;
6124 tANI_U32 roamId = 0;
6125 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6126 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 if (NULL == pProfile)
6128 {
6129 smsLog(pMac, LOGP, FL("No profile specified"));
6130 return eHAL_STATUS_FAILURE;
6131 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006132 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006133 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 if( CSR_IS_WDS( pProfile ) &&
6135 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6136 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006137 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006138 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006139 return status;
6140 }
6141 csrRoamCancelRoaming(pMac, sessionId);
6142 csrScanRemoveFreshScanCommand(pMac, sessionId);
6143 csrScanCancelIdleScan(pMac);
6144 //Only abort the scan if it is not used for other roam/connect purpose
6145 csrScanAbortMacScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6147 {
6148 csrScanDisable(pMac);
6149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6151 //Check whether ssid changes
6152 if(csrIsConnStateConnected(pMac, sessionId))
6153 {
6154 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6155 {
6156 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6157 }
6158 }
6159#ifdef FEATURE_WLAN_BTAMP_UT_RF
6160 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6161#endif
6162 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6163 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006164 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6166 if(pRoamId)
6167 {
6168 roamId = *pRoamId;
6169 }
6170 if(!HAL_STATUS_SUCCESS(status))
6171 {
6172 fCallCallback = eANI_BOOLEAN_TRUE;
6173 }
6174 }
6175 else
6176 {
6177 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6178 if(HAL_STATUS_SUCCESS(status))
6179 {
6180 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6181 //Try to connect to any BSS
6182 if(NULL == pProfile)
6183 {
6184 //No encryption
6185 pScanFilter->EncryptionType.numEntries = 1;
6186 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6187 }//we don't have a profile
6188 else
6189 {
6190 //Here is the profile we need to connect to
6191 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6192 }//We have a profile
6193 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6194 if(pRoamId)
6195 {
6196 *pRoamId = roamId;
6197 }
6198
6199 if(HAL_STATUS_SUCCESS(status))
6200 {
6201 /*Save the WPS info*/
6202 if(NULL != pProfile)
6203 {
6204 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6205 }
6206 else
6207 {
6208 pScanFilter->bWPSAssociation = 0;
6209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 do
6211 {
6212 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006214 )
6215 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006216 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006217 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6218 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6219 if(!HAL_STATUS_SUCCESS(status))
6220 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006221 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006222 fCallCallback = eANI_BOOLEAN_TRUE;
6223 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006224 else
6225 {
6226 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 break;
6229 }
6230 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006231 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006232 if(HAL_STATUS_SUCCESS(status))
6233 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006234 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6235 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6236 if(!HAL_STATUS_SUCCESS(status))
6237 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006238 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006239 csrScanResultPurge(pMac, hBSSList);
6240 fCallCallback = eANI_BOOLEAN_TRUE;
6241 }
6242 }//Have scan result
6243 else if(NULL != pProfile)
6244 {
6245 //Check whether it is for start ibss
6246 if(CSR_IS_START_IBSS(pProfile))
6247 {
6248 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6249 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6250 if(!HAL_STATUS_SUCCESS(status))
6251 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006252 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 fCallCallback = eANI_BOOLEAN_TRUE;
6254 }
6255 }
6256 else
6257 {
6258 //scan for this SSID
6259 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
6260 if(!HAL_STATUS_SUCCESS(status))
6261 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006262 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006263 fCallCallback = eANI_BOOLEAN_TRUE;
6264 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006265 else
6266 {
6267 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006269 }
6270 }
6271 else
6272 {
6273 fCallCallback = eANI_BOOLEAN_TRUE;
6274 }
6275 } while (0);
6276 if(NULL != pProfile)
6277 {
6278 //we need to free memory for filter if profile exists
6279 csrFreeScanFilter(pMac, pScanFilter);
6280 }
6281 }//Got the scan filter from profile
6282
6283 palFreeMemory(pMac->hHdd, pScanFilter);
6284 }//allocated memory for pScanFilter
6285 }//No Bsslist coming in
6286 //tell the caller if we fail to trigger a join request
6287 if( fCallCallback )
6288 {
6289 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6290 }
6291
6292 return (status);
6293}
Jeff Johnson295189b2012-06-20 16:38:30 -07006294eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6295 tCsrRoamModifyProfileFields modProfileFields,
6296 tANI_U32 *pRoamId)
6297{
6298 eHalStatus status = eHAL_STATUS_SUCCESS;
6299 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6300 tANI_U32 roamId = 0;
6301 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 if (NULL == pProfile)
6303 {
6304 smsLog(pMac, LOGP, FL("No profile specified"));
6305 return eHAL_STATUS_FAILURE;
6306 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006307 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"), pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 csrRoamCancelRoaming(pMac, sessionId);
6309 csrScanRemoveFreshScanCommand(pMac, sessionId);
6310 csrScanCancelIdleScan(pMac);
6311 csrScanAbortMacScanNotForConnect(pMac);
6312 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 if(csrIsConnStateConnected(pMac, sessionId))
6314 {
6315 if(pProfile)
6316 {
6317 if(pProfile->SSIDs.numOfSSIDs &&
6318 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6319 {
6320 fCallCallback = eANI_BOOLEAN_FALSE;
6321 }
6322 else
6323 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006324 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006325 }
6326 }
6327 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
6328 &pSession->connectedProfile.modifyProfileFields,
6329 sizeof(tCsrRoamModifyProfileFields)))
6330 {
6331 fCallCallback = eANI_BOOLEAN_FALSE;
6332 }
6333 else
6334 {
6335 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006336 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006337 }
6338 }
6339 else
6340 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006341 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 if(!fCallCallback)
6344 {
6345 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6346 if(pRoamId)
6347 {
6348 *pRoamId = roamId;
6349 }
6350
Jeff Johnson295189b2012-06-20 16:38:30 -07006351 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6352 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006353 }
6354 else
6355 {
6356 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6357 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6358 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006359 return status;
6360}
Jeff Johnson295189b2012-06-20 16:38:30 -07006361eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6362{
6363 eHalStatus status = eHAL_STATUS_FAILURE;
6364 tScanResultHandle hBSSList = NULL;
6365 tCsrScanResultFilter *pScanFilter = NULL;
6366 tANI_U32 roamId;
6367 tCsrRoamProfile *pProfile = NULL;
6368 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006369
6370 if(!pSession)
6371 {
6372 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6373 return eHAL_STATUS_FAILURE;
6374 }
6375
Jeff Johnson295189b2012-06-20 16:38:30 -07006376 do
6377 {
6378 if(pSession->pCurRoamProfile)
6379 {
6380 csrScanCancelIdleScan(pMac);
6381 csrScanAbortMacScanNotForConnect(pMac);
6382 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6383 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6384 if(!HAL_STATUS_SUCCESS(status))
6385 break;
6386 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6387 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6388 if(!HAL_STATUS_SUCCESS(status))
6389 break;
6390 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6391 if(!HAL_STATUS_SUCCESS(status))
6392 {
6393 break;
6394 }
6395 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6396 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6397 if(!HAL_STATUS_SUCCESS(status))
6398 {
6399 break;
6400 }
6401 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6402 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6403 if(HAL_STATUS_SUCCESS(status))
6404 {
6405 //we want to put the last connected BSS to the very beginning, if possible
6406 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6407 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6408 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6409 if(!HAL_STATUS_SUCCESS(status))
6410 {
6411 csrScanResultPurge(pMac, hBSSList);
6412 break;
6413 }
6414 }
6415 else
6416 {
6417 //Do a scan on this profile
6418 //scan for this SSID only in case the AP suppresses SSID
6419 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
6420 if(!HAL_STATUS_SUCCESS(status))
6421 {
6422 break;
6423 }
6424 }
6425 }//We have a profile
6426 else
6427 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006428 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006429 break;
6430 }
6431 }while(0);
6432 if(pScanFilter)
6433 {
6434 csrFreeScanFilter(pMac, pScanFilter);
6435 palFreeMemory(pMac->hHdd, pScanFilter);
6436 }
6437 if(NULL != pProfile)
6438 {
6439 csrReleaseProfile(pMac, pProfile);
6440 palFreeMemory(pMac->hHdd, pProfile);
6441 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006442 return (status);
6443}
Jeff Johnson295189b2012-06-20 16:38:30 -07006444eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6445{
6446 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006447 if(csrIsConnStateConnected(pMac, sessionId))
6448 {
6449 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6450 if(HAL_STATUS_SUCCESS(status))
6451 {
6452 status = csrRoamJoinLastProfile(pMac, sessionId);
6453 }
6454 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006455 return (status);
6456}
6457
Jeff Johnson295189b2012-06-20 16:38:30 -07006458eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6459{
6460 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006461 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006462 csrRoamCancelRoaming(pMac, sessionId);
6463 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6464 if(csrIsConnStateDisconnected(pMac, sessionId))
6465 {
6466 status = csrRoamJoinLastProfile(pMac, sessionId);
6467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006468 return (status);
6469}
6470
Jeff Johnson295189b2012-06-20 16:38:30 -07006471eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6472{
6473 eHalStatus status = eHAL_STATUS_SUCCESS;
6474 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6475 eCsrRoamSubState NewSubstate;
6476 tANI_U32 sessionId = pCommand->sessionId;
6477
6478 // change state to 'Roaming'...
6479 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6480
6481 if ( csrIsConnStateIbss( pMac, sessionId ) )
6482 {
6483 // If we are in an IBSS, then stop the IBSS...
6484 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6485 fComplete = (!HAL_STATUS_SUCCESS(status));
6486 }
6487 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6488 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006489 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 -07006490 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6491 //Restore AC weight in case we change it
6492 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6493 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6494 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6495 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6496 {
6497 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6498 }
6499 if( fDisassoc )
6500 {
6501 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6502 }
6503 else
6504 {
6505 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6506 }
6507 fComplete = (!HAL_STATUS_SUCCESS(status));
6508 }
6509 else if ( csrIsConnStateWds( pMac, sessionId ) )
6510 {
6511 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6512 {
6513 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6514 fComplete = (!HAL_STATUS_SUCCESS(status));
6515 }
6516 //This has to be WDS station
6517 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6518 {
6519
6520 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6521 if( fDisassoc )
6522 {
6523 status = csrRoamIssueDisassociate( pMac, sessionId,
6524 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6525 fComplete = (!HAL_STATUS_SUCCESS(status));
6526 }
6527 }
6528 } else {
6529 // we got a dis-assoc request while not connected to any peer
6530 // just complete the command
6531 fComplete = eANI_BOOLEAN_TRUE;
6532 status = eHAL_STATUS_FAILURE;
6533 }
6534 if(fComplete)
6535 {
6536 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6537 }
6538
6539 if(HAL_STATUS_SUCCESS(status))
6540 {
6541 if ( csrIsConnStateInfra( pMac, sessionId ) )
6542 {
6543 //Set the state to disconnect here
6544 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6545 }
6546 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006547 else
6548 {
6549 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006551 return (status);
6552}
6553
Jeff Johnson295189b2012-06-20 16:38:30 -07006554/* This is been removed from latest code base */
6555/*
6556static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6557{
6558 eHalStatus status;
6559 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6561 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006562 return ( status );
6563}
6564*/
6565
Jeff Johnson295189b2012-06-20 16:38:30 -07006566eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6567{
6568 eHalStatus status = eHAL_STATUS_SUCCESS;
6569 tSmeCmd *pCommand;
6570 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006571 do
6572 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006573 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006574 pCommand = csrGetCommandBuffer( pMac );
6575 if ( !pCommand )
6576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006577 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006578 status = eHAL_STATUS_RESOURCES;
6579 break;
6580 }
6581 //Change the substate in case it is wait-for-key
6582 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6583 {
6584 csrRoamStopWaitForKeyTimer( pMac );
6585 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6586 }
6587 pCommand->command = eSmeCommandRoam;
6588 pCommand->sessionId = (tANI_U8)sessionId;
6589 switch ( reason )
6590 {
6591 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6592 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6593 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006594 case eCSR_DISCONNECT_REASON_DEAUTH:
6595 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6596 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 case eCSR_DISCONNECT_REASON_HANDOFF:
6598 fHighPriority = eANI_BOOLEAN_TRUE;
6599 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6600 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006601 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6602 case eCSR_DISCONNECT_REASON_DISASSOC:
6603 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6604 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6606 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6607 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6609 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6610 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 default:
6612 break;
6613 }
6614 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6615 if( !HAL_STATUS_SUCCESS( status ) )
6616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006617 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 csrReleaseCommandRoam( pMac, pCommand );
6619 }
6620 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006621 return( status );
6622}
6623
Jeff Johnson295189b2012-06-20 16:38:30 -07006624eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6625{
6626 eHalStatus status = eHAL_STATUS_SUCCESS;
6627 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006628 pCommand = csrGetCommandBuffer( pMac );
6629 if ( NULL != pCommand )
6630 {
6631 //Change the substate in case it is wait-for-key
6632 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6633 {
6634 csrRoamStopWaitForKeyTimer( pMac );
6635 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6636 }
6637 pCommand->command = eSmeCommandRoam;
6638 pCommand->sessionId = (tANI_U8)sessionId;
6639 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6640 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6641 if( !HAL_STATUS_SUCCESS( status ) )
6642 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006643 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006644 csrReleaseCommandRoam( pMac, pCommand );
6645 }
6646 }
6647 else
6648 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006649 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006650 status = eHAL_STATUS_RESOURCES;
6651 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 return ( status );
6653}
6654
Jeff Johnson295189b2012-06-20 16:38:30 -07006655eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6656{
6657 eHalStatus status = eHAL_STATUS_SUCCESS;
6658 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006659
6660 if(!pSession)
6661 {
6662 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6663 return eHAL_STATUS_FAILURE;
6664 }
6665
Jeff Johnson295189b2012-06-20 16:38:30 -07006666#ifdef FEATURE_WLAN_BTAMP_UT_RF
6667 //Stop te retry
6668 pSession->maxRetryCount = 0;
6669 csrRoamStopJoinRetryTimer(pMac, sessionId);
6670#endif
6671 //Not to call cancel roaming here
6672 //Only issue disconnect when necessary
6673 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6674 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6675 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6676
6677 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006678 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6680 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 return (status);
6682}
6683
Jeff Johnson295189b2012-06-20 16:38:30 -07006684eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6685{
6686 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006687
6688 if(!pSession)
6689 {
6690 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6691 return eHAL_STATUS_FAILURE;
6692 }
6693
Jeff Johnson295189b2012-06-20 16:38:30 -07006694 csrRoamCancelRoaming(pMac, sessionId);
6695 pSession->ibss_join_pending = FALSE;
6696 csrRoamStopIbssJoinTimer(pMac, sessionId);
6697 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6698
6699 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6700}
6701
Jeff Johnson295189b2012-06-20 16:38:30 -07006702eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6703 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6704{
6705 eHalStatus status = eHAL_STATUS_SUCCESS;
6706 tDot11fBeaconIEs *pIesTemp = pIes;
6707 tANI_U8 index;
6708 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6709 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006710
6711 if(!pSession)
6712 {
6713 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6714 return eHAL_STATUS_FAILURE;
6715 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006716
6717 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6718 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6719 pConnectProfile->AuthInfo = pProfile->AuthType;
6720 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6721 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6722 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6723 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6724 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6725 pConnectProfile->BSSType = pProfile->BSSType;
6726 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6727 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006728 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6729
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006731 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6732 if(pProfile->nAddIEAssocLength)
6733 {
6734 status = palAllocateMemory(pMac->hHdd,
6735 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6736 if(!HAL_STATUS_SUCCESS(status))
6737 {
6738 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6739 return eHAL_STATUS_FAILURE;
6740 }
6741 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6742 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6743 pProfile->nAddIEAssocLength);
6744 }
6745
Jeff Johnson295189b2012-06-20 16:38:30 -07006746 //Save bssid
6747 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6748#ifdef WLAN_FEATURE_VOWIFI_11R
6749 if (pSirBssDesc->mdiePresent)
6750 {
6751 pConnectProfile->MDID.mdiePresent = 1;
6752 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6753 }
6754#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07006755 if( NULL == pIesTemp )
6756 {
6757 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6758 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006759#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006760 if ((csrIsProfileCCX(pProfile) ||
6761 ((pIesTemp->CCXVersion.present)
6762 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6763 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6764 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6765 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07006766#ifdef WLAN_FEATURE_11W
6767 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
6768#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05306769 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006770 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006771 {
6772 pConnectProfile->isCCXAssoc = 1;
6773 }
6774#endif
6775 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 if(HAL_STATUS_SUCCESS(status))
6777 {
6778 if(pIesTemp->SSID.present)
6779 {
6780 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6781 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6782 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6783 }
6784
6785 //Save the bss desc
6786 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306787
6788 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006789 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306790 //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 -07006791 pConnectProfile->qap = TRUE;
6792 }
6793 else
6794 {
6795 pConnectProfile->qap = FALSE;
6796 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006797 if ( NULL == pIes )
6798 {
6799 //Free memory if it allocated locally
6800 palFreeMemory(pMac->hHdd, pIesTemp);
6801 }
6802 }
6803 //Save Qos connection
6804 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6805
6806 if(!HAL_STATUS_SUCCESS(status))
6807 {
6808 csrFreeConnectBssDesc(pMac, sessionId);
6809 }
6810 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6811 {
6812 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6813 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6814 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6815 {
6816 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6817 break;
6818 }
6819 pConnectProfile->handoffPermitted = FALSE;
6820 }
6821
6822 return (status);
6823}
6824
Jeff Johnson295189b2012-06-20 16:38:30 -07006825static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6826{
6827 tListElem *pEntry = NULL;
6828 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006829 //The head of the active list is the request we sent
6830 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6831 if(pEntry)
6832 {
6833 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006835 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6836 {
6837 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6838 {
6839#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6840 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6841#endif
6842 }
6843 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6844 }
6845 else
6846 {
6847 tANI_U32 roamId = 0;
6848 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006849 if(!pSession)
6850 {
6851 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6852 return;
6853 }
6854
Jeff Johnson295189b2012-06-20 16:38:30 -07006855
6856 //The head of the active list is the request we sent
6857 //Try to get back the same profile and roam again
6858 if(pCommand)
6859 {
6860 roamId = pCommand->u.roamCmd.roamId;
6861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006862 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6863 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006864 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07006865#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6866 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6867 if (csrRoamIsHandoffInProgress(pMac))
6868 {
6869 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6870 /* Should indicate neighbor roam algorithm about the connect failure here */
6871 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
6872 }
6873#endif
6874 if (pCommand)
6875 {
6876 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
6877 {
6878 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6879 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
6880 csrRoamReissueRoamCommand(pMac);
6881 }
6882 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
6883 {
6884 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6885 }
6886 else
6887 {
6888 csrRoam(pMac, pCommand);
6889 }
6890 }
6891 else
6892 {
6893 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6894 }
6895 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
6896}
6897
Jeff Johnson295189b2012-06-20 16:38:30 -07006898eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6899 tDot11fBeaconIEs *pIes,
6900 tCsrRoamProfile *pProfile, tANI_U32 roamId )
6901{
6902 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006903 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006904 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
6905 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
6906
6907 // Set the roaming substate to 'join attempt'...
6908 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006909 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006910 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006911 return (status);
6912}
6913
Jeff Johnson295189b2012-06-20 16:38:30 -07006914static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6915 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
6916{
6917 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006918 // Set the roaming substate to 'join attempt'...
6919 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
6920
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006921 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006922
6923 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006924 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07006925}
6926
Jeff Johnson295189b2012-06-20 16:38:30 -07006927void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
6928{
6929 tListElem *pEntry;
6930 tSmeCmd *pCommand;
6931 tCsrRoamInfo roamInfo;
6932 tANI_U32 sessionId;
6933 tCsrRoamSession *pSession;
6934
6935 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6936 if(pEntry)
6937 {
6938 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6939 if ( eSmeCommandRoam == pCommand->command )
6940 {
6941 sessionId = pCommand->sessionId;
6942 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006943
6944 if(!pSession)
6945 {
6946 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6947 return;
6948 }
6949
Jeff Johnson295189b2012-06-20 16:38:30 -07006950 if( pCommand->u.roamCmd.fStopWds )
6951 {
6952 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
6953 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6954 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6955 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07006956 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07006957 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6958 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6959 eCSR_ROAM_WDS_IND,
6960 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07006961 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
6962 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6963 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6964 eCSR_ROAM_INFRA_IND,
6965 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
6966 }
6967
Jeff Johnson295189b2012-06-20 16:38:30 -07006968
Jeff Johnson295189b2012-06-20 16:38:30 -07006969 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
6970 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006971 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07006972 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6973 }
6974 }
6975 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
6976 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006977 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07006978 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6979 }
6980 }
6981 else
6982 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006983 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07006984 }
6985 }
6986 else
6987 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006988 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07006989 }
6990}
6991
Jeff Johnson295189b2012-06-20 16:38:30 -07006992tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
6993{
6994 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6995 tListElem *pEntry;
6996 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006997 //alwasy lock active list before locking pending list
6998 csrLLLock( &pMac->sme.smeCmdActiveList );
6999 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7000 if(pEntry)
7001 {
7002 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7003 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7004 {
7005 fRet = eANI_BOOLEAN_TRUE;
7006 }
7007 }
7008 if(eANI_BOOLEAN_FALSE == fRet)
7009 {
7010 csrLLLock(&pMac->sme.smeCmdPendingList);
7011 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7012 while(pEntry)
7013 {
7014 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7015 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7016 {
7017 fRet = eANI_BOOLEAN_TRUE;
7018 break;
7019 }
7020 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7021 }
7022 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7023 }
7024 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007025 return (fRet);
7026}
7027
Jeff Johnson295189b2012-06-20 16:38:30 -07007028tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7029{
7030 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7031 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007032 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7033 {
7034 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7035 {
7036 break;
7037 }
7038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007039 return ( fRet );
7040}
7041
Jeff Johnson295189b2012-06-20 16:38:30 -07007042tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7043{
7044 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007045 //alwasy lock active list before locking pending list
7046 csrLLLock( &pMac->sme.smeCmdActiveList );
7047 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7048 if(eANI_BOOLEAN_FALSE == fRet)
7049 {
7050 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7051 }
7052 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007053 return (fRet);
7054}
7055
Jeff Johnson295189b2012-06-20 16:38:30 -07007056tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7057{
7058 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7059 tListElem *pEntry;
7060 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007061 //alwasy lock active list before locking pending list
7062 csrLLLock( &pMac->sme.smeCmdActiveList );
7063 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7064 if( pEntry )
7065 {
7066 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7067 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7068 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7069 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7070 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7071 {
7072 fRet = eANI_BOOLEAN_TRUE;
7073 }
7074 }
7075 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007076 return (fRet);
7077}
Jeff Johnson295189b2012-06-20 16:38:30 -07007078eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7079{
7080 eHalStatus status = eHAL_STATUS_SUCCESS;
7081 tSmeCmd *pCommand = NULL;
7082 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7083 tANI_BOOLEAN fRemoveCmd = FALSE;
7084 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007085 // Delete the old assoc command. All is setup for reassoc to be serialized
7086 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7087 if ( pEntry )
7088 {
7089 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7090 if ( !pCommand )
7091 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007092 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 return eHAL_STATUS_RESOURCES;
7094 }
7095 if ( eSmeCommandRoam == pCommand->command )
7096 {
7097 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7098 {
7099 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7100 }
7101 else
7102 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007103 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007104 }
7105 if (fRemoveCmd == FALSE)
7106 {
7107 // Implies we did not get the serialized assoc command we
7108 // were expecting
7109 pCommand = NULL;
7110 }
7111 }
7112 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 if(NULL == pCommand)
7114 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007115 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007116 return eHAL_STATUS_RESOURCES;
7117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007118 do
7119 {
7120 //Change the substate in case it is wait-for-key
7121 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7122 {
7123 csrRoamStopWaitForKeyTimer( pMac );
7124 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7125 }
7126 pCommand->command = eSmeCommandRoam;
7127 pCommand->sessionId = (tANI_U8)sessionId;
7128 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007129 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7130 if( !HAL_STATUS_SUCCESS( status ) )
7131 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007132 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007133 csrReleaseCommandRoam( pMac, pCommand );
7134 }
7135 } while( 0 );
7136
Jeff Johnson295189b2012-06-20 16:38:30 -07007137 return( status );
7138}
7139static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7140{
7141 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7142 tCsrScanResult *pScanResult = NULL;
7143 tSirBssDescription *pBssDesc = NULL;
7144 tSmeCmd *pCommand = NULL;
7145 tANI_U32 sessionId;
7146 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007147 if(NULL == pEntry)
7148 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007149 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007150 return;
7151 }
7152 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7153 sessionId = pCommand->sessionId;
7154 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007155
7156 if(!pSession)
7157 {
7158 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7159 return;
7160 }
7161
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7163 {
7164 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007165 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007166 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7167 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007168 /* If the roaming has stopped, not to continue the roaming command*/
7169 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7170 {
7171 //No need to complete roaming here as it already completes
7172 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7173 pCommand->u.roamCmd.roamReason);
7174 csrSetAbortRoamingCommand( pMac, pCommand );
7175 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7176 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007177 else
7178 {
7179 if ( CCM_IS_RESULT_SUCCESS(result) )
7180 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007181 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007182 // Successfully set the configuration parameters for the new Bss. Attempt to
7183 // join the roaming Bss.
7184 if(pCommand->u.roamCmd.pRoamBssEntry)
7185 {
7186 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7187 pBssDesc = &pScanResult->Result.BssDescriptor;
7188 }
7189 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7190 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007191 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 )
7193 {
7194 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7195 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7196 pBssDesc, pCommand->u.roamCmd.roamId )))
7197 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007198 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007199 //We need to complete the command
7200 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7201 }
7202 }
7203 else
7204 {
7205 if (!pCommand->u.roamCmd.pRoamBssEntry)
7206 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007207 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 //We need to complete the command
7209 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7210 return;
7211 }
7212 // If we are roaming TO an Infrastructure BSS...
7213 VOS_ASSERT(pScanResult != NULL);
7214 if ( csrIsInfraBssDesc( pBssDesc ) )
7215 {
7216 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007217 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7218 {
7219 // ..and currently in an Infrastructure connection....
7220 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7221 {
7222 // ...and the SSIDs are equal, then we Reassoc.
7223 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7224 pIesLocal ) )
7225 // ..and currently in an infrastructure connection
7226 {
7227 // then issue a Reassoc.
7228 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7229 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7230 &pCommand->u.roamCmd.roamProfile );
7231 }
7232 else
7233 {
7234
7235 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7236 // previously associated AP.
7237 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7238 pIesLocal,
7239 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7240 {
7241 //try something else
7242 csrRoam( pMac, pCommand );
7243 }
7244 }
7245 }
7246 else
7247 {
7248 eHalStatus status = eHAL_STATUS_SUCCESS;
7249
7250 /* We need to come with other way to figure out that this is because of HO in BMP
7251 The below API will be only available for Android as it uses a different HO algorithm */
7252 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7253 * use join request */
7254#ifdef WLAN_FEATURE_VOWIFI_11R
7255 if (csrRoamIsHandoffInProgress(pMac) &&
7256 csrRoamIs11rAssoc(pMac))
7257 {
7258 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7259 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7260 }
7261 else
7262#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007263#ifdef FEATURE_WLAN_CCX
7264 if (csrRoamIsHandoffInProgress(pMac) &&
7265 csrRoamIsCCXAssoc(pMac))
7266 {
7267 // Now serialize the reassoc command.
7268 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7269 }
7270 else
7271#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007272#ifdef FEATURE_WLAN_LFR
7273 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307274 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007275 {
7276 // Now serialize the reassoc command.
7277 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7278 }
7279 else
7280#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007281 // else we are not connected and attempting to Join. Issue the
7282 // Join request.
7283 {
7284 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7285 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7286 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7287 }
7288 if(!HAL_STATUS_SUCCESS(status))
7289 {
7290 //try something else
7291 csrRoam( pMac, pCommand );
7292 }
7293 }
7294 if( !pScanResult->Result.pvIes )
7295 {
7296 //Locally allocated
7297 palFreeMemory(pMac->hHdd, pIesLocal);
7298 }
7299 }
7300 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7301 else
7302 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007303 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007304 }
7305 }//else
7306 }//if ( WNI_CFG_SUCCESS == result )
7307 else
7308 {
7309 // In the event the configuration failed, for infra let the roam processor
7310 //attempt to join something else...
7311 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7312 {
7313 csrRoam(pMac, pCommand);
7314 }
7315 else
7316 {
7317 //We need to complete the command
7318 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7319 {
7320 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7321 }
7322 else
7323 {
7324 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7325 }
7326 }
7327 }
7328 }//we have active entry
7329}
7330
Jeff Johnson295189b2012-06-20 16:38:30 -07007331static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7332{
7333 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007334 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7336 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007337 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007338 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7339 // join the new one...
7340 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007341 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7342 }
7343 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007344 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007345 /***profHandleLostLinkAfterReset(pAdapter);
7346 // In the event the authenticate fails, let the roam processor attempt to join something else...
7347 roamRoam( pAdapter );***/
7348 }
7349}
7350
Jeff Johnson295189b2012-06-20 16:38:30 -07007351static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7352{
7353 eCsrRoamCompleteResult result;
7354 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7355 tCsrRoamInfo roamInfo;
7356 tANI_U32 roamId = 0;
7357
7358 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7359 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007360 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007361 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007362 /* Defeaturize this part later if needed */
7363#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7364 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7365 * we need the response contents while processing the result in csrRoamProcessResults() */
7366 if (csrRoamIsHandoffInProgress(pMac))
7367 {
7368 /* Need to dig more on indicating events to SME QoS module */
7369 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7370 csrRoamComplete( pMac, result, pSmeJoinRsp);
7371 }
7372 else
7373#endif
7374 {
7375 csrRoamComplete( pMac, result, NULL );
7376 }
7377 }
7378 /* Should we handle this similar to handling the join failure? Is it ok
7379 * to call csrRoamComplete() with state as CsrJoinFailure */
7380 else
7381 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007382 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 result = eCsrReassocFailure;
7384#ifdef WLAN_FEATURE_VOWIFI_11R
7385 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7386 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7387 {
7388 // Inform HDD to turn off FT flag in HDD
7389 if (pNeighborRoamInfo)
7390 {
7391 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7392 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7393 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007394 /*
7395 * Since the above callback sends a disconnect
7396 * to HDD, we should clean-up our state
7397 * machine as well to be in sync with the upper
7398 * layers. There is no need to send a disassoc
7399 * since: 1) we will never reassoc to the current
7400 * AP in LFR, and 2) there is no need to issue a
7401 * disassoc to the AP with which we were trying
7402 * to reassoc.
7403 */
7404 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7405 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 }
7407 }
7408#endif
7409 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7410 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7411 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7412 //The disassoc rsp message will remove the command from active list
7413 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7414 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7415 {
7416 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7417 }
7418 }
7419}
7420
Jeff Johnson295189b2012-06-20 16:38:30 -07007421static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7422{
Jeff Johnson295189b2012-06-20 16:38:30 -07007423#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7424 {
7425 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7427 if(pIbssLog)
7428 {
7429 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7430 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7431 {
7432 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7433 }
7434 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7435 }
7436 }
7437#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007438 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7439 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7440 {
7441 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7442 }
7443 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7444 {
7445 csrRoamReissueRoamCommand(pMac);
7446 }
7447}
7448
Jeff Johnson295189b2012-06-20 16:38:30 -07007449void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7450{
7451 tSirResultCodes statusCode;
7452#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7453 tScanResultHandle hBSSList;
7454 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7455 eHalStatus status;
7456 tCsrRoamInfo roamInfo;
7457 tCsrScanResultFilter *pScanFilter = NULL;
7458 tANI_U32 roamId = 0;
7459 tCsrRoamProfile *pCurRoamProfile = NULL;
7460 tListElem *pEntry = NULL;
7461 tSmeCmd *pCommand = NULL;
7462#endif
7463 tANI_U32 sessionId;
7464 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007465
Jeff Johnson295189b2012-06-20 16:38:30 -07007466 tSirSmeDisassocRsp SmeDisassocRsp;
7467
7468 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7469 sessionId = SmeDisassocRsp.sessionId;
7470 statusCode = SmeDisassocRsp.statusCode;
7471
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007472 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007473
7474 if ( csrIsConnStateInfra( pMac, sessionId ) )
7475 {
7476 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007479
7480 if(!pSession)
7481 {
7482 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7483 return;
7484 }
7485
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7487 {
7488 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7489 }
7490 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7491 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7492 {
7493 if ( eSIR_SME_SUCCESS == statusCode )
7494 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007495 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007496 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7497 }
7498 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007500 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7501 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007502 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007503#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007504 /*
7505 * First ensure if the roam profile is in the scan cache.
7506 * If not, post a reassoc failure and disconnect.
7507 */
7508 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7509 if(HAL_STATUS_SUCCESS(status))
7510 {
7511 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7512 status = csrRoamPrepareFilterFromProfile(pMac,
7513 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7514 if(!HAL_STATUS_SUCCESS(status))
7515 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007516 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007517 __func__, status);
7518 goto POST_ROAM_FAILURE;
7519 }
7520 else
7521 {
7522 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7523 if (!HAL_STATUS_SUCCESS(status))
7524 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007525 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007526 __func__, status);
7527 goto POST_ROAM_FAILURE;
7528 }
7529 }
7530 }
7531 else
7532 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007533 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007534 __func__, status);
7535 goto POST_ROAM_FAILURE;
7536 }
7537
7538 /*
7539 * After ensuring that the roam profile is in the scan result list,
7540 * dequeue the command from the active list.
7541 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007542 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7543 if ( pEntry )
7544 {
7545 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007546 /* If the head of the queue is Active and it is a ROAM command, remove
7547 * and put this on the Free queue.
7548 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007549 if ( eSmeCommandRoam == pCommand->command )
7550 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007551
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007552 /*
7553 * we need to process the result first before removing it from active list
7554 * because state changes still happening insides roamQProcessRoamResults so
7555 * no other roam command should be issued.
7556 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007557 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7558 if(pCommand->u.roamCmd.fReleaseProfile)
7559 {
7560 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7561 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007563 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007564 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007565 else
7566 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007567 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007568 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007569 }
7570 }
7571 else
7572 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007573 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007574 }
7575 }
7576 else
7577 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007578 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007579 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007580
7581 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7583
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007584 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7585 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7586 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007587
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007588 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7589 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007590
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007591 /* Copy the connected profile to apply the same for this connection as well */
7592 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7593 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007594 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007595 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7596 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7597 //make sure to put it at the head of the cmd queue
7598 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7599 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7600 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7601
Jeff Johnson295189b2012-06-20 16:38:30 -07007602 if(!HAL_STATUS_SUCCESS(status))
7603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007604 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007605 __func__, status);
7606 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007607 }
7608
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007609 /* Notify sub-modules like QoS etc. that handoff happening */
7610 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007611 csrReleaseProfile(pMac, pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007612 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007613 csrFreeScanFilter(pMac, pScanFilter);
7614 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007615 return;
7616 }
7617
7618POST_ROAM_FAILURE:
7619 if (pScanFilter)
7620 {
7621 csrFreeScanFilter(pMac, pScanFilter);
7622 palFreeMemory( pMac->hHdd, pScanFilter );
7623 }
7624 if (pCurRoamProfile)
7625 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7626
7627 /* Inform the upper layers that the reassoc failed */
7628 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7629 csrRoamCallCallback(pMac, sessionId,
7630 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7631
7632 /*
7633 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7634 * Upon success, we would re-enter this routine after receiving the disassoc
7635 * response and will fall into the reassoc fail sub-state. And, eventually
7636 * call csrRoamComplete which would remove the roam command from SME active
7637 * queue.
7638 */
7639 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7640 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7641 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007642 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007643 __func__, status);
7644 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007646#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007647
Jeff Johnson295189b2012-06-20 16:38:30 -07007648 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7649 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7650 {
7651 // Disassoc due to Reassoc failure falls into this codepath....
7652 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7653 }
7654 else
7655 {
7656 if ( eSIR_SME_SUCCESS == statusCode )
7657 {
7658 // Successfully disassociated from the 'old' Bss...
7659 //
7660 // We get Disassociate response in three conditions.
7661 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7662 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7663 // Infrastructure network.
7664 // - Third is where we are doing an Infra to Infra roam between networks with different
7665 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7666
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007667 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007668 }
7669 else
7670 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007671 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 }
7673 //We are not done yet. Get the data and continue roaming
7674 csrRoamReissueRoamCommand(pMac);
7675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007676}
7677
Jeff Johnson295189b2012-06-20 16:38:30 -07007678static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7679{
7680 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007681 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007682 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007683 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7684 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7685 {
7686 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7687 }
7688 else
7689 {
7690 if ( eSIR_SME_SUCCESS == statusCode )
7691 {
7692 // Successfully deauth from the 'old' Bss...
7693 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007694 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007695 }
7696 else
7697 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007698 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007699 }
7700 //We are not done yet. Get the data and continue roaming
7701 csrRoamReissueRoamCommand(pMac);
7702 }
7703}
7704
Jeff Johnson295189b2012-06-20 16:38:30 -07007705static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7706{
7707 eCsrRoamCompleteResult result;
7708
7709 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7710 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007711 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007712 result = eCsrStartBssSuccess;
7713 }
7714 else
7715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007716 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007717 //Let csrRoamComplete decide what to do
7718 result = eCsrStartBssFailure;
7719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007720 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007721}
7722
Jeff Johnson295189b2012-06-20 16:38:30 -07007723/*
7724 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7725 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7726 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7727 For the messages where sender allocates memory for specific structures, then it can be
7728 cast accordingly.
7729*/
7730void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7731{
7732 tSirSmeRsp *pSmeRsp;
7733 tSmeIbssPeerInd *pIbssPeerInd;
7734 tCsrRoamInfo roamInfo;
7735 // TODO Session Id need to be acquired in this function
7736 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007737 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007738 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007739 pSmeRsp->messageType, pSmeRsp->messageType,
7740 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07007741 pSmeRsp->messageType = (pSmeRsp->messageType);
7742 pSmeRsp->length = (pSmeRsp->length);
7743 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007744 switch (pSmeRsp->messageType)
7745 {
7746
7747 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7748 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7749 {
7750 //We sent a JOIN_REQ
7751 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7752 }
7753 break;
7754
7755 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7756 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7757 {
7758 //We sent a AUTH_REQ
7759 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7760 }
7761 break;
7762
7763 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7764 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7765 {
7766 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7767 }
7768 break;
7769
7770 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7771 {
7772 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7773 }
7774 break;
7775
7776 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7777 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7778 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7779 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7780 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7781 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7782//HO
7783 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7784 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007785 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007786 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7787 }
7788 break;
7789
7790 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7791 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7792 {
7793 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7794 }
7795 break;
7796
7797 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7798 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7799 {
7800 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7801 }
7802 break;
7803
7804 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7805 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7806 {
7807 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7808 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007809 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7811 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7812 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007813 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Jeff Johnson295189b2012-06-20 16:38:30 -07007814 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7815 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7816 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7817 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7818 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7819 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7820 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7821 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7822 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007823 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007824 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007825 pSmeRsp->messageType, pSmeRsp->messageType,
7826 pMac->roam.curSubState[pSmeRsp->sessionId] );
7827
7828 //If we are connected, check the link status change
7829 if(!csrIsConnStateDisconnected(pMac, sessionId))
7830 {
7831 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7832 }
7833 break;
7834 }
7835}
7836
Jeff Johnson295189b2012-06-20 16:38:30 -07007837void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7838{
7839 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007840 switch (pSirMsg->messageType)
7841 {
7842 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007843 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007844 csrRoamStatsRspProcessor( pMac, pSirMsg );
7845 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007846 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7847 {
7848 tCsrRoamSession *pSession;
7849 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7850 tCsrRoamInfo roamInfo;
7851 tCsrRoamInfo *pRoamInfo = NULL;
7852 tANI_U32 sessionId;
7853 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007854 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Jeff Johnson295189b2012-06-20 16:38:30 -07007855 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7856 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7858 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7859 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007860
7861 if(!pSession)
7862 {
7863 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7864 return;
7865 }
7866
Jeff Johnson295189b2012-06-20 16:38:30 -07007867 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
7868 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07007869 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
7870 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
7871 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007872 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
7873 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007874 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
7875 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07007876 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07007877 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
7878 {
7879 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
7880 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
7881 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
7882 }
7883 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
7884 {
7885 vos_sleep( 100 );
7886 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
7887 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
7888 }
7889
Jeff Johnson295189b2012-06-20 16:38:30 -07007890 }
7891 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007892 default:
7893 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
7894 break;
7895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007896}
7897
Jeff Johnson295189b2012-06-20 16:38:30 -07007898eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
7899 tSirBssDescription *pBssDescription,
7900 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
7901 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
7902 tANI_U8 keyId, tANI_U16 keyLength,
7903 tANI_U8 *pKey, tANI_U8 paeRole )
7904{
7905 eHalStatus status = eHAL_STATUS_SUCCESS;
7906 tAniEdType edType;
7907
7908 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
7909 {
7910 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
7911 }
7912
7913 edType = csrTranslateEncryptTypeToEdType( EncryptType );
7914
7915 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
7916 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
7917 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
7918 addKey )
7919 {
7920 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07007921 setKey.encType = EncryptType;
7922 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
7923 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
7924 setKey.paeRole = paeRole; //0 for supplicant
7925 setKey.keyId = keyId; // Kye index
7926 setKey.keyLength = keyLength;
7927 if( keyLength )
7928 {
7929 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
7930 }
7931 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
7932 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007933 return (status);
7934}
7935
Jeff Johnson295189b2012-06-20 16:38:30 -07007936static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7937 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7938{
7939 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7940 tSmeCmd *pCommand = NULL;
7941#ifdef FEATURE_WLAN_CCX
7942 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7943#endif /* FEATURE_WLAN_CCX */
7944
7945 do
7946 {
7947 pCommand = csrGetCommandBuffer(pMac);
7948 if(NULL == pCommand)
7949 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007950 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007951 status = eHAL_STATUS_RESOURCES;
7952 break;
7953 }
7954 pCommand->command = eSmeCommandSetKey;
7955 pCommand->sessionId = (tANI_U8)sessionId;
7956 // validate the key length, Adjust if too long...
7957 // for static WEP the keys are not set thru' SetContextReq
7958 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
7959 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
7960 {
7961 //KeyLength maybe 0 for static WEP
7962 if( pSetKey->keyLength )
7963 {
7964 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
7965 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007966 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07007967 break;
7968 }
7969
7970 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
7971 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
7972 }
7973 }
7974 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
7975 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
7976 {
7977 //KeyLength maybe 0 for static WEP
7978 if( pSetKey->keyLength )
7979 {
7980 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
7981 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007982 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07007983 break;
7984 }
7985
7986 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
7987 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
7988 }
7989 }
7990 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
7991 {
7992 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
7993 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007994 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07007995 break;
7996 }
7997 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
7998 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
7999 }
8000 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8001 {
8002 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8003 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008004 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008005 break;
8006 }
8007 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
8008 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
8009 }
8010#ifdef FEATURE_WLAN_WAPI
8011 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8012 {
8013 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8014 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008015 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008016 break;
8017 }
8018 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
8019 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
8020 }
8021#endif /* FEATURE_WLAN_WAPI */
8022#ifdef FEATURE_WLAN_CCX
8023 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8024 {
8025 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008027 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008028 break;
8029 }
8030 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
8031 pSession->ccxCckmInfo.reassoc_req_num=1;
8032 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8033 status = eHAL_STATUS_SUCCESS;
8034 break;
8035 }
8036#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008037
Jeff Johnson295189b2012-06-20 16:38:30 -07008038#ifdef WLAN_FEATURE_11W
8039 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008040 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008042 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008044 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008045 break;
8046 }
8047 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Chet Lanctot186b5732013-03-18 10:26:30 -07008048 palCopyMemory(pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008049 }
8050#endif
8051 status = eHAL_STATUS_SUCCESS;
8052 pCommand->u.setKeyCmd.roamId = roamId;
8053 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8054 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
8055 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
8056 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8057 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
8058 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
8059 //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
8060
8061 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8062 if( !HAL_STATUS_SUCCESS( status ) )
8063 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008064 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008065 }
8066 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008067 // Free the command if there has been a failure, or it is a
8068 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008069 if ( ( NULL != pCommand ) &&
8070 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008071#ifdef FEATURE_WLAN_CCX
8072 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8073#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008074 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008075 {
8076 csrReleaseCommandSetKey( pMac, pCommand );
8077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008078 return( status );
8079}
8080
Jeff Johnson295189b2012-06-20 16:38:30 -07008081eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8082 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8083{
8084 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8085 tSmeCmd *pCommand = NULL;
8086 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008087 do
8088 {
8089 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8090 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008091 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008092 status = eHAL_STATUS_CSR_WRONG_STATE;
8093 break;
8094 }
8095 pCommand = csrGetCommandBuffer(pMac);
8096 if(NULL == pCommand)
8097 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008098 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008099 status = eHAL_STATUS_RESOURCES;
8100 break;
8101 }
8102 pCommand->command = eSmeCommandRemoveKey;
8103 pCommand->sessionId = (tANI_U8)sessionId;
8104 pCommand->u.removeKeyCmd.roamId = roamId;
8105 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
8106 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
8107 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8108 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8109 {
8110 //in this case, put it to the end of the Q incase there is a set key pending.
8111 fImediate = eANI_BOOLEAN_FALSE;
8112 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008113 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008114 pRemoveKey->encType, pRemoveKey->keyId,
8115 pCommand->u.removeKeyCmd.peerMac[0],
8116 pCommand->u.removeKeyCmd.peerMac[1],
8117 pCommand->u.removeKeyCmd.peerMac[2],
8118 pCommand->u.removeKeyCmd.peerMac[3],
8119 pCommand->u.removeKeyCmd.peerMac[4],
8120 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008121 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8122 if( !HAL_STATUS_SUCCESS( status ) )
8123 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008124 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008125 break;
8126 }
8127 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008128 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8129 {
8130 csrReleaseCommandRemoveKey( pMac, pCommand );
8131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008132 return (status );
8133}
8134
Jeff Johnson295189b2012-06-20 16:38:30 -07008135eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8136{
8137 eHalStatus status;
8138 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8139 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8140 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8141 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008142#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8143 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8144 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008145 if(eCSR_ENCRYPT_TYPE_NONE != edType)
8146 {
8147 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8148 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8149 {
8150 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8151 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8152 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8153 }
8154 else
8155 {
8156 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8157 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8158 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8159 }
8160 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8161 if(CSR_IS_ENC_TYPE_STATIC(edType))
8162 {
8163 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008164 //It has to be static WEP here
8165 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8166 {
8167 setKeyEvent.keyId = (v_U8_t)defKeyId;
8168 }
8169 }
8170 else
8171 {
8172 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8173 }
8174 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8175 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8176 }
8177#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008178 if( csrIsSetKeyAllowed(pMac, sessionId) )
8179 {
8180 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8181 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8182 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8183 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8184 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8185 pCommand->u.setKeyCmd.keyRsc);
8186 }
8187 else
8188 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008189 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008190 //Set this status so the error handling take care of the case.
8191 status = eHAL_STATUS_CSR_WRONG_STATE;
8192 }
8193 if( !HAL_STATUS_SUCCESS(status) )
8194 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008195 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008196 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008197#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8198 if(eCSR_ENCRYPT_TYPE_NONE != edType)
8199 {
8200 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8201 {
8202 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8203 }
8204 else
8205 {
8206 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8207 }
8208 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8209 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8210 }
8211#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008213 return ( status );
8214}
8215
Jeff Johnson295189b2012-06-20 16:38:30 -07008216eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8217{
8218 eHalStatus status;
8219 tpSirSmeRemoveKeyReq pMsg = NULL;
8220 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8221 tANI_U8 *p;
8222 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008223#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8224 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8225 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008226 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8227 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8228 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8229 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8230 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8231 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8232 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8233 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8234#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008235 if( csrIsSetKeyAllowed(pMac, sessionId) )
8236 {
8237 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
8238 }
8239 else
8240 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008241 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008242 //Set the error status so error handling kicks in below
8243 status = eHAL_STATUS_CSR_WRONG_STATE;
8244 }
8245 if( HAL_STATUS_SUCCESS( status ) )
8246 {
8247 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
8248 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8249 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008250 pMsg->sessionId = (tANI_U8)sessionId;
8251 pMsg->transactionId = 0;
8252 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8253 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8254 // bssId - copy from session Info
8255 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
8256 p += sizeof(tSirMacAddr);
8257 // peerMacAddr
8258 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
8259 p += sizeof(tSirMacAddr);
8260 // edType
8261 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8262 p++;
8263 // weptype
8264 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8265 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8266 {
8267 *p = (tANI_U8)eSIR_WEP_STATIC;
8268 }
8269 else
8270 {
8271 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8272 }
8273 p++;
8274 //keyid
8275 *p = pCommand->u.removeKeyCmd.keyId;
8276 p++;
8277 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008278 status = palSendMBMessage(pMac->hHdd, pMsg);
8279 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008280 if( !HAL_STATUS_SUCCESS( status ) )
8281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008282 smsLog( pMac, LOGE, FL(" error status "), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008283#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8284 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008285 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008286 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8287#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008288 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8289 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008290 return ( status );
8291}
8292
Jeff Johnson295189b2012-06-20 16:38:30 -07008293eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8294{
8295 eHalStatus status;
8296
8297 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8298 {
8299 status = eHAL_STATUS_CSR_WRONG_STATE;
8300 }
8301 else
8302 {
8303 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008305 return ( status );
8306}
8307
Jeff Johnson295189b2012-06-20 16:38:30 -07008308/*
8309 Prepare a filter base on a profile for parsing the scan results.
8310 Upon successful return, caller MUST call csrFreeScanFilter on
8311 pScanFilter when it is done with the filter.
8312*/
8313eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8314 tCsrScanResultFilter *pScanFilter)
8315{
8316 eHalStatus status = eHAL_STATUS_SUCCESS;
8317 tANI_U32 size = 0;
8318 tANI_U8 index = 0;
8319
8320 do
8321 {
8322 if(pProfile->BSSIDs.numOfBSSIDs)
8323 {
8324 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
8325 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
8326 if(!HAL_STATUS_SUCCESS(status))
8327 {
8328 break;
8329 }
8330 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
8331 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
8332 }
8333 if(pProfile->SSIDs.numOfSSIDs)
8334 {
8335 if( !CSR_IS_WDS_STA( pProfile ) )
8336 {
8337 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8338 }
8339 else
8340 {
8341 //For WDS station
8342 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8343 pScanFilter->SSIDs.numOfSSIDs = 1;
8344 }
8345 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8346 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8347 if(!HAL_STATUS_SUCCESS(status))
8348 {
8349 break;
8350 }
8351 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8352 }
8353 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8354 {
8355 pScanFilter->ChannelInfo.numOfChannels = 0;
8356 pScanFilter->ChannelInfo.ChannelList = NULL;
8357 }
8358 else if(pProfile->ChannelInfo.numOfChannels)
8359 {
8360 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8361 pScanFilter->ChannelInfo.numOfChannels = 0;
8362 if(HAL_STATUS_SUCCESS(status))
8363 {
8364 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8365 {
8366 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8367 {
8368 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8369 = pProfile->ChannelInfo.ChannelList[index];
8370 pScanFilter->ChannelInfo.numOfChannels++;
8371 }
8372 else
8373 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008374 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008375 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008376 }
8377 }
8378 else
8379 {
8380 break;
8381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008382 }
8383 else
8384 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008385 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008386 status = eHAL_STATUS_FAILURE;
8387 break;
8388 }
8389 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8390 pScanFilter->authType = pProfile->AuthType;
8391 pScanFilter->EncryptionType = pProfile->EncryptionType;
8392 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8393 pScanFilter->BSSType = pProfile->BSSType;
8394 pScanFilter->phyMode = pProfile->phyMode;
8395#ifdef FEATURE_WLAN_WAPI
8396 //check if user asked for WAPI with 11n or auto mode, in that case modify
8397 //the phymode to 11g
8398 if(csrIsProfileWapi(pProfile))
8399 {
8400 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8401 {
8402 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8403 }
8404 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8405 {
8406 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8407 }
8408 if(!pScanFilter->phyMode)
8409 {
8410 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8411 }
8412 }
8413#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008414 /*Save the WPS info*/
8415 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008416 if( pProfile->countryCode[0] )
8417 {
8418 //This causes the matching function to use countryCode as one of the criteria.
8419 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8420 WNI_CFG_COUNTRY_CODE_LEN );
8421 }
8422#ifdef WLAN_FEATURE_VOWIFI_11R
8423 if (pProfile->MDID.mdiePresent)
8424 {
8425 pScanFilter->MDID.mdiePresent = 1;
8426 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8427 }
8428#endif
8429
8430 }while(0);
8431
8432 if(!HAL_STATUS_SUCCESS(status))
8433 {
8434 csrFreeScanFilter(pMac, pScanFilter);
8435 }
8436
8437 return(status);
8438}
8439
Jeff Johnson295189b2012-06-20 16:38:30 -07008440tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8441 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8442{
8443 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8444 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008445 do
8446 {
8447 // Validate the type is ok...
8448 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8449 pCommand = csrGetCommandBuffer( pMac );
8450 if ( !pCommand )
8451 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008452 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008453 break;
8454 }
8455 //Change the substate in case it is waiting for key
8456 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8457 {
8458 csrRoamStopWaitForKeyTimer( pMac );
8459 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8460 }
8461 pCommand->command = eSmeCommandWmStatusChange;
8462 pCommand->sessionId = (tANI_U8)sessionId;
8463 pCommand->u.wmStatusChangeCmd.Type = Type;
8464 if ( eCsrDisassociated == Type )
8465 {
8466 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8467 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8468 }
8469 else
8470 {
8471 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8472 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8473 }
8474 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8475 {
8476 fCommandQueued = eANI_BOOLEAN_TRUE;
8477 }
8478 else
8479 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008480 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008481 csrReleaseCommandWmStatusChange( pMac, pCommand );
8482 }
8483
Jeff Johnson295189b2012-06-20 16:38:30 -07008484 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8485 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008486 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008487 return( fCommandQueued );
8488}
8489
Jeff Johnson295189b2012-06-20 16:38:30 -07008490static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8491{
8492 v_S7_t rssi = 0;
8493 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8494 if(pGetRssiReq)
8495 {
8496 if(NULL != pGetRssiReq->pVosContext)
8497 {
8498 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8499 }
8500 else
8501 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008502 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008503 return;
8504 }
8505
8506 if(NULL != pGetRssiReq->rssiCallback)
8507 {
8508 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8509 }
8510 else
8511 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008512 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008513 return;
8514 }
8515 }
8516 else
8517 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008518 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 }
8520 return;
8521}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008522#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8523void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8524{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008525 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8526
Jeff Johnson36d483b2013-04-08 11:08:53 -07008527 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008528 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008529 /* Get roam Rssi request is backed up and passed back to the response,
8530 Extract the request message to fetch callback */
8531 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8532 v_S7_t rssi = pRoamRssiRsp->rssi;
8533
8534 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008535 {
8536 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8537 reqBkp->rssiCallback = NULL;
8538 vos_mem_free(reqBkp);
8539 }
8540 else
8541 {
8542 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8543 if (NULL != reqBkp)
8544 {
8545 vos_mem_free(reqBkp);
8546 }
8547 }
8548 }
8549 else
8550 {
8551 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8552 }
8553 return;
8554}
8555#endif
8556
Jeff Johnsone7245742012-09-05 17:12:55 -07008557static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8558{
8559 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8560 if(pTlRssiInd)
8561 {
8562 if(NULL != pTlRssiInd->tlCallback)
8563 {
8564 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08008565 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008566 }
8567 else
8568 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008569 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008570 }
8571 }
8572 else
8573 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008574 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008575 }
8576 return;
8577}
Jeff Johnson295189b2012-06-20 16:38:30 -07008578
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05308579eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
8580{
8581 tpSirResetAPCapsChange pMsg;
8582 tANI_U16 len;
8583 eHalStatus status = eHAL_STATUS_SUCCESS;
8584
8585 /* Create the message and send to lim */
8586 len = sizeof(tSirResetAPCapsChange);
8587 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
8588 if (HAL_STATUS_SUCCESS(status))
8589 {
8590 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirResetAPCapsChange) );
8591 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
8592 pMsg->length = len;
8593 palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr) );
8594 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= %02x-%02x-%02x-%02x-%02x-%02x"),
8595 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
8596 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ]);
8597 status = palSendMBMessage(pMac->hHdd, pMsg);
8598 }
8599 else
8600 {
8601 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
8602 }
8603 return status;
8604}
8605
Jeff Johnson295189b2012-06-20 16:38:30 -07008606void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8607{
8608 tSirSmeAssocInd *pAssocInd;
8609 tSirSmeDisassocInd *pDisassocInd;
8610 tSirSmeDeauthInd *pDeauthInd;
8611 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8612 tSirSmeNewBssInfo *pNewBss;
8613 tSmeIbssPeerInd *pIbssPeerInd;
8614 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8615 tSirSmeApNewCaps *pApNewCaps;
8616 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8617 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8618 tCsrRoamInfo *pRoamInfo = NULL;
8619 tCsrRoamInfo roamInfo;
8620 eHalStatus status;
8621 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8622 tCsrRoamSession *pSession = NULL;
8623 tpSirSmeSwitchChannelInd pSwitchChnInd;
8624 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008625 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008626 pSirMsg->messageType = (pSirMsg->messageType);
8627 pSirMsg->length = (pSirMsg->length);
8628 pSirMsg->statusCode = (pSirMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008629 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008630 switch( pSirMsg->messageType )
8631 {
8632 case eWNI_SME_ASSOC_IND:
8633 {
8634 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008635 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008636 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8637 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8638 if( HAL_STATUS_SUCCESS( status ) )
8639 {
8640 pSession = CSR_GET_SESSION(pMac, sessionId);
8641
Jeff Johnson32d95a32012-09-10 13:15:23 -07008642 if(!pSession)
8643 {
8644 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8645 return;
8646 }
8647
Jeff Johnson295189b2012-06-20 16:38:30 -07008648 pRoamInfo = &roamInfo;
8649
8650 // Required for indicating the frames to upper layer
8651 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8652 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8653
8654 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8655 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8656 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8657 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8658
8659 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8660 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8661 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8662
8663 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8664 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008665 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8666 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008667 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8668 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07008669 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07008670 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8671 {
8672 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8673 {
8674 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8675 pSession->pConnectBssDesc,
8676 &(pRoamInfo->peerMac),
8677 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8678 pRoamInfo->fAuthRequired = FALSE;
8679 }
8680 else
8681 {
8682 pRoamInfo->fAuthRequired = TRUE;
8683 }
8684 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8685 if (!HAL_STATUS_SUCCESS(status))
8686 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008688 /* Send Association completion message to PE */
8689 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8690
8691 /* send a message to CSR itself just to avoid the EAPOL frames going
8692 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008693 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8694 {
8695 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008697 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8698 {
8699 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8700 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8701 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8702 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008703 }
8704 }
8705 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008706 case eWNI_SME_DISASSOC_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008707 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008708 // Check if AP dis-associated us because of MIC failure. If so,
8709 // then we need to take action immediately and not wait till the
8710 // the WmStatusChange requests is pushed and processed
8711 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8712 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8713 if( HAL_STATUS_SUCCESS( status ) )
8714 {
8715 // If we are in neighbor preauth done state then on receiving
8716 // disassoc or deauth we dont roam instead we just disassoc
8717 // from current ap and then go to disconnected state
8718 // This happens for CCX and 11r FT connections ONLY.
8719#ifdef WLAN_FEATURE_VOWIFI_11R
8720 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8721 {
8722 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8723 }
8724#endif
8725#ifdef FEATURE_WLAN_CCX
8726 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8727 {
8728 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8729 }
8730#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008731#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308732 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008733 {
8734 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8735 }
8736#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008737 pSession = CSR_GET_SESSION( pMac, sessionId );
8738
Jeff Johnson32d95a32012-09-10 13:15:23 -07008739 if(!pSession)
8740 {
8741 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8742 return;
8743 }
8744
Jeff Johnson295189b2012-06-20 16:38:30 -07008745 if ( csrIsConnStateInfra( pMac, sessionId ) )
8746 {
8747 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8748 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008749#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8750 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8751#endif
8752 csrRoamLinkDown(pMac, sessionId);
8753 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008754 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8755 {
8756
8757 pRoamInfo = &roamInfo;
8758
8759 pRoamInfo->statusCode = pDisassocInd->statusCode;
8760 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8761
8762 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8763
8764 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8765 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8766
8767 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008768
8769 /*
8770 * STA/P2P client got disassociated so remove any pending deauth
8771 * commands in sme pending list
8772 */
8773 pCommand.command = eSmeCommandRoam;
8774 pCommand.sessionId = (tANI_U8)sessionId;
8775 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8776 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8777 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008778 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008779 }
8780 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008781 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008782 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008783 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8784 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8785 if( HAL_STATUS_SUCCESS( status ) )
8786 {
8787 // If we are in neighbor preauth done state then on receiving
8788 // disassoc or deauth we dont roam instead we just disassoc
8789 // from current ap and then go to disconnected state
8790 // This happens for CCX and 11r FT connections ONLY.
8791#ifdef WLAN_FEATURE_VOWIFI_11R
8792 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8793 {
8794 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8795 }
8796#endif
8797#ifdef FEATURE_WLAN_CCX
8798 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8799 {
8800 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8801 }
8802#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008803#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308804 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008805 {
8806 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8807 }
8808#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008809 pSession = CSR_GET_SESSION( pMac, sessionId );
8810
Jeff Johnson32d95a32012-09-10 13:15:23 -07008811 if(!pSession)
8812 {
8813 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8814 return;
8815 }
8816
Jeff Johnson295189b2012-06-20 16:38:30 -07008817 if ( csrIsConnStateInfra( pMac, sessionId ) )
8818 {
8819 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8820 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008821#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8822 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8823#endif
8824 csrRoamLinkDown(pMac, sessionId);
8825 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008826 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8827 {
8828
8829 pRoamInfo = &roamInfo;
8830
8831 pRoamInfo->statusCode = pDeauthInd->statusCode;
8832 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8833
8834 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8835
8836 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8837 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8838
8839 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8840 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 }
8842 break;
8843
8844 case eWNI_SME_SWITCH_CHL_REQ: // in case of STA, the SWITCH_CHANNEL originates from its AP
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008845 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008846 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8847 //Update with the new channel id.
8848 //The channel id is hidden in the statusCode.
8849 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8850 if( HAL_STATUS_SUCCESS( status ) )
8851 {
8852 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008853 if(!pSession)
8854 {
8855 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8856 return;
8857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008858 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8859 if(pSession->pConnectBssDesc)
8860 {
8861 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8862 }
8863 }
8864 break;
8865
8866 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008867 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008868 {
8869 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8870 sessionId = pDeauthRsp->sessionId;
8871 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8872 {
8873 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008874 if(!pSession)
8875 {
8876 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8877 return;
8878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8880 {
8881 pRoamInfo = &roamInfo;
8882 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8883 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8884 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8885 pRoamInfo->statusCode = pDeauthRsp->statusCode;
8886 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8887 }
8888 }
8889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008890 break;
8891
8892 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07008893 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008894 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07008895 {
8896 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8897 sessionId = pDisassocRsp->sessionId;
8898 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8899 {
8900 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008901 if(!pSession)
8902 {
8903 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8904 return;
8905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008906 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8907 {
8908 pRoamInfo = &roamInfo;
8909 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8910 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
8911 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8912 pRoamInfo->statusCode = pDisassocRsp->statusCode;
8913 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8914 }
8915 }
8916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008917 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008918 case eWNI_SME_MIC_FAILURE_IND:
8919 {
8920 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
8921 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8922 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Jeff Johnson295189b2012-06-20 16:38:30 -07008923#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8924 {
8925 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008926 if(!pSession)
8927 {
8928 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8929 return;
8930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008931 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
8932 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
8933 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
8934 secEvent.encryptionModeMulticast =
8935 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8936 secEvent.encryptionModeUnicast =
8937 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8938 secEvent.authMode =
8939 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8940 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
8941 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
8942 }
8943#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008944 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
8945 if( HAL_STATUS_SUCCESS( status ) )
8946 {
8947 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8948 roamInfo.u.pMICFailureInfo = &pMicInd->info;
8949 pRoamInfo = &roamInfo;
8950 if(pMicInd->info.multicast)
8951 {
8952 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
8953 }
8954 else
8955 {
8956 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
8957 }
8958 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
8959 }
8960 }
8961 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008962 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
8963 {
8964 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
8965 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008966 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008967
8968 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
8969 if( HAL_STATUS_SUCCESS( status ) )
8970 {
8971 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8972 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
8973 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
8974 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
8975 }
8976 }
8977 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008978
Jeff Johnson295189b2012-06-20 16:38:30 -07008979 case eWNI_SME_WM_STATUS_CHANGE_NTF:
8980 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
8981 switch( pStatusChangeMsg->statusChangeCode )
8982 {
8983 case eSIR_SME_IBSS_ACTIVE:
8984 sessionId = csrFindIbssSession( pMac );
8985 if( CSR_SESSION_ID_INVALID != sessionId )
8986 {
8987 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008988 if(!pSession)
8989 {
8990 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8991 return;
8992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008993 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
8994 if(pSession->pConnectBssDesc)
8995 {
8996 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8997 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
8998 pRoamInfo = &roamInfo;
8999 }
9000 else
9001 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009002 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009003 }
9004 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9005 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9006 }
9007 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009008 case eSIR_SME_IBSS_INACTIVE:
9009 sessionId = csrFindIbssSession( pMac );
9010 if( CSR_SESSION_ID_INVALID != sessionId )
9011 {
9012 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009013 if(!pSession)
9014 {
9015 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9016 return;
9017 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009018 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9019 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9020 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9021 }
9022 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009023 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9024 sessionId = csrFindIbssSession( pMac );
9025 if( CSR_SESSION_ID_INVALID != sessionId )
9026 {
9027 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009028 if(!pSession)
9029 {
9030 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9031 return;
9032 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009033 // update the connection state information
9034 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009035#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9036 {
9037 vos_log_ibss_pkt_type *pIbssLog;
9038 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009039 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9040 if(pIbssLog)
9041 {
9042 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9043 if(pNewBss)
9044 {
9045 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
9046 if(pNewBss->ssId.length)
9047 {
9048 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
9049 }
9050 pIbssLog->operatingChannel = pNewBss->channelNumber;
9051 }
9052 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9053 {
9054 //***U8 is not enough for beacon interval
9055 pIbssLog->beaconInterval = (v_U8_t)bi;
9056 }
9057 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9058 }
9059 }
9060#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009061 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
9062 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
9063 pSession->pConnectBssDesc,
9064 &Broadcastaddr,
9065 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9066 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9067 roamStatus = eCSR_ROAM_IBSS_IND;
9068 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
9069 pRoamInfo = &roamInfo;
9070 //This BSSID is th ereal BSSID, let's save it
9071 if(pSession->pConnectBssDesc)
9072 {
9073 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
9074 }
9075 // Stop the join IBSS timer in case of join, for
9076 // genuine merge do nothing
9077 if(pSession->ibss_join_pending)
9078 {
9079 pSession->ibss_join_pending = FALSE;
9080 csrRoamStopIbssJoinTimer(pMac, sessionId);
9081 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
9082 }
9083 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009084 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009085 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009086 // detection by LIM that the capabilities of the associated AP have changed.
9087 case eSIR_SME_AP_CAPS_CHANGED:
9088 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009089 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009090 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9091 if( HAL_STATUS_SUCCESS( status ) )
9092 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009093 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9094 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309095 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009096 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9097 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9098 )
9099 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309100 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9101 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009102 }
9103 else
9104 {
9105 smsLog(pMac, LOGW,
9106 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009107 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009108 pMac->roam.curState[sessionId],
9109 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309110 /* We ignore the caps change event if CSR is not in full connected state.
9111 * Send one event to PE to reset limSentCapsChangeNtf
9112 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9113 * otherwise lim cannot send any CAPS change events to SME */
9114 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009116 }
9117 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309118
Jeff Johnson295189b2012-06-20 16:38:30 -07009119 default:
9120 roamStatus = eCSR_ROAM_FAILED;
9121 result = eCSR_ROAM_RESULT_NONE;
9122 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009123 } // end switch on statusChangeCode
9124 if(eCSR_ROAM_RESULT_NONE != result)
9125 {
9126 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9127 }
9128 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009129 case eWNI_SME_IBSS_NEW_PEER_IND:
9130 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009131#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9132 {
9133 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009134 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9135 if(pIbssLog)
9136 {
9137 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
9138 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9139 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9140 }
9141 }
9142#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009143 sessionId = csrFindIbssSession( pMac );
9144 if( CSR_SESSION_ID_INVALID != sessionId )
9145 {
9146 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009147
9148 if(!pSession)
9149 {
9150 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9151 return;
9152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009153 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9154 if(pSession->pConnectBssDesc)
9155 {
9156 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9157 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9158 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9159 {
9160 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
9161 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
9162 if(HAL_STATUS_SUCCESS(status))
9163 {
9164 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
9165 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9166 roamInfo.nBeaconLength);
9167 }
9168 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9169 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9170 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9171 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
9172 pSession->pConnectBssDesc->length);
9173 if(HAL_STATUS_SUCCESS(status))
9174 {
9175 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
9176 pSession->pConnectBssDesc->length);
9177 }
9178 if(HAL_STATUS_SUCCESS(status))
9179 {
9180 pRoamInfo = &roamInfo;
9181 }
9182 else
9183 {
9184 if(roamInfo.pbFrames)
9185 {
9186 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9187 }
9188 if(roamInfo.pBssDesc)
9189 {
9190 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9191 }
9192 }
9193 }
9194 else
9195 {
9196 pRoamInfo = &roamInfo;
9197 }
9198 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
9199 pSession->pConnectBssDesc,
9200 &(pIbssPeerInd->peerAddr),
9201 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9202 }
9203 else
9204 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009205 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009206 }
9207 //send up the sec type for the new peer
9208 if (pRoamInfo)
9209 {
9210 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9211 }
9212 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9213 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9214 if(pRoamInfo)
9215 {
9216 if(roamInfo.pbFrames)
9217 {
9218 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9219 }
9220 if(roamInfo.pBssDesc)
9221 {
9222 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9223 }
9224 }
9225 }
9226 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9228 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9229 sessionId = csrFindIbssSession( pMac );
9230 if( CSR_SESSION_ID_INVALID != sessionId )
9231 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009232#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9233 {
9234 vos_log_ibss_pkt_type *pIbssLog;
9235
9236 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9237 if(pIbssLog)
9238 {
9239 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9240 if(pIbssPeerInd)
9241 {
9242 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9243 }
9244 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9245 }
9246 }
9247#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009248 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009249 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9250 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9251 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9252 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9253 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9254 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9255 }
9256 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009257 case eWNI_SME_SETCONTEXT_RSP:
9258 {
9259 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9260 tListElem *pEntry;
9261 tSmeCmd *pCommand;
9262
9263 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9264 if ( pEntry )
9265 {
9266 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9267 if ( eSmeCommandSetKey == pCommand->command )
9268 {
9269 sessionId = pCommand->sessionId;
9270 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009271
9272 if(!pSession)
9273 {
9274 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9275 return;
9276 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009277
9278#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9279 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9280 {
9281 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
9282 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9283 if( pRsp->peerMacAddr[0] & 0x01 )
9284 {
9285 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9286 }
9287 else
9288 {
9289 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9290 }
9291 setKeyEvent.encryptionModeMulticast =
9292 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9293 setKeyEvent.encryptionModeUnicast =
9294 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9295 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9296 setKeyEvent.authMode =
9297 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9298 if( eSIR_SUCCESS != pRsp->statusCode )
9299 {
9300 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9301 }
9302 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9303 }
9304#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9305 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9306 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009307 csrRoamStopWaitForKeyTimer( pMac );
9308
Jeff Johnson295189b2012-06-20 16:38:30 -07009309 //We are done with authentication, whethere succeed or not
9310 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009311 //We do it here because this linkup function is not called after association
9312 //when a key needs to be set.
9313 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9314 {
9315 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9316 }
9317 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009318 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009319 {
9320 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07009321 //Make sure we install the GTK before indicating to HDD as authenticated
9322 //This is to prevent broadcast packets go out after PTK and before GTK.
9323 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
9324 sizeof(tSirMacAddr) ) )
9325 {
Yathish9f22e662012-12-10 14:21:35 -08009326#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9327 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9328 {
9329 tpSirSetActiveModeSetBncFilterReq pMsg;
9330 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
9331 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9332 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9333 pMsg->seesionId = sessionId;
9334 status = palSendMBMessage(pMac->hHdd, pMsg );
9335 }
9336#endif
9337 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009338 }
9339 else
9340 {
9341 result = eCSR_ROAM_RESULT_NONE;
9342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009343 pRoamInfo = &roamInfo;
9344 }
9345 else
9346 {
9347 result = eCSR_ROAM_RESULT_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009348 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...",
Jeff Johnson295189b2012-06-20 16:38:30 -07009349 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9350 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9351 }
9352 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9353 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9355 // can go ahead and initiate the TSPEC if any are pending
9356 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009357#ifdef FEATURE_WLAN_CCX
9358 //Send Adjacent AP repot to new AP.
9359 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9360 pSession->isPrevApInfoValid &&
9361 pSession->connectedProfile.isCCXAssoc)
9362 {
9363#ifdef WLAN_FEATURE_VOWIFI
9364 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9365#endif
9366 pSession->isPrevApInfoValid = FALSE;
9367 }
9368#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009369 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9370 {
9371 csrReleaseCommandSetKey( pMac, pCommand );
9372 }
9373 }
9374 else
9375 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009376 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009377 }
9378 }
9379 else
9380 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009381 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009383 smeProcessPendingQueue( pMac );
9384 }
9385 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009386 case eWNI_SME_REMOVEKEY_RSP:
9387 {
9388 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9389 tListElem *pEntry;
9390 tSmeCmd *pCommand;
9391
9392 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9393 if ( pEntry )
9394 {
9395 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9396 if ( eSmeCommandRemoveKey == pCommand->command )
9397 {
9398 sessionId = pCommand->sessionId;
9399 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009400
9401 if(!pSession)
9402 {
9403 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9404 return;
9405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009406#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9407 {
9408 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9409 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9410 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9411 removeKeyEvent.encryptionModeMulticast =
9412 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9413 removeKeyEvent.encryptionModeUnicast =
9414 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9415 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9416 removeKeyEvent.authMode =
9417 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9418 if( eSIR_SUCCESS != pRsp->statusCode )
9419 {
9420 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9421 }
9422 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9423 }
9424#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009425 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009426 {
9427 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9428 result = eCSR_ROAM_RESULT_NONE;
9429 pRoamInfo = &roamInfo;
9430 }
9431 else
9432 {
9433 result = eCSR_ROAM_RESULT_FAILURE;
9434 }
9435 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9436 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9437 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9438 {
9439 csrReleaseCommandRemoveKey( pMac, pCommand );
9440 }
9441 }
9442 else
9443 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009444 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009445 }
9446 }
9447 else
9448 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009449 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009451 smeProcessPendingQueue( pMac );
9452 }
9453 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009454 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009455 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009456 csrRoamStatsRspProcessor( pMac, pSirMsg );
9457 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009458#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9459 case eWNI_SME_GET_ROAM_RSSI_RSP:
9460 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9461 csrRoamRssiRspProcessor( pMac, pSirMsg );
9462 break;
9463#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009464 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009465 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009466 csrUpdateRssi( pMac, pSirMsg );
9467 break;
9468
Jeff Johnson295189b2012-06-20 16:38:30 -07009469#ifdef WLAN_FEATURE_VOWIFI_11R
9470 case eWNI_SME_FT_PRE_AUTH_RSP:
9471 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9472 break;
9473#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009474 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9475 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009476 smsLog( pMac, LOG1, FL("send indication that max assoc have been reached and the new peer cannot be accepted"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 sessionId = pSmeMaxAssocInd->sessionId;
9478 roamInfo.sessionId = sessionId;
9479 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9480 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9481 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9482 break;
9483
9484 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009485 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009486 btampEstablishLogLinkHdlr( pSirMsg );
9487 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009488 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009489 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009490 csrRoamRssiIndHdlr( pMac, pSirMsg );
9491 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009492#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9493 case eWNI_SME_CANDIDATE_FOUND_IND:
9494 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
9495 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
9496 break;
9497#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009498
9499 default:
9500 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009501 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009502}
9503
Jeff Johnson295189b2012-06-20 16:38:30 -07009504void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9505 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9506{
9507 if(pSession)
9508 {
9509 if(pSession->bRefAssocStartCnt)
9510 {
9511 pSession->bRefAssocStartCnt--;
9512 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9513 //Need to call association_completion because there is an assoc_start pending.
9514 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9515 eCSR_ROAM_ASSOCIATION_COMPLETION,
9516 eCSR_ROAM_RESULT_FAILURE);
9517 }
9518 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9519 }
9520 else
9521 {
9522 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9523 }
9524}
9525
9526
9527eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9528{
9529 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009530 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9531 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9532 {
9533 status = csrScanRequestLostLink1( pMac, sessionId );
9534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009535 return(status);
9536}
9537
Jeff Johnson295189b2012-06-20 16:38:30 -07009538//return a boolean to indicate whether roaming completed or continue.
9539tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9540 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9541{
9542 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9543 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9544 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9545 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009546 if(!pSession)
9547 {
9548 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9549 return eANI_BOOLEAN_FALSE;
9550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009551 //Check whether time is up
9552 if(pSession->fCancelRoaming || fForce ||
9553 ((curTime - pSession->roamingStartTime) > roamTime) ||
9554 eCsrReassocRoaming == pSession->roamingReason ||
9555 eCsrDynamicRoaming == pSession->roamingReason)
9556 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009557 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009558 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9559 {
9560 //roaming is cancelled, tell HDD to indicate disconnect
9561 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9562 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9563 //to be eSIR_BEACON_MISSED
9564 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9565 {
9566 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9567 }
9568 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9569 {
9570 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9571 }
9572 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9573 {
9574 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9575 }
9576 else
9577 {
9578 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9579 }
9580 }
9581 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9582 pSession->roamingReason = eCsrNotRoaming;
9583 }
9584 else
9585 {
9586 pSession->roamResult = roamResult;
9587 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9588 {
9589 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9590 pSession->roamingReason = eCsrNotRoaming;
9591 }
9592 else
9593 {
9594 fCompleted = eANI_BOOLEAN_FALSE;
9595 }
9596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 return(fCompleted);
9598}
9599
Jeff Johnson295189b2012-06-20 16:38:30 -07009600void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9601{
9602 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009603
9604 if(!pSession)
9605 {
9606 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9607 return;
9608 }
9609
Jeff Johnson295189b2012-06-20 16:38:30 -07009610 if(CSR_IS_ROAMING(pSession))
9611 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009612 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -07009613 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9614 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9615 {
9616 //No need to do anything in here because the handler takes care of it
9617 }
9618 else
9619 {
9620 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9621 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9622 //Roaming is stopped after here
9623 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9624 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
9625 csrScanAbortMacScan(pMac);
9626 csrRoamStopRoamingTimer(pMac, sessionId);
9627 }
9628 }
9629}
9630
Jeff Johnson295189b2012-06-20 16:38:30 -07009631void csrRoamRoamingTimerHandler(void *pv)
9632{
9633 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9634 tpAniSirGlobal pMac = pInfo->pMac;
9635 tANI_U32 sessionId = pInfo->sessionId;
9636 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009637
9638 if(!pSession)
9639 {
9640 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9641 return;
9642 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009643
9644 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9645 {
9646 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9647 {
9648 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9649 pSession->roamingReason = eCsrNotRoaming;
9650 }
9651 }
9652}
9653
Jeff Johnson295189b2012-06-20 16:38:30 -07009654eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9655{
9656 eHalStatus status;
9657 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009658
9659 if(!pSession)
9660 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009661 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009662 return eHAL_STATUS_FAILURE;
9663 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009664
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009665 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009666 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
9667 status = palTimerStart(pMac->hHdd, pSession->hTimerRoaming, interval, eANI_BOOLEAN_FALSE);
9668
9669 return (status);
9670}
9671
Jeff Johnson295189b2012-06-20 16:38:30 -07009672eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9673{
9674 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerRoaming));
9675}
9676
Jeff Johnson295189b2012-06-20 16:38:30 -07009677void csrRoamWaitForKeyTimeOutHandler(void *pv)
9678{
9679 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9680 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009681 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9682
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009683 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009684 pMac->roam.neighborRoamInfo.neighborRoamState,
9685 pMac->roam.curSubState[pInfo->sessionId]);
9686
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9688 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009689#ifdef FEATURE_WLAN_LFR
9690 if (csrNeighborRoamIsHandoffInProgress(pMac))
9691 {
9692 /*
9693 * Enable heartbeat timer when hand-off is in progress
9694 * and Key Wait timer expired.
9695 */
9696 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009697 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009698 pMac->roam.configParam.HeartbeatThresh24);
9699 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9700 pMac->roam.configParam.HeartbeatThresh24,
9701 NULL, eANI_BOOLEAN_FALSE);
9702 }
9703#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009704 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Jeff Johnson295189b2012-06-20 16:38:30 -07009705 //Change the substate so command queue is unblocked.
9706 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009707 if (pSession)
9708 {
9709 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9710 {
9711 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9712 smeProcessPendingQueue(pMac);
9713 }
9714 else
9715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009716 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009717 __func__);
9718 }
9719 }
9720 else
9721 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009722 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009723 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009724 }
9725
9726}
9727
Jeff Johnson295189b2012-06-20 16:38:30 -07009728eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9729{
9730 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009731#ifdef FEATURE_WLAN_LFR
9732 if (csrNeighborRoamIsHandoffInProgress(pMac))
9733 {
9734 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009735 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009736 __func__,
9737 pMac->roam.neighborRoamInfo.neighborRoamState,
9738 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9739 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9740 }
9741#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009742 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009743 status = palTimerStart(pMac->hHdd, pMac->roam.hTimerWaitForKey, interval, eANI_BOOLEAN_FALSE);
9744
9745 return (status);
9746}
9747
Jeff Johnson295189b2012-06-20 16:38:30 -07009748eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9749{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009750 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009751 pMac->roam.neighborRoamInfo.neighborRoamState,
9752 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9753#ifdef FEATURE_WLAN_LFR
9754 if (csrNeighborRoamIsHandoffInProgress(pMac))
9755 {
9756 /*
9757 * Enable heartbeat timer when hand-off is in progress
9758 * and Key Wait timer got stopped for some reason
9759 */
9760 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009761 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009762 pMac->roam.configParam.HeartbeatThresh24);
9763 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9764 pMac->roam.configParam.HeartbeatThresh24,
9765 NULL, eANI_BOOLEAN_FALSE);
9766 }
9767#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009768 return (palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey));
9769}
9770
Jeff Johnson295189b2012-06-20 16:38:30 -07009771void csrRoamIbssJoinTimerHandler(void *pv)
9772{
9773 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9774 tpAniSirGlobal pMac = pInfo->pMac;
9775 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9776 tANI_U32 sessionId = pInfo->sessionId;
9777 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009778
9779 if(!pSession)
9780 {
9781 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9782 return;
9783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009784
9785 pSession->ibss_join_pending = FALSE;
9786 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9787 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9788 // Send an IBSS stop request to PE
9789 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009790}
Jeff Johnson295189b2012-06-20 16:38:30 -07009791eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9792{
9793 eHalStatus status;
9794 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009795
9796 if(!pSession)
9797 {
9798 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9799 return eHAL_STATUS_FAILURE;
9800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009801
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009802 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009803 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
9804 status = palTimerStart(pMac->hHdd, pSession->hTimerIbssJoining, interval, eANI_BOOLEAN_FALSE);
9805
9806 return (status);
9807}
Jeff Johnson295189b2012-06-20 16:38:30 -07009808eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9809{
9810 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerIbssJoining));
9811}
Jeff Johnson295189b2012-06-20 16:38:30 -07009812void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9813 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9814{
9815 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9816 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009817 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9818 /* To silence the KW tool Null chaeck is added */
9819 if(!pSession)
9820 {
9821 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9822 return;
9823 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009824
9825 if(pCommand)
9826 {
9827 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009828 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009830 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9831 {
9832 //if success, force roaming completion
9833 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9834 }
9835 else
9836 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009837 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009838 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07009839 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9840 }
9841}
9842
Jeff Johnson295189b2012-06-20 16:38:30 -07009843eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9844{
9845 eHalStatus status = eHAL_STATUS_SUCCESS;
9846 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9847 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9848 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9849 tCsrRoamInfo *pRoamInfo = NULL;
9850 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009851 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07009852 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009853 /* To silence the KW tool Null chaeck is added */
9854 if(!pSession)
9855 {
9856 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9857 return eHAL_STATUS_FAILURE;
9858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009859 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009860 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07009861 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9862 if ( eWNI_SME_DISASSOC_IND == type )
9863 {
9864 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9865 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9866 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009867 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009868 }
9869 else if ( eWNI_SME_DEAUTH_IND == type )
9870 {
9871 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9872 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9873 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -08009874 /* Convert into proper reason code */
9875 pSession->joinFailStatusCode.reasonCode =
9876 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +05309877 0 : pDeauthIndMsg->reasonCode;
9878 /* cfg layer expects 0 as reason code if
9879 the driver dosent know the reason code
9880 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -07009881 }
9882 else
9883 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009884 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009885 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009886 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009887 }
9888
9889 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -07009890 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009891 {
9892 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
9893 }
9894
9895 if ( eWNI_SME_DISASSOC_IND == type )
9896 {
9897 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
9898 }
9899 else if ( eWNI_SME_DEAUTH_IND == type )
9900 {
9901 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
9902 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009903 if(!HAL_STATUS_SUCCESS(status))
9904 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009905 //If fail to send confirmation to PE, not to trigger roaming
9906 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009907 }
9908
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009909 //prepare to tell HDD to disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -07009910 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9911 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9912 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009913 if( eWNI_SME_DISASSOC_IND == type)
9914 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009915 //staMacAddr
9916 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9917 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009919 else if( eWNI_SME_DEAUTH_IND == type )
9920 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009921 //staMacAddr
9922 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9923 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9924 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009925 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009926
9927 /* See if we can possibly roam. If so, start the roaming process and notify HDD
9928 that we are roaming. But if we cannot possibly roam, or if we are unable to
9929 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -07009930 if(fToRoam)
9931 {
9932 //Only remove the connected BSS in infrastructure mode
9933 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9934 //Not to do anying for lostlink with WDS
9935 if( pMac->roam.configParam.nRoamingTime )
9936 {
9937 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
9938 ( eWNI_SME_DEAUTH_IND == type ) ?
9939 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
9940 {
9941 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9942 //For IBSS, we need to give some more info to HDD
9943 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
9944 {
9945 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9946 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9947 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
9948 }
9949 else
9950 {
9951 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
9952 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009953 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009954 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
9955 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
9956 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9957 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
9958 }
9959 else
9960 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009961 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009962 fToRoam = eANI_BOOLEAN_FALSE;
9963 }
9964 }
9965 else
9966 {
9967 //We are told not to roam, indicate lostlink
9968 fToRoam = eANI_BOOLEAN_FALSE;
9969 }
9970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009971 if(!fToRoam)
9972 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -07009973 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009974 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009975 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009976 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
9977 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
9978 * csrRoamCheckForLinkStatusChange API.
9979 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009980 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
9981 }
9982
9983 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -07009984 Still enable idle scan for polling in case concurrent sessions are running */
9985 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
9986 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009987 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07009988 }
9989 }
9990
9991 return (status);
9992}
9993
Jeff Johnson295189b2012-06-20 16:38:30 -07009994eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
9995{
9996 eHalStatus status = eHAL_STATUS_SUCCESS;
9997 tListElem *pEntry = NULL;
9998 tSmeCmd *pCommand = NULL;
9999 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010000
10001 if(!pSession)
10002 {
10003 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10004 return eHAL_STATUS_FAILURE;
10005 }
10006
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010008 //Only remove the connected BSS in infrastructure mode
10009 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10010 if(pMac->roam.configParam.nRoamingTime)
10011 {
10012 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10013 {
10014 //before starting the lost link logic release the roam command for handoff
10015 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10016 if(pEntry)
10017 {
10018 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10019 }
10020 if(pCommand)
10021 {
10022 if (( eSmeCommandRoam == pCommand->command ) &&
10023 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10024 {
10025 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10026 {
10027 csrReleaseCommandRoam( pMac, pCommand );
10028 }
10029 }
10030 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010031 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010032 }
10033 }
10034 else
10035 {
10036 //We are told not to roam, indicate lostlink
10037 status = eHAL_STATUS_FAILURE;
10038 }
10039
10040 return (status);
10041}
Jeff Johnson295189b2012-06-20 16:38:30 -070010042void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10043{
10044 tListElem *pEntry;
10045 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010046 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10047 if ( pEntry )
10048 {
10049 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10050 if ( eSmeCommandWmStatusChange == pCommand->command )
10051 {
10052 // Nothing to process in a Lost Link completion.... It just kicks off a
10053 // roaming sequence.
10054 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10055 {
10056 csrReleaseCommandWmStatusChange( pMac, pCommand );
10057 }
10058 else
10059 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010060 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010061 }
10062
10063 }
10064 else
10065 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010066 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010067 }
10068 }
10069 else
10070 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010071 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010072 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010073 smeProcessPendingQueue( pMac );
10074}
10075
Jeff Johnson295189b2012-06-20 16:38:30 -070010076void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10077{
10078 eHalStatus status = eHAL_STATUS_FAILURE;
10079 tSirSmeRsp *pSirSmeMsg;
10080 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010081
10082 if(!pSession)
10083 {
10084 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10085 return;
10086 }
10087
Jeff Johnson295189b2012-06-20 16:38:30 -070010088 switch ( pCommand->u.wmStatusChangeCmd.Type )
10089 {
10090 case eCsrDisassociated:
10091 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10092 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10093 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010094 case eCsrDeauthenticated:
10095 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10096 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10097 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010099 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010100 break;
10101 }
10102 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10103 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10104 {
10105 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10106 {
10107 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010108 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010109 }
10110 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010111 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10112 // command here since there is nothing else to do.
10113 csrRoamWmStatusChangeComplete( pMac );
10114}
10115
Jeff Johnson295189b2012-06-20 16:38:30 -070010116//This function returns band and mode information.
10117//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10118//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010119static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10120 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010121{
Jeff Johnson295189b2012-06-20 16:38:30 -070010122 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10123 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10124 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010125 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010126
Jeff Johnson295189b2012-06-20 16:38:30 -070010127 //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 -070010128 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10129 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10130 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10131 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010132 {
10133 switch( pMac->roam.configParam.uCfgDot11Mode )
10134 {
10135 case eCSR_CFG_DOT11_MODE_11A:
10136 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10137 eBand = eCSR_BAND_5G;
10138 break;
10139 case eCSR_CFG_DOT11_MODE_11B:
10140 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10141 eBand = eCSR_BAND_24;
10142 break;
10143 case eCSR_CFG_DOT11_MODE_11G:
10144 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10145 eBand = eCSR_BAND_24;
10146 break;
10147 case eCSR_CFG_DOT11_MODE_11N:
10148 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10149 eBand = eCSR_BAND_24;
10150 break;
10151 //case eCSR_CFG_DOT11_MODE_BEST:
10152 // cfgDot11Mode = eCSR_CFG_DOT11_MODE_BEST;
10153 // eBand = eCSR_BAND_24;
10154 // break;
10155 default:
10156 // Global dot11 Mode setting is 11a/b/g.
10157 // use the channel number to determine the Mode setting.
10158 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10159 {
10160 eBand = pMac->roam.configParam.eBand;
10161 if(eCSR_BAND_24 == eBand)
10162 {
10163 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10164 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10165 }
10166 else
10167 {
10168 //prefer 5GHz
10169 eBand = eCSR_BAND_5G;
10170 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10171 }
10172 }
10173 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10174 {
10175 // channel is a 2.4GHz channel. Set mode to 11g.
10176 //
10177 // !!LAC - WiFi tests require IBSS networks to start in 11b mode without any change to the
10178 // default parameter settings on the adapter. We use ACU to start an IBSS through creation
10179 // of a startIBSS profile. this startIBSS profile has Auto MACProtocol and the
10180 // adapter property setting for dot11Mode is also AUTO. So in this case, let's start
10181 // the IBSS network in 11b mode instead of 11g mode.
10182 //
10183 // so this is for Auto=profile->MacProtocol && Auto=Global.dot11Mode && profile->channel is < 14,
10184 // then start the IBSS in b mode.
10185 //
10186 // Note: we used to have this start as an 11g IBSS for best performance... now to specify that
10187 // the user will have to set the do11Mode in the property page to 11g to force it.
10188 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10189 eBand = eCSR_BAND_24;
10190 }
10191 else
10192 {
10193 // else, it's a 5.0GHz channel. Set mode to 11a.
10194 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10195 eBand = eCSR_BAND_5G;
10196 }
10197 break;
10198 }//switch
10199 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10200 else
10201 {
10202 //dot11 mode is set, lets pick the band
10203 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10204 {
10205 // channel is Auto also.
10206 eBand = pMac->roam.configParam.eBand;
10207 if(eCSR_BAND_ALL == eBand)
10208 {
10209 //prefer 5GHz
10210 eBand = eCSR_BAND_5G;
10211 }
10212 }
10213 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10214 {
10215 eBand = eCSR_BAND_24;
10216 }
10217 else
10218 {
10219 eBand = eCSR_BAND_5G;
10220 }
10221 }
10222 if(pBand)
10223 {
10224 *pBand = eBand;
10225 }
10226
10227 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010228 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010229 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10230 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010231
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010232 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10233 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 -070010234 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010235#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010236 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010237#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010238 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10239 {
10240 //We cannot do 11n here
10241 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10242 {
10243 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10244 }
10245 else
10246 {
10247 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10248 }
10249 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010250 return( cfgDot11Mode );
10251}
10252
Jeff Johnson295189b2012-06-20 16:38:30 -070010253eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10254{
10255 eHalStatus status;
10256 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010257
10258 if(!pSession)
10259 {
10260 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10261 return eHAL_STATUS_FAILURE;
10262 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010263
10264#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10265 {
10266 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010267 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10268 if(pIbssLog)
10269 {
10270 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10271 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10272 }
10273 }
10274#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010275 pSession->ibss_join_pending = FALSE;
10276 csrRoamStopIbssJoinTimer(pMac, sessionId );
10277 // Set the roaming substate to 'stop Bss request'...
10278 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10279
10280 // attempt to stop the Bss (reason code is ignored...)
10281 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010282 if(!HAL_STATUS_SUCCESS(status))
10283 {
10284 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10285 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010286 return (status);
10287}
10288
Jeff Johnson295189b2012-06-20 16:38:30 -070010289//pNumChan is a caller allocated space with the sizeof pChannels
10290eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10291{
10292
10293 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10294 (tANI_U8 *)pChannels,
10295 pNumChan));
10296}
10297
Kiran4a17ebe2013-01-31 10:43:43 -080010298tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10299{
10300 tANI_U32 cfgLength = 0;
10301 tANI_U16 cfgId = 0;
10302 tPowerdBm maxTxPwr = 0;
10303 tANI_U8 *pCountryInfo = NULL;
10304 eHalStatus status;
10305 tANI_U8 count = 0;
10306 tANI_U8 firstChannel;
10307 tANI_U8 maxChannels;
10308
10309 if (CSR_IS_CHANNEL_5GHZ(channel))
10310 {
10311 cfgId = WNI_CFG_MAX_TX_POWER_5;
10312 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10313 }
10314 else if (CSR_IS_CHANNEL_24GHZ(channel))
10315 {
10316 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10317 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10318 }
10319 else
10320 return maxTxPwr;
10321
10322 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10323 if (status != eHAL_STATUS_SUCCESS)
10324 {
10325 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10326 FL("%s: palAllocateMemory() failed, status = %d"),
10327 __FUNCTION__, status);
10328 goto error;
10329 }
10330 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10331 if (status != eHAL_STATUS_SUCCESS)
10332 {
10333 goto error;
10334 }
10335 /* Identify the channel and maxtxpower */
10336 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10337 {
10338 firstChannel = pCountryInfo[count++];
10339 maxChannels = pCountryInfo[count++];
10340 maxTxPwr = pCountryInfo[count++];
10341
10342 if ((channel >= firstChannel) &&
10343 (channel < (firstChannel + maxChannels)))
10344 {
10345 break;
10346 }
10347 }
10348
10349error:
10350 if (NULL != pCountryInfo)
10351 palFreeMemory(pMac->hHdd, pCountryInfo);
10352
10353 return maxTxPwr;
10354}
10355
10356
Jeff Johnson295189b2012-06-20 16:38:30 -070010357tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10358{
10359 tANI_BOOLEAN fValid = FALSE;
10360 tANI_U32 idxValidChannels;
10361 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10362
10363 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10364 {
10365 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10366 {
10367 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10368 {
10369 fValid = TRUE;
10370 break;
10371 }
10372 }
10373 }
10374 pMac->roam.numValidChannels = len;
10375 return fValid;
10376}
10377
Jeff Johnson295189b2012-06-20 16:38:30 -070010378tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10379{
10380 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10381 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010382 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10383 {
10384 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10385 {
10386 fValid = eANI_BOOLEAN_TRUE;
10387 break;
10388 }
10389 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010390 return (fValid);
10391}
10392
Jeff Johnson295189b2012-06-20 16:38:30 -070010393//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010394 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010395{
Jeff Johnsone7245742012-09-05 17:12:55 -070010396 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010397 tANI_U8 centerChn;
10398 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010399 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10400 {
10401 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10402 }
10403 else
10404 {
10405 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10406 }
10407 //Figure what the other side's CB mode
10408 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10409 {
10410 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10411 {
10412 if(pIes->HTInfo.present)
10413 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010414 /* This is called during INFRA STA/CLIENT and should use the merged value of
10415 * supported channel width and recommended tx width as per standard
10416 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010417 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010418 pIes->HTCaps.supportedChannelWidthSet,
10419 pIes->HTInfo.recommendedTxWidthSet,
10420 pIes->HTInfo.secondaryChannelOffset);
10421
10422 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10423 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010424 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010425 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10426 switch (eRet) {
10427 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10428 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10429 break;
10430 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10431 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10432 break;
10433 case PHY_SINGLE_CHANNEL_CENTERED:
10434 default:
10435 centerChn = primaryChn;
10436 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010437 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010438 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010439 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010440 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070010441 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010442 }
10443 }
10444 }
10445 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010446 return eRet;
10447}
Jeff Johnson295189b2012-06-20 16:38:30 -070010448tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10449{
10450 tANI_BOOLEAN fFound = FALSE;
10451 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010452 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10453 {
10454 if( pCipherList->encryptionType[idx] == encryptionType )
10455 {
10456 fFound = TRUE;
10457 break;
10458 }
10459 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010460 return fFound;
10461}
Jeff Johnson295189b2012-06-20 16:38:30 -070010462tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10463{
10464 tANI_BOOLEAN fFound = FALSE;
10465 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010466 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10467 {
10468 if( pAuthList->authType[idx] == authType )
10469 {
10470 fFound = TRUE;
10471 break;
10472 }
10473 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010474 return fFound;
10475}
Jeff Johnson295189b2012-06-20 16:38:30 -070010476tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10477{
10478 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10479 tCsrScanResultFilter *pScanFilter = NULL;
10480 eHalStatus status = eHAL_STATUS_SUCCESS;
10481
10482 if(pProfile1 && pProfile2)
10483 {
10484 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10485 if(HAL_STATUS_SUCCESS(status))
10486 {
10487 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10488 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10489 if(HAL_STATUS_SUCCESS(status))
10490 {
10491 fCheck = eANI_BOOLEAN_FALSE;
10492 do
10493 {
10494 tANI_U32 i;
10495 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10496 {
10497 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10498 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10499 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10500 if ( fCheck ) break;
10501 }
10502 if(!fCheck)
10503 {
10504 break;
10505 }
10506 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10507 || pProfile2->BSSType != pProfile1->BSSType
10508 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10509 )
10510 {
10511 fCheck = eANI_BOOLEAN_FALSE;
10512 break;
10513 }
10514#ifdef WLAN_FEATURE_VOWIFI_11R
10515 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10516 {
10517 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10518 {
10519 fCheck = eANI_BOOLEAN_FALSE;
10520 break;
10521 }
10522 }
10523#endif
10524 //Match found
10525 fCheck = eANI_BOOLEAN_TRUE;
10526 }while(0);
10527 csrFreeScanFilter(pMac, pScanFilter);
10528 }
10529 palFreeMemory(pMac->hHdd, pScanFilter);
10530 }
10531 }
10532
10533 return (fCheck);
10534}
10535
Jeff Johnson295189b2012-06-20 16:38:30 -070010536tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10537{
10538 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10539 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010540 do
10541 {
10542 //Only check for static WEP
10543 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10544 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10545 {
10546 fCheck = eANI_BOOLEAN_TRUE;
10547 break;
10548 }
10549 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10550 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10551 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10552 {
10553 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10554 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10555 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10556 {
10557 break;
10558 }
10559 }
10560 if( i == CSR_MAX_NUM_KEY)
10561 {
10562 fCheck = eANI_BOOLEAN_TRUE;
10563 }
10564 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010565 return (fCheck);
10566}
10567
Jeff Johnson295189b2012-06-20 16:38:30 -070010568//IBSS
10569
Jeff Johnson295189b2012-06-20 16:38:30 -070010570tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10571{
10572 tANI_U8 channel = 0;
10573 tANI_U32 idx;
10574 tANI_U32 idxValidChannels;
10575 tANI_BOOLEAN fFound = FALSE;
10576 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10577
10578 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10579 {
10580 channel = pMac->roam.configParam.AdHocChannel5G;
10581 if(!csrRoamIsChannelValid(pMac, channel))
10582 {
10583 channel = 0;
10584 }
10585 }
10586 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10587 {
10588 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10589 {
10590 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10591 {
10592 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10593 {
10594 fFound = TRUE;
10595 channel = csrStartIbssChannels50[ idx ];
10596 }
10597 }
10598 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010599 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10600 if (!fFound)
10601 {
10602 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10603 {
10604 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10605 {
10606 channel = csrStartIbssChannels50[ idx ];
10607 break;
10608 }
10609 }
10610 }
10611 }//if
10612
10613 return( channel );
10614}
10615
Jeff Johnson295189b2012-06-20 16:38:30 -070010616tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10617{
10618 tANI_U8 channel = 1;
10619 tANI_U32 idx;
10620 tANI_U32 idxValidChannels;
10621 tANI_BOOLEAN fFound = FALSE;
10622 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10623
10624 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10625 {
10626 channel = pMac->roam.configParam.AdHocChannel24;
10627 if(!csrRoamIsChannelValid(pMac, channel))
10628 {
10629 channel = 0;
10630 }
10631 }
10632
10633 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10634 {
10635 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10636 {
10637 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10638 {
10639 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10640 {
10641 fFound = TRUE;
10642 channel = csrStartIbssChannels24[ idx ];
10643 }
10644 }
10645 }
10646 }
10647
10648 return( channel );
10649}
10650
Jeff Johnson295189b2012-06-20 16:38:30 -070010651static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10652 tCsrRoamStartBssParams *pParam )
10653{
10654 eCsrCfgDot11Mode cfgDot11Mode;
10655 eCsrBand eBand;
10656 tANI_U8 channel = 0;
10657 tSirNwType nwType;
10658 tANI_U8 operationChannel = 0;
10659
10660 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10661 {
10662 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10663 }
10664
Jeff Johnson295189b2012-06-20 16:38:30 -070010665 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010666
Jeff Johnson295189b2012-06-20 16:38:30 -070010667 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10668 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10669 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10670 )
10671 {
10672 /* This should never happen */
10673 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010674 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010675 pProfile->csrPersona);
10676 VOS_ASSERT(0);
10677 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010678 switch( cfgDot11Mode )
10679 {
10680 case eCSR_CFG_DOT11_MODE_11G:
10681 nwType = eSIR_11G_NW_TYPE;
10682 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010683 case eCSR_CFG_DOT11_MODE_11B:
10684 nwType = eSIR_11B_NW_TYPE;
10685 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010686 case eCSR_CFG_DOT11_MODE_11A:
10687 nwType = eSIR_11A_NW_TYPE;
10688 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010689 default:
10690 case eCSR_CFG_DOT11_MODE_11N:
10691 case eCSR_CFG_DOT11_MODE_TAURUS:
10692 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10693 if(eCSR_BAND_24 == eBand)
10694 {
10695 nwType = eSIR_11G_NW_TYPE;
10696 }
10697 else
10698 {
10699 nwType = eSIR_11A_NW_TYPE;
10700 }
10701 break;
10702 }
10703
10704 pParam->extendedRateSet.numRates = 0;
10705
10706 switch ( nwType )
10707 {
10708 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010709 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070010710 case eSIR_11A_NW_TYPE:
10711
10712 pParam->operationalRateSet.numRates = 8;
10713
10714 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10715 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10716 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10717 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10718 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10719 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10720 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10721 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10722
10723 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10724 {
10725 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10726 if( 0 == channel &&
10727 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10728 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10729 )
10730 {
10731 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10732 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10733 nwType = eSIR_11B_NW_TYPE;
10734 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10735 pParam->operationalRateSet.numRates = 4;
10736 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10737 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10738 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10739 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10740 }
10741 }
10742 else
10743 {
10744 channel = operationChannel;
10745 }
10746 break;
10747
10748 case eSIR_11B_NW_TYPE:
10749 pParam->operationalRateSet.numRates = 4;
10750 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10751 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10752 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10753 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010754 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10755 {
10756 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10757 }
10758 else
10759 {
10760 channel = operationChannel;
10761 }
10762
10763 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010764 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070010765 /* For P2P Client and P2P GO, disable 11b rates */
10766 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10767 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10768 )
10769 {
10770 pParam->operationalRateSet.numRates = 8;
10771
10772 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10773 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10774 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10775 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10776 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10777 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10778 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10779 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10780 }
10781 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010782 {
10783 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010784 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10785 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10786 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10787 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10788
10789 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010790 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10791 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10792 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10793 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10794 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10795 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10796 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10797 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10798 }
10799
10800 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10801 {
10802 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10803 }
10804 else
10805 {
10806 channel = operationChannel;
10807 }
10808
10809 break;
10810 }
10811 pParam->operationChn = channel;
10812 pParam->sirNwType = nwType;
10813}
10814
Jeff Johnson295189b2012-06-20 16:38:30 -070010815static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10816 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10817{
10818
10819 if( pParam )
10820 {
10821 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070010822 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010823 pParam->operationChn = pBssDesc->channelId;
10824 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
10825
10826 if( pIes )
10827 {
10828 if(pIes->SuppRates.present)
10829 {
10830 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
10831 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
10832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010833 smsLog(pMac, LOGE, FL("num_rates :%d is more than SIR_MAC_RATESET_EID_MAX, resetting to SIR_MAC_RATESET_EID_MAX"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010834 pIes->SuppRates.num_rates);
10835 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
10836 }
10837 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
10838 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
10839 }
10840 if( pIes->SSID.present )
10841 {
10842 pParam->ssId.length = pIes->SSID.num_ssid;
10843 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
10844 }
10845 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070010846 }
10847 else
10848 {
10849 pParam->ssId.length = 0;
10850 pParam->operationalRateSet.numRates = 0;
10851 }
10852 }
10853}
10854
Jeff Johnson295189b2012-06-20 16:38:30 -070010855static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
10856{
10857 tANI_U8 MaxRate = 0;
10858 tANI_U32 i;
10859 tANI_U8 *pRate;
10860
10861 pRate = pSirRateSet->rate;
10862 for ( i = 0; i < pSirRateSet->numRates; i++ )
10863 {
10864 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
10865 }
10866
10867 // Save the max rate in the connected state information...
10868
10869 // modify LastRates variable as well
10870
10871 return;
10872}
10873
Jeff Johnson295189b2012-06-20 16:38:30 -070010874//this function finds a valid secondary channel for channel bonding with "channel".
10875//Param: channel -- primary channel, caller must validate it
10876// cbChoice -- CB directory
10877//Return: if 0, no secondary channel is found. Otherwise a valid secondary channel.
10878static tANI_U8 csrRoamGetSecondaryChannel(tpAniSirGlobal pMac, tANI_U8 channel, eCsrCBChoice cbChoice)
10879{
10880 tANI_U8 chnUp = 0, chnDown = 0, chnRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010881 switch (cbChoice)
10882 {
10883 case eCSR_CB_OFF:
10884 chnUp = 0;
10885 chnDown = 0;
10886 break;
10887 case eCSR_CB_DOWN:
10888 chnUp = 0;
10889 chnDown = channel - CSR_CB_CHANNEL_GAP;
10890 break;
10891 case eCSR_CB_UP:
10892 chnUp = channel + CSR_CB_CHANNEL_GAP;
10893 chnDown = 0;
10894 break;
10895 case eCSR_CB_AUTO:
10896 //consider every other value means auto
10897 default:
10898 chnUp = channel + CSR_CB_CHANNEL_GAP;
10899 chnDown = channel - CSR_CB_CHANNEL_GAP;
10900 break;
10901 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010902 //if CB_UP or auto, try channel up first
10903 if(chnUp && CSR_IS_SAME_BAND_CHANNELS(chnUp, channel) && csrRoamIsChannelValid(pMac, chnUp))
10904 {
10905 //found a valid up channel for channel bonding
10906 //check whether the center channel is valid
10907 if(csrRoamIsValid40MhzChannel(pMac, channel + CSR_CB_CENTER_CHANNEL_OFFSET))
10908 {
10909 chnRet = chnUp;
10910 }
10911 }
10912 if(chnRet == 0 && chnDown && CSR_IS_SAME_BAND_CHANNELS(chnDown, channel) && csrRoamIsChannelValid(pMac, chnDown))
10913 {
10914 //found a valid down channel for channel bonding
10915 if(csrRoamIsValid40MhzChannel(pMac, channel - CSR_CB_CENTER_CHANNEL_OFFSET))
10916 {
10917 chnRet = chnDown;
10918 }
10919 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010920 return chnRet;
10921}
10922
Jeff Johnson295189b2012-06-20 16:38:30 -070010923eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
10924 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
10925{
10926 eHalStatus status = eHAL_STATUS_SUCCESS;
10927 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010928 // Set the roaming substate to 'Start BSS attempt'...
10929 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010930#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10931 //Need to figure out whether we need to log WDS???
10932 if( CSR_IS_IBSS( pProfile ) )
10933 {
10934 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010935 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10936 if(pIbssLog)
10937 {
10938 if(pBssDesc)
10939 {
10940 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
10941 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
10942 }
10943 else
10944 {
10945 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
10946 }
10947 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
10948 pParam->ssId.length);
10949 if(pProfile->ChannelInfo.numOfChannels == 0)
10950 {
10951 pIbssLog->channelSetting = AUTO_PICK;
10952 }
10953 else
10954 {
10955 pIbssLog->channelSetting = SPECIFIED;
10956 }
10957 pIbssLog->operatingChannel = pParam->operationChn;
10958 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10959 }
10960 }
10961#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10962 //Put RSN information in for Starting BSS
10963 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
10964 pParam->pRSNIE = pProfile->pRSNReqIE;
10965
Jeff Johnson295189b2012-06-20 16:38:30 -070010966 pParam->privacy = pProfile->privacy;
10967 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
10968 pParam->authType = pProfile->csr80211AuthType;
10969 pParam->beaconInterval = pProfile->beaconInterval;
10970 pParam->dtimPeriod = pProfile->dtimPeriod;
10971 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
10972 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
10973 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
10974 {
10975 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
10976 {
10977 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
10978 }
10979 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010980 pParam->protEnabled = pProfile->protEnabled;
10981 pParam->obssProtEnabled = pProfile->obssProtEnabled;
10982 pParam->ht_protection = pProfile->cfg_protection;
10983 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080010984
Jeff Johnson295189b2012-06-20 16:38:30 -070010985 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
10986 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070010987 pParam->bssPersona = pProfile->csrPersona;
10988 // When starting an IBSS, start on the channel from the Profile.
10989 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070010990 return (status);
10991}
10992
Jeff Johnson295189b2012-06-20 16:38:30 -070010993static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070010994 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010995{
10996 tANI_U8 Channel, SecondChn;
Jeff Johnsone7245742012-09-05 17:12:55 -070010997 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010998 eCsrCBChoice cbChoice;
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;
11005 }
11006
Jeff Johnson295189b2012-06-20 16:38:30 -070011007 if( pBssDesc )
11008 {
11009 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11010 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11011 //The following code has to be do after that.
11012 //For WDS station, use selfMac as the self BSSID
11013 if( CSR_IS_WDS_STA( pProfile ) )
11014 {
11015 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11016 }
11017 }
11018 else
11019 {
11020 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011021 //Use the first SSID
11022 if(pProfile->SSIDs.numOfSSIDs)
11023 {
11024 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
11025 }
11026 //For WDS station, use selfMac as the self BSSID
11027 if( CSR_IS_WDS_STA( pProfile ) )
11028 {
11029 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11030 }
11031 //Use the first BSSID
11032 else if( pProfile->BSSIDs.numOfBSSIDs )
11033 {
11034 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
11035 }
11036 else
11037 {
11038 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
11039 }
11040 }
11041 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011042 //Set operating channel in pProfile which will be used
11043 //in csrRoamSetBssConfigCfg() to determine channel bonding
11044 //mode and will be configured in CFG later
11045 pProfile->operationChannel = Channel;
11046
11047 if(Channel == 0)
11048 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011049 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011050 }
11051 else
11052 {
11053
11054 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Jeff Johnsone7245742012-09-05 17:12:55 -070011055 if (CSR_IS_INFRA_AP(pProfile))
11056 {
11057 if(CSR_IS_CHANNEL_24GHZ(Channel))
11058 {
11059 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11060 }
11061 else
11062 {
11063 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11064 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011065 smsLog(pMac, LOG1, "##softap cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011066 pBssConfig->cbMode = cbMode;
11067 pSession->bssParams.cbMode = cbMode;
11068 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011069
11070 if( CSR_IS_START_IBSS( pProfile ) )
11071 {
11072 //TBH: channel bonding is not supported for Libra
11073 if( pProfile->ChannelInfo.ChannelList && eCSR_OPERATING_CHANNEL_AUTO != pProfile->ChannelInfo.ChannelList[0] )
11074 {
11075 Channel = pProfile->ChannelInfo.ChannelList[0];
11076 cbChoice = pProfile->CBMode;
11077 }
11078 else {
11079 cbChoice = pMac->roam.configParam.cbChoice;
11080 }
11081 pSession->bssParams.operationChn = Channel;
11082 //make sure channel is valid
11083 if(!csrRoamIsChannelValid(pMac, Channel))
11084 {
11085 //set Channel to 0 to let lim know this is invalid
11086 //We still send this request down to lim even though we know the channel is wrong because
11087 //lim will response with error and hdd's eWNI_SME_START_BSS_RSP handler will roam other profile (if any)
11088 Channel = 0;
11089 pSession->bssParams.operationChn = 0;
11090 }
11091 else {
11092 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011093 if(CSR_IS_CHANNEL_24GHZ(Channel))
11094 {
11095 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11096 }
11097 else
11098 {
11099 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11100 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011101 //now we have a valid channel
11102 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11103 {
11104 //let's pick a secondard channel
11105 SecondChn = csrRoamGetSecondaryChannel(pMac, Channel, cbChoice);
Jeff Johnson295189b2012-06-20 16:38:30 -070011106 if(SecondChn > Channel)
11107 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011108 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070011109 }
11110 else if(SecondChn && SecondChn < Channel)
11111 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011112 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070011113 }
11114 else
11115 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011116 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011117 }
11118 pSession->bssParams.cbMode = cbMode;
11119 }
11120 else
11121 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011122 pSession->bssParams.cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011123 }
11124 }
11125 }
11126 }
11127}
11128
Jeff Johnson295189b2012-06-20 16:38:30 -070011129static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11130 tANI_BOOLEAN *pfSameIbss )
11131{
11132 eHalStatus status = eHAL_STATUS_SUCCESS;
11133 tANI_BOOLEAN fSameIbss = FALSE;
11134
11135 if ( csrIsConnStateIbss( pMac, sessionId ) )
11136 {
11137 // Check if any profile parameter has changed ? If any profile parameter
11138 // has changed then stop old BSS and start a new one with new parameters
11139 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11140 {
11141 fSameIbss = TRUE;
11142 }
11143 else
11144 {
11145 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11146 }
11147 }
11148 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11149 {
11150 // Disassociate from the connected Infrastructure network...
11151 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11152 }
11153 else
11154 {
11155 tBssConfigParam *pBssConfig;
11156
11157 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
11158 if(HAL_STATUS_SUCCESS(status))
11159 {
11160 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
11161 // there is no Bss description before we start an IBSS so we need to adopt
11162 // all Bss configuration parameters from the Profile.
11163 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11164 if(HAL_STATUS_SUCCESS(status))
11165 {
11166 //save dotMode
11167 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11168 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011169 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011170 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
11171 }
11172
11173 palFreeMemory(pMac->hHdd, pBssConfig);
11174 }//Allocate memory
11175 }
11176
11177 if(pfSameIbss)
11178 {
11179 *pfSameIbss = fSameIbss;
11180 }
11181 return( status );
11182}
11183
Jeff Johnson295189b2012-06-20 16:38:30 -070011184static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11185 tSirSmeNewBssInfo *pNewBss )
11186{
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;
11193 }
11194
Jeff Johnson295189b2012-06-20 16:38:30 -070011195 if( pNewBss )
11196 {
11197 // Set the operating channel.
11198 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11199 // move the BSSId from the BSS description into the connected state information.
11200 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
11201 &(pNewBss->bssId), sizeof( tCsrBssid ) );
11202 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011203 return;
11204}
11205
Jeff Johnson295189b2012-06-20 16:38:30 -070011206#ifdef FEATURE_WLAN_WAPI
11207eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11208 tANI_U32 numItems )
11209{
11210 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11211 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011212 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11213 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011214 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011215 return status;
11216 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011217 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011218 pSession = CSR_GET_SESSION( pMac, sessionId );
11219 if(numItems <= CSR_MAX_BKID_ALLOWED)
11220 {
11221 status = eHAL_STATUS_SUCCESS;
11222 //numItems may be 0 to clear the cache
11223 pSession->NumBkidCache = (tANI_U16)numItems;
11224 if(numItems && pBKIDCache)
11225 {
11226 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
11227 sizeof(tBkidCacheInfo) * numItems );
11228 }
11229 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011230 return (status);
11231}
Jeff Johnson295189b2012-06-20 16:38:30 -070011232eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11233 tBkidCacheInfo *pBkidCache)
11234{
11235 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11236 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011237 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011239 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011240 return status;
11241 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011242 pSession = CSR_GET_SESSION( pMac, sessionId );
11243 if(pNum && pBkidCache)
11244 {
11245 if(pSession->NumBkidCache == 0)
11246 {
11247 *pNum = 0;
11248 status = eHAL_STATUS_SUCCESS;
11249 }
11250 else if(*pNum >= pSession->NumBkidCache)
11251 {
11252 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11253 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011254 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011255 pSession->NumBkidCache);
11256 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11257 }
11258 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
11259 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
11260 *pNum = pSession->NumBkidCache;
11261 status = eHAL_STATUS_SUCCESS;
11262 }
11263 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011264 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011265}
Jeff Johnson295189b2012-06-20 16:38:30 -070011266tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11267{
11268 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011269}
11270#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011271eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11272 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11273{
11274 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11275 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011276
11277 if(!pSession)
11278 {
11279 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11280 return eHAL_STATUS_FAILURE;
11281 }
11282
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011283 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011284 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11285 {
11286#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11287 {
11288 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11289 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11290 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11291 secEvent.encryptionModeMulticast =
11292 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11293 secEvent.encryptionModeUnicast =
11294 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11295 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11296 secEvent.authMode =
11297 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11298 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11299 }
11300#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011301 status = eHAL_STATUS_SUCCESS;
11302 //numItems may be 0 to clear the cache
11303 pSession->NumPmkidCache = (tANI_U16)numItems;
11304 if(numItems && pPMKIDCache)
11305 {
11306 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11307 sizeof(tPmkidCacheInfo) * numItems );
11308 }
11309 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011310 return (status);
11311}
11312
Jeff Johnson295189b2012-06-20 16:38:30 -070011313tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11314{
11315 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11316}
11317
Jeff Johnson295189b2012-06-20 16:38:30 -070011318eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11319{
11320 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11321 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011322
11323 if(!pSession)
11324 {
11325 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11326 return eHAL_STATUS_FAILURE;
11327 }
11328
Jeff Johnson295189b2012-06-20 16:38:30 -070011329 if(pNum && pPmkidCache)
11330 {
11331 if(pSession->NumPmkidCache == 0)
11332 {
11333 *pNum = 0;
11334 status = eHAL_STATUS_SUCCESS;
11335 }
11336 else if(*pNum >= pSession->NumPmkidCache)
11337 {
11338 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11339 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011340 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011341 pSession->NumPmkidCache);
11342 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11343 }
11344 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11345 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11346 *pNum = pSession->NumPmkidCache;
11347 status = eHAL_STATUS_SUCCESS;
11348 }
11349 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011350 return (status);
11351}
11352
Jeff Johnson295189b2012-06-20 16:38:30 -070011353eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11354{
11355 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11356 tANI_U32 len;
11357 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011358
11359 if(!pSession)
11360 {
11361 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11362 return eHAL_STATUS_FAILURE;
11363 }
11364
Jeff Johnson295189b2012-06-20 16:38:30 -070011365 if(pLen)
11366 {
11367 len = *pLen;
11368 *pLen = pSession->nWpaRsnReqIeLength;
11369 if(pBuf)
11370 {
11371 if(len >= pSession->nWpaRsnReqIeLength)
11372 {
11373 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11374 }
11375 }
11376 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011377 return (status);
11378}
11379
Jeff Johnson295189b2012-06-20 16:38:30 -070011380eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11381{
11382 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11383 tANI_U32 len;
11384 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011385
11386 if(!pSession)
11387 {
11388 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11389 return eHAL_STATUS_FAILURE;
11390 }
11391
Jeff Johnson295189b2012-06-20 16:38:30 -070011392 if(pLen)
11393 {
11394 len = *pLen;
11395 *pLen = pSession->nWpaRsnRspIeLength;
11396 if(pBuf)
11397 {
11398 if(len >= pSession->nWpaRsnRspIeLength)
11399 {
11400 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11401 }
11402 }
11403 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011404 return (status);
11405}
Jeff Johnson295189b2012-06-20 16:38:30 -070011406#ifdef FEATURE_WLAN_WAPI
11407eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11408{
11409 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11410 tANI_U32 len;
11411 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011412
11413 if(!pSession)
11414 {
11415 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11416 return eHAL_STATUS_FAILURE;
11417 }
11418
Jeff Johnson295189b2012-06-20 16:38:30 -070011419 if(pLen)
11420 {
11421 len = *pLen;
11422 *pLen = pSession->nWapiReqIeLength;
11423 if(pBuf)
11424 {
11425 if(len >= pSession->nWapiReqIeLength)
11426 {
11427 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11428 }
11429 }
11430 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011431 return (status);
11432}
Jeff Johnson295189b2012-06-20 16:38:30 -070011433eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11434{
11435 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11436 tANI_U32 len;
11437 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011438
11439 if(!pSession)
11440 {
11441 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11442 return eHAL_STATUS_FAILURE;
11443 }
11444
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 if(pLen)
11446 {
11447 len = *pLen;
11448 *pLen = pSession->nWapiRspIeLength;
11449 if(pBuf)
11450 {
11451 if(len >= pSession->nWapiRspIeLength)
11452 {
11453 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11454 }
11455 }
11456 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011457 return (status);
11458}
11459#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011460eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11461{
11462 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11463 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011464
11465 if(!pSession)
11466 {
11467 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11468 return (retStatus);
11469 }
11470
Jeff Johnson295189b2012-06-20 16:38:30 -070011471 if(CSR_IS_ROAMING(pSession))
11472 {
11473 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11474 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11475 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011476 return (retStatus);
11477}
11478
Jeff Johnson295189b2012-06-20 16:38:30 -070011479//This function remove the connected BSS from te cached scan result
11480eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11481 tCsrRoamConnectedProfile *pConnProfile)
11482{
11483 eHalStatus status = eHAL_STATUS_FAILURE;
11484 tCsrScanResultFilter *pScanFilter = NULL;
11485 tListElem *pEntry;
11486 tCsrScanResult *pResult;
11487 tDot11fBeaconIEs *pIes;
11488 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011489 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11490 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11491 {
11492 do
11493 {
11494 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11495 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11496 if(!HAL_STATUS_SUCCESS(status)) break;
11497 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11498 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11499 if(!HAL_STATUS_SUCCESS(status)) break;
11500 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11501 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11502 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11503 {
11504 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11505 if(!HAL_STATUS_SUCCESS(status)) break;
11506 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11507 }
11508 pScanFilter->authType.numEntries = 1;
11509 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11510 pScanFilter->BSSType = pConnProfile->BSSType;
11511 pScanFilter->EncryptionType.numEntries = 1;
11512 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11513 pScanFilter->mcEncryptionType.numEntries = 1;
11514 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11515 //We ignore the channel for now, BSSID should be enough
11516 pScanFilter->ChannelInfo.numOfChannels = 0;
11517 //Also ignore the following fields
11518 pScanFilter->uapsd_mask = 0;
11519 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11520 pScanFilter->countryCode[0] = 0;
11521 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011522 csrLLLock(&pMac->scan.scanResultList);
11523 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11524 while( pEntry )
11525 {
11526 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11527 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11528 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11529 pScanFilter, NULL, NULL, NULL, &pIes);
11530 //Release the IEs allocated by csrMatchBSS is needed
11531 if( !pResult->Result.pvIes )
11532 {
11533 //need to free the IEs since it is allocated by csrMatchBSS
11534 palFreeMemory(pMac->hHdd, pIes);
11535 }
11536 if(fMatch)
11537 {
11538 //We found the one
11539 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11540 {
11541 //Free the memory
11542 csrFreeScanResultEntry( pMac, pResult );
11543 }
11544 break;
11545 }
11546 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11547 }//while
11548 csrLLUnlock(&pMac->scan.scanResultList);
11549 }while(0);
11550 if(pScanFilter)
11551 {
11552 csrFreeScanFilter(pMac, pScanFilter);
11553 palFreeMemory(pMac->hHdd, pScanFilter);
11554 }
11555 }
11556 return (status);
11557}
11558
Jeff Johnson295189b2012-06-20 16:38:30 -070011559//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011560eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11561{
11562 eHalStatus status = eHAL_STATUS_SUCCESS;
11563 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011564 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11565 {
11566 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11567 {
11568 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11569 {
11570 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011571 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011572 status = eHAL_STATUS_CSR_WRONG_STATE;
11573 break;
11574 }
11575 if( csrIsConnStateInfra( pMac, sessionId ) )
11576 {
11577 if( chnId &&
11578 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11579 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011580 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011581 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11582 status = eHAL_STATUS_CSR_WRONG_STATE;
11583 break;
11584 }
11585 }
11586 }
11587 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011588 return ( status );
11589}
11590
Jeff Johnson295189b2012-06-20 16:38:30 -070011591static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11592{
11593 eHalStatus status = eHAL_STATUS_SUCCESS;
11594 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11595 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011596
11597 if(!pSession)
11598 {
11599 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11600 return eHAL_STATUS_FAILURE;
11601 }
11602
Jeff Johnson295189b2012-06-20 16:38:30 -070011603 if ( csrIsConnStateIbss( pMac, sessionId ) )
11604 {
11605 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11606 }
11607 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11608 {
11609 // Disassociate from the connected Infrastructure network...
11610 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11611 }
11612 else
11613 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011614 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11615 //Otherwise we need to add code to handle the
11616 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11617 //send stop_bss to PE, before we can continue.
11618 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011619 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11620 /* Assume HDD provide bssid in profile */
11621 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11622 // there is no Bss description before we start an WDS so we need
11623 // to adopt all Bss configuration parameters from the Profile.
11624 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11625 if(HAL_STATUS_SUCCESS(status))
11626 {
11627 //Save profile for late use
11628 csrFreeRoamProfile( pMac, sessionId );
11629 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
11630 (void **)&pSession->pCurRoamProfile,
11631 sizeof(tCsrRoamProfile))))
11632 {
11633 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11634 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11635 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011636 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011637 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011638 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
11639 }
11640 }
11641
11642 return( status );
11643}
11644
Jeff Johnson295189b2012-06-20 16:38:30 -070011645////////////////////Mail box
11646
Jeff Johnson295189b2012-06-20 16:38:30 -070011647//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11648//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11649static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11650 tSirBssDescription *pBssDescription,
11651 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11652{
11653 tCsrChannelSet channelGroup;
11654 tSirMacCapabilityInfo *pAP_capabilityInfo;
11655 tAniBool fTmp;
11656 tANI_BOOLEAN found = FALSE;
11657 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011658 tANI_S8 pwrLimit = 0;
11659 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011660 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11661 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11662 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11663 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011664 // 802.11h
11665 //We can do this because it is in HOST CPU order for now.
11666 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080011667 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11668 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11669 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011670 fTmp = (tAniBool)pal_cpu_to_be32(1);
11671 }
11672 else
11673 fTmp = (tAniBool)0;
11674
11675 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11676 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11677 pBuf += sizeof(tAniBool);
11678 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011679 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011680 // This is required for 11k test VoWiFi Ent: Test 2.
11681 // We need the power capabilities for Assoc Req.
11682 // This macro is provided by the halPhyCfg.h. We pick our
11683 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080011684 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11685 if (0 != pwrLimit)
11686 {
11687 *pBuf++ = pwrLimit;
11688 }
11689 else
11690 {
11691 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11692 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011693 size = sizeof(pMac->roam.validChannelList);
11694 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11695 {
11696 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11697 for ( i = 0; i < size; i++)
11698 {
11699 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11700
11701 }
11702 }
11703 else
11704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011705 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011706 *pBuf++ = 0; //tSirSupChnl->numChnl
11707 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011708 //Check whether it is ok to enter UAPSD
11709#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11710 if( btcIsReadyForUapsd(pMac) )
11711#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11712 {
11713 *pBuf++ = uapsdMask;
11714 }
11715#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11716 else
11717 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011718 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070011719 *pBuf++ = 0;
11720 }
11721#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11722
Jeff Johnson295189b2012-06-20 16:38:30 -070011723 // move the entire BssDescription into the join request.
11724 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11725 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011726 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11727}
11728
Jeff Johnson295189b2012-06-20 16:38:30 -070011729/*
11730 * The communication between HDD and LIM is thru mailbox (MB).
11731 * Both sides will access the data structure "tSirSmeJoinReq".
11732 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11733 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11734 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11735 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11736 */
11737eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011738 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011739{
11740 eHalStatus status = eHAL_STATUS_SUCCESS;
11741 tSirSmeJoinReq *pMsg;
11742 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011743 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011744 tANI_U16 msgLen, wTmp, ieLen;
11745 tSirMacRateSet OpRateSet;
11746 tSirMacRateSet ExRateSet;
11747 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11748 tANI_U32 dwTmp;
11749 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Jeff Johnson32d95a32012-09-10 13:15:23 -070011750
11751 if(!pSession)
11752 {
11753 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11754 return eHAL_STATUS_FAILURE;
11755 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011756 /* To satisfy klockworks */
11757 if (NULL == pBssDescription)
11758 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011759 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011760 return eHAL_STATUS_FAILURE;
11761 }
11762
Jeff Johnson295189b2012-06-20 16:38:30 -070011763 do {
11764 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11765 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070011766 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070011767 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11768 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11769 // IE fields, but the length field in the bssDescription needs to be interpreted to
11770 // determine length of the IE fields.
11771 //
11772 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11773 // add in the length from the bssDescription (then add the size of the 'length' field
11774 // itself because that is NOT included in the length field).
11775 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11776 pBssDescription->length + sizeof( pBssDescription->length ) +
11777 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 -070011778 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11779 if ( !HAL_STATUS_SUCCESS(status) ) break;
11780 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011781 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011782 pMsg->length = pal_cpu_to_be16(msgLen);
11783 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011784 // sessionId
11785 *pBuf = (tANI_U8)sessionId;
11786 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011787 // transactionId
11788 *pBuf = 0;
11789 *( pBuf + 1 ) = 0;
11790 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011791 // ssId
11792 if( pIes->SSID.present && pIes->SSID.num_ssid )
11793 {
11794 // ssId len
11795 *pBuf = pIes->SSID.num_ssid;
11796 pBuf++;
11797 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11798 pBuf += pIes->SSID.num_ssid;
11799 }
11800 else
11801 {
11802 *pBuf = 0;
11803 pBuf++;
11804 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011805 // selfMacAddr
11806 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11807 pBuf += sizeof(tSirMacAddr);
11808 // bsstype
11809 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11810 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11811 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11812 pBuf += sizeof(tSirBssType);
11813 // dot11mode
11814 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11815 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011816 //Persona
11817 *pBuf = (tANI_U8)pProfile->csrPersona;
11818 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011819 //CBMode
11820 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11821 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011822
11823 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011824 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11825
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 // uapsdPerAcBitmask
11827 *pBuf = pProfile->uapsd_mask;
11828 pBuf++;
11829
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011830
11831
Jeff Johnson295189b2012-06-20 16:38:30 -070011832 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011833 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011834 {
11835 // OperationalRateSet
11836 if (OpRateSet.numRates) {
11837 *pBuf++ = OpRateSet.numRates;
11838 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11839 pBuf += OpRateSet.numRates;
11840 } else *pBuf++ = 0;
11841 // ExtendedRateSet
11842 if (ExRateSet.numRates) {
11843 *pBuf++ = ExRateSet.numRates;
11844 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11845 pBuf += ExRateSet.numRates;
11846 } else *pBuf++ = 0;
11847 }
11848 else
11849 {
11850 *pBuf++ = 0;
11851 *pBuf++ = 0;
11852 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011853 // rsnIE
11854 if ( csrIsProfileWpa( pProfile ) )
11855 {
11856 // Insert the Wpa IE into the join request
11857 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11858 (tCsrWpaIe *)( wpaRsnIE ) );
11859 }
11860 else if( csrIsProfileRSN( pProfile ) )
11861 {
11862 // Insert the RSN IE into the join request
11863 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11864 (tCsrRSNIe *)( wpaRsnIE ) );
11865 }
11866#ifdef FEATURE_WLAN_WAPI
11867 else if( csrIsProfileWapi( pProfile ) )
11868 {
11869 // Insert the WAPI IE into the join request
11870 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11871 (tCsrWapiIe *)( wpaRsnIE ) );
11872 }
11873#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011874 else
11875 {
11876 ieLen = 0;
11877 }
11878 //remember the IE for future use
11879 if( ieLen )
11880 {
11881 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11882 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011883 smsLog(pMac, LOGE, FL(" WPA RSN IE length :%d is more than DOT11F_IE_RSN_MAX_LEN, resetting to %d"), ieLen, DOT11F_IE_RSN_MAX_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070011884 ieLen = DOT11F_IE_RSN_MAX_LEN;
11885 }
11886#ifdef FEATURE_WLAN_WAPI
11887 if( csrIsProfileWapi( pProfile ) )
11888 {
11889 //Check whether we need to allocate more memory
11890 if(ieLen > pSession->nWapiReqIeLength)
11891 {
11892 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11893 {
11894 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11895 }
11896 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11897 if(!HAL_STATUS_SUCCESS(status)) break;
11898 }
11899 pSession->nWapiReqIeLength = ieLen;
11900 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11901 wTmp = pal_cpu_to_be16( ieLen );
11902 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11903 pBuf += sizeof(tANI_U16);
11904 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11905 pBuf += ieLen;
11906 }
11907 else//should be WPA/WPA2 otherwise
11908#endif /* FEATURE_WLAN_WAPI */
11909 {
11910 //Check whether we need to allocate more memory
11911 if(ieLen > pSession->nWpaRsnReqIeLength)
11912 {
11913 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11914 {
11915 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11916 }
11917 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
11918 if(!HAL_STATUS_SUCCESS(status)) break;
11919 }
11920 pSession->nWpaRsnReqIeLength = ieLen;
11921 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
11922 wTmp = pal_cpu_to_be16( ieLen );
11923 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11924 pBuf += sizeof(tANI_U16);
11925 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11926 pBuf += ieLen;
11927 }
11928 }
11929 else
11930 {
11931 //free whatever old info
11932 pSession->nWpaRsnReqIeLength = 0;
11933 if(pSession->pWpaRsnReqIE)
11934 {
11935 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11936 pSession->pWpaRsnReqIE = NULL;
11937 }
11938#ifdef FEATURE_WLAN_WAPI
11939 pSession->nWapiReqIeLength = 0;
11940 if(pSession->pWapiReqIE)
11941 {
11942 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11943 pSession->pWapiReqIE = NULL;
11944 }
11945#endif /* FEATURE_WLAN_WAPI */
11946 //length is two bytes
11947 *pBuf = 0;
11948 *(pBuf + 1) = 0;
11949 pBuf += 2;
11950 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011951#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011952 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011953 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011954 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070011955 //length is two bytes
11956 *pBuf = 0;
11957 *(pBuf + 1) = 0;
11958 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011959 }
11960 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011961 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011962 // cckmIE
11963 if( csrIsProfileCCX( pProfile ) )
11964 {
11965 // Insert the CCKM IE into the join request
11966 ieLen = csrConstructCcxCckmIe( pMac,
11967 pSession,
11968 pProfile,
11969 pBssDescription,
11970 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070011971 pSession->nWpaRsnReqIeLength,
11972 (void *)( wpaRsnIE ) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011973 }
11974 else
11975 {
11976 ieLen = 0;
11977 }
11978 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
11979 if( ieLen )
11980 {
11981 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
11982 wTmp = pal_cpu_to_be16( ieLen );
11983 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11984 pBuf += sizeof(tANI_U16);
11985 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11986 pBuf += ieLen;
11987 }
11988 else
11989 {
11990 //Indicate you have no CCKM IE
11991 //length is two bytes
11992 *pBuf = 0;
11993 *(pBuf + 1) = 0;
11994 pBuf += 2;
11995 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011996 }
11997#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070011998 // addIEScan
11999 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
12000 {
12001 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012002 if(ieLen > pSession->nAddIEScanLength)
12003 {
12004 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
12005 {
12006 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12007 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012008 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012009 (void **)&pSession->pAddIEScan, ieLen);
12010 if(!HAL_STATUS_SUCCESS(status)) break;
12011 }
12012 pSession->nAddIEScanLength = ieLen;
12013 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
12014 pProfile->pAddIEScan, ieLen);
12015 wTmp = pal_cpu_to_be16( ieLen );
12016 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12017 pBuf += sizeof(tANI_U16);
12018 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
12019 pBuf += ieLen;
12020 }
12021 else
12022 {
12023 pSession->nAddIEScanLength = 0;
12024 if(pSession->pAddIEScan)
12025 {
12026 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12027 pSession->pAddIEScan = NULL;
12028 }
12029 *pBuf = 0;
12030 *(pBuf + 1) = 0;
12031 pBuf += 2;
12032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012033 // addIEAssoc
12034 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12035 {
12036 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012037 if(ieLen > pSession->nAddIEAssocLength)
12038 {
12039 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
12040 {
12041 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12042 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012043 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012044 (void **)&pSession->pAddIEAssoc, ieLen);
12045 if(!HAL_STATUS_SUCCESS(status)) break;
12046 }
12047 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012048 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070012049 pProfile->pAddIEAssoc, ieLen);
12050 wTmp = pal_cpu_to_be16( ieLen );
12051 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12052 pBuf += sizeof(tANI_U16);
12053 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
12054 pBuf += ieLen;
12055 }
12056 else
12057 {
12058 pSession->nAddIEAssocLength = 0;
12059 if(pSession->pAddIEAssoc)
12060 {
12061 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12062 pSession->pAddIEAssoc = NULL;
12063 }
12064 *pBuf = 0;
12065 *(pBuf + 1) = 0;
12066 pBuf += 2;
12067 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012068
12069 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012070 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012071 //Unmask any AC in reassoc that is ACM-set
12072 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12073 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012074 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012075 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12076 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012077#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012078 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012079#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012080 uapsd_mask &= ~(acm_mask);
12081 }
12082 else
12083 {
12084 uapsd_mask = 0;
12085 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012086 }
12087 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012088
Jeff Johnson295189b2012-06-20 16:38:30 -070012089 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
12090 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012091 pBuf += sizeof(tANI_U32);
12092
Jeff Johnson295189b2012-06-20 16:38:30 -070012093 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
12094 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012095 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012096#ifdef WLAN_FEATURE_11W
12097 //MgmtEncryption
12098 if (pProfile->MFPEnabled)
12099 {
12100 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12101 }
12102 else
12103 {
12104 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12105 }
12106 palCopyMemory(pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32));
12107 pBuf += sizeof(tANI_U32);
12108#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012109#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012110 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012111 if (csrIsProfile11r( pProfile )
12112#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012113 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12114 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012115#endif
12116 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012117 {
12118 // is11Rconnection;
12119 dwTmp = pal_cpu_to_be32(TRUE);
12120 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12121 pBuf += sizeof(tAniBool);
12122 }
12123 else
12124 {
12125 // is11Rconnection;
12126 dwTmp = pal_cpu_to_be32(FALSE);
12127 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12128 pBuf += sizeof(tAniBool);
12129 }
12130#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012131#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012132 /* A profile can not be both CCX and 11R. But an 802.11R AP
12133 * may be advertising support for CCX as well. So if we are
12134 * associating Open or explicitly CCX then we will get CCX.
12135 * If we are associating explictly 11R only then we will get
12136 * 11R.
12137 */
12138 if ((csrIsProfileCCX(pProfile) ||
12139 ((pIes->CCXVersion.present)
12140 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012141 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12142 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12143 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012144#ifdef WLAN_FEATURE_11W
12145 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12146#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012147 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012148 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12149 {
12150 // isCCXconnection;
12151 dwTmp = pal_cpu_to_be32(TRUE);
12152 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12153 pBuf += sizeof(tAniBool);
12154 }
12155 else
12156 {
12157 //isCCXconnection;
12158 dwTmp = pal_cpu_to_be32(FALSE);
12159 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12160 pBuf += sizeof(tAniBool);
12161 }
12162
12163 if (eWNI_SME_JOIN_REQ == messageType)
12164 {
12165 tCCXTspecInfo ccxTspec;
12166 // CCX-Tspec IEs in the ASSOC request is presently not supported
12167 // so nullify the TSPEC parameters
12168 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12169 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12170 pBuf += sizeof(tCCXTspecInfo);
12171 }
12172 else if (eWNI_SME_REASSOC_REQ == messageType)
12173 {
12174 if ((csrIsProfileCCX(pProfile) ||
12175 ((pIes->CCXVersion.present)
12176 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012177 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12178 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12179 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012180#ifdef WLAN_FEATURE_11W
12181 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12182#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012183 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012184 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012185 {
12186 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012187 // CCX Tspec information
12188 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12189 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12190 *pBuf = ccxTspec.numTspecs;
12191 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012192 // Copy the TSPEC information only if present
12193 if (ccxTspec.numTspecs) {
12194 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
12195 }
12196 pBuf += sizeof(ccxTspec.tspec);
12197 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012198 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012199 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012200 tCCXTspecInfo ccxTspec;
12201 // CCX-Tspec IEs in the ASSOC request is presently not supported
12202 // so nullify the TSPEC parameters
12203 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12204 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12205 pBuf += sizeof(tCCXTspecInfo);
12206 }
12207 }
12208#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012209#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012210 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012211 if (pMac->roam.configParam.isFastTransitionEnabled
12212#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012213 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012214#endif
12215 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012216 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012217 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012218 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012219 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012220 }
12221 else
12222 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012223 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012224 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012225 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012226 }
12227#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012228#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012229 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012230 {
12231 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012232 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012233 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012234 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012235 }
12236 else
12237 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012238 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012239 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012240 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012241 }
12242#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012243
12244 // txLdpcIniFeatureEnabled
12245 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12246 pBuf++;
12247
Kiran4a17ebe2013-01-31 10:43:43 -080012248 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12249 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12250 {
12251 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12252 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12253 csrApplyPower2Current(pMac);
12254 }
12255
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012256#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012257 // txBFIniFeatureEnabled
12258 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12259 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012260
12261 // txBFCsnValue
12262 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12263 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012264#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012265 //BssDesc
12266 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12267 (tANI_U8)pProfile->uapsd_mask);
12268 status = palSendMBMessage(pMac->hHdd, pMsg );
12269 if(!HAL_STATUS_SUCCESS(status))
12270 {
12271 break;
12272 }
12273 else
12274 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012275#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012276 if (eWNI_SME_JOIN_REQ == messageType)
12277 {
12278 //Tush-QoS: notify QoS module that join happening
12279 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12280 }
12281 else if (eWNI_SME_REASSOC_REQ == messageType)
12282 {
12283 //Tush-QoS: notify QoS module that reassoc happening
12284 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12285 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012286#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012287 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012288 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012289 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012290}
12291
Jeff Johnson295189b2012-06-20 16:38:30 -070012292//
12293eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12294{
12295 eHalStatus status = eHAL_STATUS_SUCCESS;
12296 tSirSmeDisassocReq *pMsg;
12297 tANI_U8 *pBuf;
12298 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012299 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12300 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12301 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012302 do {
12303 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12304 if ( !HAL_STATUS_SUCCESS(status) ) break;
12305 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12306 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12307 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012308 pBuf = &pMsg->sessionId;
12309 // sessionId
12310 *pBuf++ = (tANI_U8)sessionId;
12311 // transactionId
12312 *pBuf = 0;
12313 *( pBuf + 1 ) = 0;
12314 pBuf += sizeof(tANI_U16);
12315
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012316 if ( (pSession->pCurRoamProfile != NULL) &&
12317 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12318 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012319 {
12320 // Set the bssid address before sending the message to LIM
12321 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12322 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012323 // Set the peer MAC address before sending the message to LIM
12324 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12325 pBuf = pBuf + sizeof ( tSirMacAddr );
12326 }
12327 else
12328 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012329 // Set the peer MAC address before sending the message to LIM
12330 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12331 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012332 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12333 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012334 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 if(!HAL_STATUS_SUCCESS(status))
12336 {
12337 palFreeMemory(pMac->hHdd, pMsg);
12338 break;
12339 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012340 // reasonCode
12341 wTmp = pal_cpu_to_be16(reasonCode);
12342 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12343 if(!HAL_STATUS_SUCCESS(status))
12344 {
12345 palFreeMemory(pMac->hHdd, pMsg);
12346 break;
12347 }
12348 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012349 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12350 Here we should not send the disassoc over the air to the AP */
12351 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12352#ifdef WLAN_FEATURE_VOWIFI_11R
12353 && csrRoamIs11rAssoc(pMac)
12354#endif
12355 )
12356 {
12357 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12358 }
12359 pBuf += sizeof(tANI_U8);
12360 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012361 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012362 return( status );
12363}
Jeff Johnson295189b2012-06-20 16:38:30 -070012364eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12365{
12366 eHalStatus status = eHAL_STATUS_SUCCESS;
12367 tSirSmeTkipCntrMeasReq *pMsg;
12368 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012369 do
12370 {
12371 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12372 if ( !HAL_STATUS_SUCCESS(status) ) break;
12373 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12374 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12375 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012376 pBuf = &pMsg->sessionId;
12377 // sessionId
12378 *pBuf++ = (tANI_U8)sessionId;
12379 // transactionId
12380 *pBuf = 0;
12381 *( pBuf + 1 ) = 0;
12382 pBuf += sizeof(tANI_U16);
12383 // bssid
12384 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12385 pBuf = pBuf + sizeof ( tSirMacAddr );
12386 // bEnable
12387 *pBuf = (tANI_BOOLEAN)bEnable;
12388 if(!HAL_STATUS_SUCCESS(status))
12389 {
12390 palFreeMemory(pMac->hHdd, pMsg);
12391 break;
12392 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012393 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012395 return( status );
12396}
Jeff Johnson295189b2012-06-20 16:38:30 -070012397eHalStatus
12398csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12399 VOS_MODULE_ID modId, tSirMacAddr bssId,
12400 void *pUsrContext, void *pfnSapEventCallback,
12401 tANI_U8 *pAssocStasBuf )
12402{
12403 eHalStatus status = eHAL_STATUS_SUCCESS;
12404 tSirSmeGetAssocSTAsReq *pMsg;
12405 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12406 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012407 do
12408 {
12409 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12410 if (!HAL_STATUS_SUCCESS(status)) break;
12411 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12412 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012413 pBuf = (tANI_U8 *)&pMsg->bssId;
12414 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012415 // bssId
12416 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12417 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012418 // modId
12419 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12420 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12421 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012422 // pUsrContext
12423 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12424 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12425 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012426 // pfnSapEventCallback
12427 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12428 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12429 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012430 // pAssocStasBuf
12431 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12432 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12433 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012434 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012435 status = palSendMBMessage( pMac->hHdd, pMsg );
12436 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012437 return( status );
12438 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012439eHalStatus
12440csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12441 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12442 {
12443 eHalStatus status = eHAL_STATUS_SUCCESS;
12444 tSirSmeGetWPSPBCSessionsReq *pMsg;
12445 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12446 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012447 do
12448 {
12449 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12450 if (!HAL_STATUS_SUCCESS(status)) break;
12451 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12452 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012453 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
12454 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012455 // pUsrContext
12456 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12457 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12458 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012459 // pSapEventCallback
12460 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12461 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12462 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 // bssId
12464 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12465 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012466 // MAC Address of STA in WPS session
12467 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12468 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012469 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012470 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012471 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012472 return( status );
12473}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012474
12475eHalStatus
12476csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12477{
12478 tpSirChangeBIParams pMsg;
12479 tANI_U16 len = 0;
12480 eHalStatus status = eHAL_STATUS_SUCCESS;
12481 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12482
12483 if(!pSession)
12484 {
12485 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12486 return eHAL_STATUS_FAILURE;
12487 }
12488
12489 //NO need to update the Beacon Params if update beacon parameter flag is not set
12490 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12491 return eHAL_STATUS_SUCCESS;
12492
12493 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12494
12495 /* Create the message and send to lim */
12496 len = sizeof(tSirChangeBIParams);
12497 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12498 if(HAL_STATUS_SUCCESS(status))
12499 {
12500 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12501 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12502 pMsg->length = len;
12503
12504 // bssId
12505 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012506 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= %02x-%02x-%02x-%02x-%02x-%02x "),
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012507 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12508 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12509 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012510 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012511 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12512 status = palSendMBMessage(pMac->hHdd, pMsg);
12513 }
12514 return status;
12515}
12516
Jeff Johnson295189b2012-06-20 16:38:30 -070012517eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12518{
12519 eHalStatus status = eHAL_STATUS_SUCCESS;
12520 tSirSmeDeauthReq *pMsg;
12521 tANI_U8 *pBuf;
12522 tANI_U16 wTmp;
12523 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12524 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12525 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012526 do {
12527 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12528 if ( !HAL_STATUS_SUCCESS(status) ) break;
12529 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12530 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12531 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12532 //sessionId
12533 pBuf = &pMsg->sessionId;
12534 *pBuf++ = (tANI_U8)sessionId;
12535
12536 //tansactionId
12537 *pBuf = 0;
12538 *(pBuf + 1 ) = 0;
12539 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012540 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012541 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012542 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12543 // Set the BSSID before sending the message to LIM
12544 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12545 pBuf = pBuf + sizeof(tSirMacAddr);
12546 }
12547 else
12548 {
12549 // Set the BSSID before sending the message to LIM
12550 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12551 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012552 }
12553 if(!HAL_STATUS_SUCCESS(status))
12554 {
12555 palFreeMemory(pMac->hHdd, pMsg);
12556 break;
12557 }
12558 // Set the peer MAC address before sending the message to LIM
12559 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12560 pBuf = pBuf + sizeof(tSirMacAddr);
12561 if(!HAL_STATUS_SUCCESS(status))
12562 {
12563 palFreeMemory(pMac->hHdd, pMsg);
12564 break;
12565 }
12566 wTmp = pal_cpu_to_be16(reasonCode);
12567 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12568 if(!HAL_STATUS_SUCCESS(status))
12569 {
12570 palFreeMemory(pMac->hHdd, pMsg);
12571 break;
12572 }
12573 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012575 return( status );
12576}
12577
Jeff Johnson295189b2012-06-20 16:38:30 -070012578eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12579{
12580 eHalStatus status = eHAL_STATUS_SUCCESS;
12581 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012582 do {
12583 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12584 if ( !HAL_STATUS_SUCCESS(status) ) break;
12585 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12586 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12587 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12588 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12589 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12590 if(!HAL_STATUS_SUCCESS(status))
12591 {
12592 palFreeMemory(pMac->hHdd, pMsg);
12593 break;
12594 }
12595//To test reconn
12596 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12597 if(!HAL_STATUS_SUCCESS(status))
12598 {
12599 palFreeMemory(pMac->hHdd, pMsg);
12600 break;
12601 }
12602//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012603 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012604 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 return( status );
12606}
12607
Jeff Johnson295189b2012-06-20 16:38:30 -070012608eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12609{
12610 eHalStatus status = eHAL_STATUS_SUCCESS;
12611 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012612 do {
12613 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12614 if ( !HAL_STATUS_SUCCESS(status) ) break;
12615 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12616 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12617 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12618 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12619 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12620 if(!HAL_STATUS_SUCCESS(status))
12621 {
12622 palFreeMemory(pMac->hHdd, pMsg);
12623 break;
12624 }
12625 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12626 if(!HAL_STATUS_SUCCESS(status))
12627 {
12628 palFreeMemory(pMac->hHdd, pMsg);
12629 break;
12630 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012631 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012632 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012633 return( status );
12634}
Jeff Johnson295189b2012-06-20 16:38:30 -070012635eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12636{
12637 eHalStatus status = eHAL_STATUS_SUCCESS;
12638 tSirSmeAssocCnf *pMsg;
12639 tANI_U8 *pBuf;
12640 tSirResultCodes statusCode;
12641 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012642 do {
12643 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12644 if ( !HAL_STATUS_SUCCESS(status) ) break;
12645 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12646 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12647 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012648 pBuf = (tANI_U8 *)&pMsg->statusCode;
12649 if(HAL_STATUS_SUCCESS(Halstatus))
12650 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12651 else
12652 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12653 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12654 pBuf += sizeof(tSirResultCodes);
12655 // bssId
12656 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12657 pBuf += sizeof (tSirMacAddr);
12658 // peerMacAddr
12659 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12660 pBuf += sizeof (tSirMacAddr);
12661 // aid
12662 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12663 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12664 pBuf += sizeof (tANI_U16);
12665 // alternateBssId
12666 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12667 pBuf += sizeof (tSirMacAddr);
12668 // alternateChannelId
12669 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012670 status = palSendMBMessage( pMac->hHdd, pMsg );
12671 if(!HAL_STATUS_SUCCESS(status))
12672 {
12673 //pMsg is freed by palSendMBMessage
12674 break;
12675 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012676 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012677 return( status );
12678}
Jeff Johnson295189b2012-06-20 16:38:30 -070012679eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12680 tpSirSmeAssocInd pAssocInd,
12681 eHalStatus Halstatus,
12682 tANI_U8 sessionId)
12683{
12684 tSirMsgQ msgQ;
12685 eHalStatus status = eHAL_STATUS_SUCCESS;
12686 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12687 tANI_U8 *pBuf;
12688 tSirResultCodes statusCode;
12689 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012690 do {
12691 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12692 if ( !HAL_STATUS_SUCCESS(status) ) break;
12693 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012694
Jeff Johnson295189b2012-06-20 16:38:30 -070012695 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12696 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12697
12698 pMsg->sessionId = sessionId;
12699
12700 pBuf = (tANI_U8 *)&pMsg->statusCode;
12701 if(HAL_STATUS_SUCCESS(Halstatus))
12702 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12703 else
12704 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12705 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12706 pBuf += sizeof(tSirResultCodes);
12707 // bssId
12708 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12709 pBuf += sizeof (tSirMacAddr);
12710 // peerMacAddr
12711 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12712 pBuf += sizeof (tSirMacAddr);
12713 // StaId
12714 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12715 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12716 pBuf += sizeof (tANI_U16);
12717 // alternateBssId
12718 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12719 pBuf += sizeof (tSirMacAddr);
12720 // alternateChannelId
12721 *pBuf = 11;
12722 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012723 // Instead of copying roam Info, we just copy only WmmEnabled , RsnIE information
12724 //Wmm
12725 *pBuf = pAssocInd->wmmEnabledSta;
12726 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012727 //RSN IE
12728 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12729 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012730 //Additional IE
12731 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12732 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012733 //reassocReq
12734 *pBuf = pAssocInd->reassocReq;
12735 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012736 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12737 msgQ.bodyptr = pMsg;
12738 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012739 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012740 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 return( status );
12742}
Jeff Johnson295189b2012-06-20 16:38:30 -070012743
Jeff Johnson295189b2012-06-20 16:38:30 -070012744eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId ,
12745 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12746 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12747 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12748 tANI_U8 *pKeyRsc )
12749{
12750 tSirSmeSetContextReq *pMsg;
12751 tANI_U16 msgLen;
12752 eHalStatus status = eHAL_STATUS_FAILURE;
12753 tAniEdType tmpEdType;
12754 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053012755 tANI_U8 *pBuf = NULL;
12756 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012757 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012758 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012759 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012760 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12761 // key set. Since we only support upto one key, we always allocate memory for 1 key
12762 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12763 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12764 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12765 ( sizeof( pMsg->keyMaterial.key ) );
12766
12767 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12768 if ( !HAL_STATUS_SUCCESS(status) ) break;
12769 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12770 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12771 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012772 //sessionId
12773 pBuf = &pMsg->sessionId;
12774 *pBuf = (tANI_U8)sessionId;
12775 pBuf++;
12776 // transactionId
12777 *pBuf = 0;
12778 *(pBuf + 1) = 0;
12779 pBuf += sizeof(tANI_U16);
12780 // peerMacAddr
12781 palCopyMemory( pMac->hHdd, pBuf,
12782 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12783
12784 pBuf += sizeof(tSirMacAddr);
12785
12786 // bssId
12787 palCopyMemory( pMac->hHdd, pBuf,
12788 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12789
12790 pBuf += sizeof(tSirMacAddr);
12791
12792 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012793 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12794 // in the tSirKeyMaterial keyMaterial; field).
12795 //
12796 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12797 // shorter than this max size. Is LIM interpreting this ok ?
12798 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 -070012799 // set pMsg->keyMaterial.edType
12800 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12801 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12802 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012803 // set the pMsg->keyMaterial.numKeys field
12804 *p = numKeys;
12805 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012806 // set pSirKey->keyId = keyId;
12807 *p = keyId;
12808 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012809 // set pSirKey->unicast = (tANI_U8)fUnicast;
12810 *p = (tANI_U8)fUnicast;
12811 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012812 // set pSirKey->keyDirection = aniKeyDirection;
12813 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12814 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12815 p += sizeof(tAniKeyDirection);
12816 // pSirKey->keyRsc = ;;
12817 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12818 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012819 // set pSirKey->paeRole
12820 *p = paeRole; // 0 is Supplicant
12821 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012822 // set pSirKey->keyLength = keyLength;
12823 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012824 if ( keyLength && pKey )
12825 {
12826 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12827 if(keyLength == 16)
12828 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012829 smsLog(pMac, LOG1, " SME Set keyIdx (%d) encType(%d) key = %02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X",
Jeff Johnson295189b2012-06-20 16:38:30 -070012830 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12831 pKey[5], pKey[6], pKey[7], pKey[8],
12832 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12833 }
12834 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012835 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012836 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012837 return( status );
12838}
12839
Jeff Johnson295189b2012-06-20 16:38:30 -070012840eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12841 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12842{
12843 eHalStatus status;
12844 tSirSmeStartBssReq *pMsg;
12845 tANI_U8 *pBuf = NULL;
12846 tANI_U8 *wTmpBuf = NULL;
12847 tANI_U16 msgLen, wTmp;
12848 tANI_U32 dwTmp;
12849 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012850 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012851 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012852 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012853
12854 if(!pSession)
12855 {
12856 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12857 return eHAL_STATUS_FAILURE;
12858 }
12859
Jeff Johnson295189b2012-06-20 16:38:30 -070012860 do {
12861 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12862 pSession->joinFailStatusCode.reasonCode = 0;
12863 msgLen = sizeof(tSirSmeStartBssReq);
12864 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12865 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012866 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12867 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012868 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012870 //sessionId
12871 *pBuf = (tANI_U8)sessionId;
12872 pBuf++;
12873 // transactionId
12874 *pBuf = 0;
12875 *(pBuf + 1) = 0;
12876 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012877 // bssid
12878 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12879 pBuf += sizeof(tSirMacAddr);
12880 // selfMacAddr
12881 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12882 pBuf += sizeof(tSirMacAddr);
12883 // beaconInterval
12884 if( pBssDesc && pBssDesc->beaconInterval )
12885 {
12886 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12887 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012888 else if(pParam->beaconInterval)
12889 {
12890 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12891 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012892 else
12893 {
12894 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
12895 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070012896 if(csrIsconcurrentsessionValid (pMac, sessionId,
12897 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070012898 == eHAL_STATUS_SUCCESS )
12899 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012900 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070012901 pParam->bssPersona);
12902 //Update the beacon Interval
12903 pParam->beaconInterval = wTmp;
12904 }
12905 else
12906 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012907 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070012908 status = eHAL_STATUS_FAILURE;
Gopichand Nakkala114718f2013-03-25 19:19:46 -070012909 palFreeMemory( pMac->hHdd, pMsg );
Jeff Johnsone7245742012-09-05 17:12:55 -070012910 return status;
12911 }
12912
Jeff Johnson295189b2012-06-20 16:38:30 -070012913 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12914 pBuf += sizeof(tANI_U16);
12915 // dot11mode
12916 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
12917 pBuf += 1;
12918 // bssType
12919 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
12920 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
12921 pBuf += sizeof(tSirBssType);
12922 // ssId
12923 if( pParam->ssId.length )
12924 {
12925 // ssId len
12926 *pBuf = pParam->ssId.length;
12927 pBuf++;
12928 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
12929 pBuf += pParam->ssId.length;
12930 }
12931 else
12932 {
12933 *pBuf = 0;
12934 pBuf++;
12935 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012936 // set the channel Id
12937 *pBuf = pParam->operationChn;
12938 pBuf++;
12939 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070012940 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
12941 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
12942 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070012943
Jeff Johnson295189b2012-06-20 16:38:30 -070012944 // Set privacy
12945 *pBuf = pParam->privacy;
12946 pBuf++;
12947
12948 //Set Uapsd
12949 *pBuf = pParam->ApUapsdEnable;
12950 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012951 //Set SSID hidden
12952 *pBuf = pParam->ssidHidden;
12953 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012954 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
12955 pBuf++;
12956
12957 //Ht protection Enable/Disable
12958 *pBuf = (tANI_U8)pParam->protEnabled;
12959 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012960 //Enable Beacons to Receive for OBSS protection Enable/Disable
12961 *pBuf = (tANI_U8)pParam->obssProtEnabled;
12962 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012963 //set cfg related to protection
12964 wTmp = pal_cpu_to_be16( pParam->ht_protection );
12965 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12966 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012967 // Set Auth type
12968 authType = pal_cpu_to_be32(pParam->authType);
12969 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
12970 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012971 // Set DTIM
12972 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
12973 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12974 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012975 // Set wps_state
12976 *pBuf = pParam->wps_state;
12977 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012978 //Persona
12979 *pBuf = (tANI_U8)pParam->bssPersona;
12980 pBuf++;
12981
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080012982 //txLdpcIniFeatureEnabled
12983 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
12984 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012985
Jeff Johnson295189b2012-06-20 16:38:30 -070012986
12987 // set RSN IE
12988 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
12989 {
12990 status = eHAL_STATUS_INVALID_PARAMETER;
12991 palFreeMemory( pMac->hHdd, pMsg );
12992 break;
12993 }
12994 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
12995 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12996 pBuf += sizeof(tANI_U16);
12997 if( wTmp )
12998 {
12999 wTmp = pParam->nRSNIELength;
13000 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
13001 pBuf += wTmp;
13002 }
13003 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
13004 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
13005 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013006 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13007 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013008 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
13009 pBuf += pParam->operationalRateSet.numRates ;
13010 *pBuf++ = pParam->extendedRateSet.numRates;
13011 if(0 != pParam->extendedRateSet.numRates)
13012 {
13013 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
13014 pBuf += pParam->extendedRateSet.numRates;
13015 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013016 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13017 pMsg->length = pal_cpu_to_be16(msgLen);
13018
13019 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013020 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 return( status );
13022}
13023
Jeff Johnson295189b2012-06-20 16:38:30 -070013024eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13025{
13026 eHalStatus status = eHAL_STATUS_FAILURE;
13027 tSirSmeStopBssReq *pMsg;
13028 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13029 tANI_U8 *pBuf;
13030 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013031
13032 if(!pSession)
13033 {
13034 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13035 return eHAL_STATUS_FAILURE;
13036 }
13037
Jeff Johnson295189b2012-06-20 16:38:30 -070013038 do {
13039 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13040 if ( !HAL_STATUS_SUCCESS(status) ) break;
13041 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13042 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13043 pBuf = &pMsg->sessionId;
13044 //sessionId
13045 *pBuf = (tANI_U8)sessionId;
13046 pBuf++;
13047 // transactionId
13048 *pBuf = 0;
13049 pBuf += sizeof(tANI_U16);
13050 //reason code
13051 *pBuf = 0;
13052 pBuf += sizeof(tSirResultCodes);
13053 // bssid
13054 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13055 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13056 {
13057 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
13058 }
13059 else
13060 {
13061 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
13062 }
13063 pBuf += sizeof(tSirMacAddr);
13064 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13065 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013066 status = palSendMBMessage( pMac->hHdd, pMsg );
13067#if 0
13068 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13069 if ( !HAL_STATUS_SUCCESS(status) ) break;
13070 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13071 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13072 pMsg->reasonCode = 0;
13073 // bssid
13074 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13075 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13076 {
13077 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13078 }
13079 else
13080 {
13081 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13082 }
13083 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
13084 pMsg->transactionId = 0;
13085 pMsg->sessionId = (tANI_U8)sessionId;
13086 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13087 status = palSendMBMessage( pMac->hHdd, pMsg );
13088#endif
13089 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013090 return( status );
13091}
13092
Jeff Johnson295189b2012-06-20 16:38:30 -070013093eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13094 tCsrRoamModifyProfileFields *pModProfileFields,
13095 tANI_U32 *pRoamId, v_BOOL_t fForce)
13096{
Jeff Johnson295189b2012-06-20 16:38:30 -070013097 eHalStatus status = eHAL_STATUS_FAILURE;
13098 tANI_U32 roamId = 0;
13099 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 if((csrIsConnStateConnected(pMac, sessionId)) &&
13101 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
13102 &pSession->connectedProfile.modifyProfileFields,
13103 sizeof(tCsrRoamModifyProfileFields)))) )
13104 {
13105 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13106 if(pRoamId)
13107 {
13108 *pRoamId = roamId;
13109 }
13110
Jeff Johnson295189b2012-06-20 16:38:30 -070013111 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13112 eCsrSmeIssuedReassocToSameAP, roamId,
13113 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013114 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013115 return status;
13116}
Jeff Johnson295189b2012-06-20 16:38:30 -070013117static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13118{
13119 eHalStatus status = eHAL_STATUS_SUCCESS;
13120 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070013121 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
13122 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13123 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13124 return (status);
13125}
Jeff Johnson295189b2012-06-20 16:38:30 -070013126eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13127{
13128 eHalStatus status = eHAL_STATUS_SUCCESS;
13129 tListElem *pEntry = NULL;
13130 tSmeCmd *pCommand = NULL;
13131 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013132 do
13133 {
13134 if(pMsg == NULL)
13135 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013136 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013137 status = eHAL_STATUS_FAILURE;
13138 break;
13139 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013140 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13141 if(pEntry)
13142 {
13143 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13144 if(eSmeCommandAddStaSession == pCommand->command)
13145 {
13146 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013147 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013148 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013149 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013150 //Remove this command out of the active list
13151 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13152 {
13153 //Now put this command back on the avilable command list
13154 csrReleaseCommand(pMac, pCommand);
13155 }
13156 smeProcessPendingQueue( pMac );
13157 }
13158 else
13159 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013160 smsLog(pMac, LOGE, "in %s eWNI_SME_ADD_STA_SELF_RSP Received but NO Add sta session command are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013161 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013162 status = eHAL_STATUS_FAILURE;
13163 break;
13164 }
13165 }
13166 else
13167 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013168 smsLog(pMac, LOGE, "in %s eWNI_SME_ADD_STA_SELF_RSP Received but NO commands are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013169 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013170 status = eHAL_STATUS_FAILURE;
13171 break;
13172 }
13173 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013174 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013175}
Jeff Johnson295189b2012-06-20 16:38:30 -070013176eHalStatus csrSendMBAddSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13177{
13178 tSirSmeAddStaSelfReq *pMsg;
13179 tANI_U16 msgLen;
13180 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013181 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013182 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13183 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013184 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13185 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013186 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013187 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13188 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013189 // self station address
13190 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013191 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070013192 pMsg->selfMacAddr[0],
13193 pMsg->selfMacAddr[1],
13194 pMsg->selfMacAddr[2],
13195 pMsg->selfMacAddr[3],
13196 pMsg->selfMacAddr[4],
13197 pMsg->selfMacAddr[5]);
13198 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013199 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013200 return( status );
13201}
Jeff Johnson295189b2012-06-20 16:38:30 -070013202eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr sessionMacAddr)
13203{
13204 eHalStatus status = eHAL_STATUS_SUCCESS;
13205 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013206 pCommand = csrGetCommandBuffer(pMac);
13207 if(NULL == pCommand)
13208 {
13209 status = eHAL_STATUS_RESOURCES;
13210 }
13211 else
13212 {
13213 pCommand->command = eSmeCommandAddStaSession;
13214 pCommand->sessionId = (tANI_U8)sessionId;
13215 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13217 if( !HAL_STATUS_SUCCESS( status ) )
13218 {
13219 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013220 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013221 }
13222 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013223 return (status);
13224}
Jeff Johnson295189b2012-06-20 16:38:30 -070013225eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13226{
13227 return csrSendMBAddSelfStaReqMsg( pMac,
13228 pCommand->u.addStaSessionCmd.selfMacAddr );
13229}
Jeff Johnson295189b2012-06-20 16:38:30 -070013230eHalStatus csrRoamOpenSession( tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext,
13231 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId )
13232{
13233 eHalStatus status = eHAL_STATUS_SUCCESS;
13234 tANI_U32 i;
13235 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013236 *pbSessionId = CSR_SESSION_ID_INVALID;
13237 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13238 {
13239 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13240 {
13241 pSession = CSR_GET_SESSION( pMac, i );
13242 status = eHAL_STATUS_SUCCESS;
13243 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13244 pSession->sessionId = (tANI_U8)i;
13245 pSession->callback = callback;
13246 pSession->pContext = pContext;
13247 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
13248 *pbSessionId = (tANI_U8)i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013249 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerRoaming, csrRoamRoamingTimerHandler,
13250 &pSession->roamingTimerInfo);
13251 if(!HAL_STATUS_SUCCESS(status))
13252 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013253 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013254 break;
13255 }
13256#ifdef FEATURE_WLAN_BTAMP_UT_RF
13257 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerJoinRetry, csrRoamJoinRetryTimerHandler,
13258 &pSession->joinRetryTimerInfo);
13259 if(!HAL_STATUS_SUCCESS(status))
13260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013261 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013262 break;
13263 }
13264#endif
13265 pSession->ibssJoinTimerInfo.pMac = pMac;
13266 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -070013267 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerIbssJoining, csrRoamIbssJoinTimerHandler,
13268 &pSession->ibssJoinTimerInfo);
13269 if(!HAL_STATUS_SUCCESS(status))
13270 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013271 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013272 break;
13273 }
13274 status = csrIssueAddStaForSessionReq ( pMac, i, pSelfMacAddr );
13275 break;
13276 }
13277 }
13278 if( CSR_ROAM_SESSION_MAX == i )
13279 {
13280 //No session is available
13281 status = eHAL_STATUS_RESOURCES;
13282 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013283 return ( status );
13284}
Jeff Johnson295189b2012-06-20 16:38:30 -070013285eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13286{
13287 eHalStatus status = eHAL_STATUS_SUCCESS;
13288 tListElem *pEntry = NULL;
13289 tSmeCmd *pCommand = NULL;
13290 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013291 do
13292 {
13293 if(pMsg == NULL)
13294 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013295 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013296 status = eHAL_STATUS_FAILURE;
13297 break;
13298 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013299 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13300 if(pEntry)
13301 {
13302 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13303 if(eSmeCommandDelStaSession == pCommand->command)
13304 {
13305 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013306 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013307 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013308 //This session is done.
13309 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 if(pCommand->u.delStaSessionCmd.callback)
13311 {
13312
13313 status = sme_ReleaseGlobalLock( &pMac->sme );
13314 if ( HAL_STATUS_SUCCESS( status ) )
13315 {
13316 pCommand->u.delStaSessionCmd.callback(
13317 pCommand->u.delStaSessionCmd.pContext);
13318 status = sme_AcquireGlobalLock( &pMac->sme );
13319 if (! HAL_STATUS_SUCCESS( status ) )
13320 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013321 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013322 return status;
13323 }
13324 }
13325 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013326 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013327 }
13328 }
13329
13330 //Remove this command out of the active list
13331 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13332 {
13333 //Now put this command back on the avilable command list
13334 csrReleaseCommand(pMac, pCommand);
13335 }
13336 smeProcessPendingQueue( pMac );
13337 }
13338 else
13339 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013340 smsLog(pMac, LOGE, "in %s eWNI_SME_DEL_STA_SELF_RSP Received but NO Del sta session command are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013341 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013342 status = eHAL_STATUS_FAILURE;
13343 break;
13344 }
13345 }
13346 else
13347 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013348 smsLog(pMac, LOGE, "in %s eWNI_SME_DEL_STA_SELF_RSP Received but NO commands are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013349 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013350 status = eHAL_STATUS_FAILURE;
13351 break;
13352 }
13353 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013354 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013355}
Jeff Johnson295189b2012-06-20 16:38:30 -070013356eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13357{
13358 tSirSmeDelStaSelfReq *pMsg;
13359 tANI_U16 msgLen;
13360 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013361 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013362 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13363 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013364 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13365 if ( !HAL_STATUS_SUCCESS(status) ) break;
13366
13367 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013368 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13369 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013370 // self station address
13371 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013372 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013373 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013374 return( status );
13375}
Jeff Johnson295189b2012-06-20 16:38:30 -070013376eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13377 tSirMacAddr sessionMacAddr,
13378 csrRoamSessionCloseCallback callback,
13379 void *pContext)
13380{
13381 eHalStatus status = eHAL_STATUS_SUCCESS;
13382 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013383 pCommand = csrGetCommandBuffer(pMac);
13384 if(NULL == pCommand)
13385 {
13386 status = eHAL_STATUS_RESOURCES;
13387 }
13388 else
13389 {
13390 pCommand->command = eSmeCommandDelStaSession;
13391 pCommand->sessionId = (tANI_U8)sessionId;
13392 pCommand->u.delStaSessionCmd.callback = callback;
13393 pCommand->u.delStaSessionCmd.pContext = pContext;
13394 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013395 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13396 if( !HAL_STATUS_SUCCESS( status ) )
13397 {
13398 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013399 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013400 }
13401 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013402 return (status);
13403}
Jeff Johnson295189b2012-06-20 16:38:30 -070013404eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13405{
13406 return csrSendMBDelSelfStaReqMsg( pMac,
13407 pCommand->u.delStaSessionCmd.selfMacAddr );
13408}
Jeff Johnson295189b2012-06-20 16:38:30 -070013409static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13410{
13411 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13412 tListElem *pEntry, *pNext;
13413 tSmeCmd *pCommand;
13414 tDblLinkList localList;
13415
13416 vos_mem_zero(&localList, sizeof(tDblLinkList));
13417 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13418 {
13419 smsLog(pMac, LOGE, FL(" failed to open list"));
13420 return;
13421 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013422 csrLLLock(pList);
13423 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13424 while(pEntry != NULL)
13425 {
13426 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13427 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13428 if(pCommand->sessionId == sessionId)
13429 {
13430 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13431 {
13432 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13433 }
13434 }
13435 pEntry = pNext;
13436 }
13437 csrLLUnlock(pList);
13438
13439 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13440 {
13441 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13442 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13443 }
13444 csrLLClose(&localList);
13445}
13446
Jeff Johnson295189b2012-06-20 16:38:30 -070013447void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13448{
13449 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13450 {
13451 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013452 csrRoamStop(pMac, sessionId);
13453 csrFreeConnectBssDesc(pMac, sessionId);
13454 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13455 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
13456 palTimerFree(pMac->hHdd, pSession->hTimerRoaming);
13457#ifdef FEATURE_WLAN_BTAMP_UT_RF
13458 palTimerFree(pMac->hHdd, pSession->hTimerJoinRetry);
13459#endif
13460 palTimerFree(pMac->hHdd, pSession->hTimerIbssJoining);
13461 purgeSmeSessionCmdList(pMac, sessionId);
13462 purgeCsrSessionCmdList(pMac, sessionId);
13463 csrInitSession(pMac, sessionId);
13464 }
13465}
13466
Jeff Johnson295189b2012-06-20 16:38:30 -070013467eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13468 tANI_BOOLEAN fSync,
13469 csrRoamSessionCloseCallback callback,
13470 void *pContext )
13471{
13472 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013473 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13474 {
13475 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13476 if(fSync)
13477 {
13478 csrCleanupSession(pMac, sessionId);
13479 }
13480 else
13481 {
13482 purgeSmeSessionCmdList(pMac, sessionId);
13483 purgeCsrSessionCmdList(pMac, sessionId);
13484 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13485 pSession->selfMacAddr, callback, pContext);
13486 }
13487 }
13488 else
13489 {
13490 status = eHAL_STATUS_INVALID_PARAMETER;
13491 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 return ( status );
13493}
13494
Jeff Johnson295189b2012-06-20 16:38:30 -070013495static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13496{
13497 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013498
13499 if(!pSession)
13500 {
13501 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13502 return;
13503 }
13504
Jeff Johnson295189b2012-06-20 16:38:30 -070013505 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13506 pSession->sessionId = CSR_SESSION_ID_INVALID;
13507 pSession->callback = NULL;
13508 pSession->pContext = NULL;
13509 pSession->ibss_join_pending = FALSE;
13510 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13511 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13512 csrFreeRoamProfile( pMac, sessionId );
13513 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13514 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13515 csrFreeConnectBssDesc(pMac, sessionId);
13516 csrScanEnable(pMac);
13517 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13518 if(pSession->pWpaRsnReqIE)
13519 {
13520 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13521 pSession->pWpaRsnReqIE = NULL;
13522 }
13523 pSession->nWpaRsnReqIeLength = 0;
13524 if(pSession->pWpaRsnRspIE)
13525 {
13526 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13527 pSession->pWpaRsnRspIE = NULL;
13528 }
13529 pSession->nWpaRsnRspIeLength = 0;
13530#ifdef FEATURE_WLAN_WAPI
13531 if(pSession->pWapiReqIE)
13532 {
13533 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13534 pSession->pWapiReqIE = NULL;
13535 }
13536 pSession->nWapiReqIeLength = 0;
13537 if(pSession->pWapiRspIE)
13538 {
13539 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13540 pSession->pWapiRspIE = NULL;
13541 }
13542 pSession->nWapiRspIeLength = 0;
13543#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013544 if(pSession->pAddIEScan)
13545 {
13546 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13547 pSession->pAddIEScan = NULL;
13548 }
13549 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013550 if(pSession->pAddIEAssoc)
13551 {
13552 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13553 pSession->pAddIEAssoc = NULL;
13554}
13555 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013556}
13557
Jeff Johnson295189b2012-06-20 16:38:30 -070013558eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13559{
13560 eHalStatus status = eHAL_STATUS_FAILURE;
13561 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013562 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13563 {
13564 if( CSR_IS_SESSION_VALID( pMac, i ) )
13565 {
13566 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13567 {
13568 //Found it
13569 status = eHAL_STATUS_SUCCESS;
13570 *pSessionId = i;
13571 break;
13572 }
13573 }
13574 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013575 return( status );
13576}
13577
Jeff Johnson295189b2012-06-20 16:38:30 -070013578//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13579//session because for IBSS, the bssid changes.
13580static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13581{
13582 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13583 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013584 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13585 {
13586 if( CSR_IS_SESSION_VALID( pMac, i ) )
13587 {
13588 pSession = CSR_GET_SESSION( pMac, i );
13589 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13590 {
13591 //Found it
13592 nRet = i;
13593 break;
13594 }
13595 }
13596 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013597 return (nRet);
13598}
Jeff Johnson295189b2012-06-20 16:38:30 -070013599static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13600{
13601 /* Update the current BSS info in ho control block based on connected
13602 profile info from pmac global structure */
13603
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013604 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013605 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13606 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013607 /* Check for user misconfig of RSSI trigger threshold */
13608 pMac->roam.configParam.vccRssiThreshold =
13609 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13610 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13611 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013612 /* Check for user misconfig of UL MAC Loss trigger threshold */
13613 pMac->roam.configParam.vccUlMacLossThreshold =
13614 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13615 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013616#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13617 {
13618 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013619 /* Indicate the neighbor roal algorithm about the connect indication */
13620 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13621 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13622 }
13623#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013624}
13625
Jeff Johnson295189b2012-06-20 16:38:30 -070013626static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13627{
13628 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013629
13630 if(!pSession)
13631 {
13632 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13633 return;
13634 }
13635
Jeff Johnson295189b2012-06-20 16:38:30 -070013636 //Only to handle the case for Handover on infra link
13637 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13638 {
13639 return;
13640 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013641 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13642 csrRoamDeregStatisticsReq(pMac);
13643 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13644#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13645 /* Indicate the neighbor roal algorithm about the disconnect indication */
13646 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13647#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013648
13649 //Remove this code once SLM_Sessionization is supported
13650 //BMPS_WORKAROUND_NOT_NEEDED
13651 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013652 csrIsInfraApStarted( pMac ) &&
13653 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013654 {
13655 pMac->roam.configParam.doBMPSWorkaround = 0;
13656 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013657}
13658
Jeff Johnson295189b2012-06-20 16:38:30 -070013659void csrRoamTlStatsTimerHandler(void *pv)
13660{
13661 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13662 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013663 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13664
Jeff Johnsone7245742012-09-05 17:12:55 -070013665 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13666
Jeff Johnson295189b2012-06-20 16:38:30 -070013667#if 0
13668 // TODO Persession .???
13669 //req TL for stats
13670 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013672 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 }
13674 else
13675 {
13676 //save in SME
13677 csrRoamSaveStatsFromTl(pMac, tlStats);
13678 }
13679#endif
13680 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13681 {
13682 if(pMac->roam.tlStatsReqInfo.periodicity)
13683 {
13684 //start timer
13685 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13686 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
13687 if(!HAL_STATUS_SUCCESS(status))
13688 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013689 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013690 return;
13691 }
13692 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13693 }
13694 }
13695}
Jeff Johnson295189b2012-06-20 16:38:30 -070013696void csrRoamPeStatsTimerHandler(void *pv)
13697{
13698 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13699 eHalStatus status;
13700 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13701 VOS_STATUS vosStatus;
13702 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013703 pPeStatsReqListEntry->timerRunning = FALSE;
13704 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13705 {
13706 // If we entered here, meaning the timer could not be successfully
13707 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13708
13709 /* Destroy the timer */
13710 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13711 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13712 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013713 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013714 }
13715
13716 // Free the entry
13717 palFreeMemory(pMac->hHdd, pPeStatsReqListEntry);
13718 pPeStatsReqListEntry = NULL;
13719 }
13720 else
13721 {
13722 if(!pPeStatsReqListEntry->rspPending)
13723 {
13724 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13725 pPeStatsReqListEntry->staId);
13726 if(!HAL_STATUS_SUCCESS(status))
13727 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013728 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013729 }
13730 else
13731 {
13732 pPeStatsReqListEntry->rspPending = TRUE;
13733 }
13734 }
13735
13736 //send down a req
13737 if(pPeStatsReqListEntry->periodicity &&
13738 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13739 {
13740 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13741 if(ePMC_FULL_POWER == powerState)
13742 {
13743 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13744 {
13745 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13746 }
13747 }
13748 else
13749 {
13750 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13751 {
13752 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13753 }
13754 }
13755 //start timer
13756 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13757 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13758 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013759 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013760 return;
13761 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013762 pPeStatsReqListEntry->timerRunning = TRUE;
13763
13764 }
13765
13766 }
13767}
Jeff Johnson295189b2012-06-20 16:38:30 -070013768void csrRoamStatsClientTimerHandler(void *pv)
13769{
13770 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013771 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13772 {
13773#if 0
13774 // TODO Stats fix for multisession
13775 //start the timer
13776 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13777
13778 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13779 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013780 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013781 }
13782#endif
13783 }
13784#if 0
13785 //send up the stats report
13786 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13787 pStaEntry->staId, pStaEntry->pContext);
13788#endif
13789}
13790
13791
13792
Jeff Johnson295189b2012-06-20 16:38:30 -070013793eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13794{
13795 tAniGetPEStatsReq *pMsg;
13796 eHalStatus status = eHAL_STATUS_SUCCESS;
13797 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13798 if ( !HAL_STATUS_SUCCESS(status) )
13799 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013800 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 return status;
13802 }
13803 // need to initiate a stats request to PE
13804 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13805 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13806 pMsg->staId = staId;
13807 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013808 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 if(!HAL_STATUS_SUCCESS(status))
13810 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013811 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013812 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013813 return status;
13814}
Jeff Johnson295189b2012-06-20 16:38:30 -070013815void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13816{
13817 tAniGetPEStatsRsp *pSmeStatsRsp;
13818 eHalStatus status = eHAL_STATUS_FAILURE;
13819 tListElem *pEntry = NULL;
13820 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13821 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13822 tANI_U32 tempMask = 0;
13823 tANI_U8 counter = 0;
13824 tANI_U8 *pStats = NULL;
13825 tANI_U32 length = 0;
13826 v_PVOID_t pvosGCtx;
13827 v_S7_t rssi = 0;
13828 tANI_U32 *pRssi = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013829 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13830 if(pSmeStatsRsp->rc)
13831 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013832 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013833 goto post_update;
13834 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013835 tempMask = pSmeStatsRsp->statsMask;
13836 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013837 /* subtract all statistics from this length, and after processing the entire
13838 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13839 * in this 'stats' message.
13840 */
13841 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013842 //new stats info from PE, fill up the stats strucutres in PMAC
13843 while(tempMask)
13844 {
13845 if(tempMask & 1)
13846 {
13847 switch(counter)
13848 {
13849 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013850 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013851 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13852 pStats, sizeof(tCsrSummaryStatsInfo));
13853 if(!HAL_STATUS_SUCCESS(status))
13854 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013855 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013856 }
13857 pStats += sizeof(tCsrSummaryStatsInfo);
13858 length -= sizeof(tCsrSummaryStatsInfo);
13859 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013860 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013861 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013862 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13863 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13864 if(!HAL_STATUS_SUCCESS(status))
13865 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013866 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013867 }
13868 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13869 length -= sizeof(tCsrGlobalClassAStatsInfo);
13870 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013872 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013873 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13874 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13875 if(!HAL_STATUS_SUCCESS(status))
13876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013877 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 }
13879 pStats += sizeof(tCsrGlobalClassBStatsInfo);
13880 length -= sizeof(tCsrGlobalClassBStatsInfo);
13881 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013882 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013883 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013884 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
13885 pStats, sizeof(tCsrGlobalClassCStatsInfo));
13886 if(!HAL_STATUS_SUCCESS(status))
13887 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013888 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013889 }
13890 pStats += sizeof(tCsrGlobalClassCStatsInfo);
13891 length -= sizeof(tCsrGlobalClassCStatsInfo);
13892 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013894 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013895 if( CSR_MAX_STA > pSmeStatsRsp->staId )
13896 {
13897 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
13898 pStats, sizeof(tCsrPerStaStatsInfo));
13899 }
13900 else
13901 {
13902 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013903 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013904 VOS_ASSERT( 0 );
13905 }
13906 if(!HAL_STATUS_SUCCESS(status))
13907 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013908 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013909 }
13910 pStats += sizeof(tCsrPerStaStatsInfo);
13911 length -= sizeof(tCsrPerStaStatsInfo);
13912 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013913 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013914 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013915 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013916 }
13917 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 tempMask >>=1;
13919 counter++;
13920 }
13921 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
13922 if (length != 0)
13923 {
13924 pRssi = (tANI_U32*)pStats;
13925 rssi = (v_S7_t)*pRssi;
13926 }
13927 else
13928 {
13929 /* If riva is not sending rssi, continue to use the hack */
13930 rssi = RSSI_HACK_BMPS;
13931 }
13932 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -070013933post_update:
13934 //make sure to update the pe stats req list
13935 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
13936 if(pEntry)
13937 {
13938 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
13939 pPeStaEntry->rspPending = FALSE;
13940
13941 }
13942 //check the one timer cases
13943 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
13944 if(pEntry)
13945 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013946 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013947 if(pTempStaEntry->timerExpired)
13948 {
13949 //send up the stats report
13950 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
13951 pTempStaEntry->staId, pTempStaEntry->pContext);
13952 //also remove from the client list
13953 csrRoamRemoveStatListEntry(pMac, pEntry);
13954 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013955 }
13956 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013957}
Jeff Johnson295189b2012-06-20 16:38:30 -070013958tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13959{
13960 tListElem *pEntry = NULL;
13961 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013962 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013963 if(!pEntry)
13964 {
13965 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013966 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070013967 return NULL;
13968 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013969 while( pEntry )
13970 {
13971 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013972 if(pTempStaEntry->statsMask == statsMask)
13973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013974 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070013975 break;
13976 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013977 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
13978 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 return pEntry;
13980}
13981
Jeff Johnson295189b2012-06-20 16:38:30 -070013982tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
13983 tANI_BOOLEAN update)
13984{
13985 tListElem *pEntry;
13986 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013987 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 if(!pEntry)
13989 {
13990 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013991 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013992 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070013993 return NULL;
13994 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013995 while( pEntry )
13996 {
13997 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013998 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
13999 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14000 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014001 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014002 if(update)
14003 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014004 pTempStaEntry->periodicity = pStaEntry->periodicity;
14005 pTempStaEntry->callback = pStaEntry->callback;
14006 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014007 }
14008 break;
14009 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14011 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014012 return pEntry;
14013}
Jeff Johnson295189b2012-06-20 16:38:30 -070014014tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14015{
14016 tListElem *pEntry;
14017 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014018 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 if(!pEntry)
14020 {
14021 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014022 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014023 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014024 return NULL;
14025 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 while( pEntry )
14027 {
14028 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014029 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14030 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014031 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014032 break;
14033 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014034 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14035 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014036 return pEntry;
14037}
Jeff Johnson295189b2012-06-20 16:38:30 -070014038eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14039 csrRoamLinkQualityIndCallback callback,
14040 void *pContext)
14041{
14042 pMac->roam.linkQualityIndInfo.callback = callback;
14043 pMac->roam.linkQualityIndInfo.context = pContext;
14044 if( NULL == callback )
14045 {
14046 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14047 }
14048 else
14049 {
14050 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014051 /* do we need to invoke the callback to notify client of initial value ?? */
14052 }
14053 return eHAL_STATUS_SUCCESS;
14054}
Jeff Johnson295189b2012-06-20 16:38:30 -070014055void csrRoamVccTrigger(tpAniSirGlobal pMac)
14056{
14057 eCsrRoamLinkQualityInd newVccLinkQuality;
14058 tANI_U32 ul_mac_loss = 0;
14059 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014060 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14061 /*-------------------------------------------------------------------------
14062 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014063 Check for a change in link quality and notify client if necessary
14064 -------------------------------------------------------------------------*/
14065 ul_mac_loss_trigger_threshold =
14066 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014067 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014068 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014069 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014070 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14071 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014072 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014073 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14074 }
14075 else
14076 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014077 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014078 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14079 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014080 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14081 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014082 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14083 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014084 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014085 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14086 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014087 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014088 newVccLinkQuality );
14089
14090 /* we now invoke the callback once to notify client of initial value */
14091 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14092 pMac->roam.linkQualityIndInfo.context );
14093 //event: EVENT_WLAN_VCC
14094 }
14095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014096 pMac->roam.vccLinkQuality = newVccLinkQuality;
14097
Jeff Johnson295189b2012-06-20 16:38:30 -070014098}
Jeff Johnson295189b2012-06-20 16:38:30 -070014099VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14100 v_U8_t rssiNotification,
14101 void * context)
14102{
14103 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14104 eCsrRoamLinkQualityInd newVccLinkQuality;
14105 // TODO : Session info unavailable
14106 tANI_U32 sessionId = 0;
14107 VOS_STATUS status = VOS_STATUS_SUCCESS;
14108 /*-------------------------------------------------------------------------
14109 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014110 Check for a change in link quality and notify client if necessary
14111 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014112 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014113 pMac->roam.configParam.vccRssiThreshold);
14114 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14115 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014116 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014117 return VOS_STATUS_SUCCESS;
14118 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014119 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14120 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014121 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014122 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14123 }
14124 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14125 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014126 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014127 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14128 }
14129 else
14130 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014131 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014132 //Set to this so the code below won't do anything
14133 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014134 VOS_ASSERT(0);
14135 }
14136
Jeff Johnson295189b2012-06-20 16:38:30 -070014137 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14138 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014139 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014140 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14141 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014142 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014143 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014144 /* we now invoke the callback once to notify client of initial value */
14145 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14146 pMac->roam.linkQualityIndInfo.context );
14147 //event: EVENT_WLAN_VCC
14148 }
14149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014150 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014151 return status;
14152}
Jeff Johnson295189b2012-06-20 16:38:30 -070014153tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14154 tDblLinkList *pStaList,
14155 tCsrStatsClientReqInfo *pStaEntry)
14156{
14157 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014158 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014159 //if same entity requested for same set of stats with different periodicity &
14160 // callback update it
14161 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14162 {
14163
14164 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
14165 if (!HAL_STATUS_SUCCESS(status))
14166 {
14167 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014168 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014169 return NULL;
14170 }
14171
Jeff Johnson295189b2012-06-20 16:38:30 -070014172 pNewStaEntry->callback = pStaEntry->callback;
14173 pNewStaEntry->pContext = pStaEntry->pContext;
14174 pNewStaEntry->periodicity = pStaEntry->periodicity;
14175 pNewStaEntry->requesterId = pStaEntry->requesterId;
14176 pNewStaEntry->statsMask = pStaEntry->statsMask;
14177 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14178 pNewStaEntry->pMac = pStaEntry->pMac;
14179 pNewStaEntry->staId = pStaEntry->staId;
14180 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14181
14182 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14183 }
14184 return pNewStaEntry;
14185}
14186
Jeff Johnson295189b2012-06-20 16:38:30 -070014187tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14188 tDblLinkList *pStaList,
14189 tCsrPeStatsReqInfo *pStaEntry)
14190{
14191 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014192 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014193 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
14194 if (!HAL_STATUS_SUCCESS(status))
14195 {
14196 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014197 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014198 return NULL;
14199 }
14200
Jeff Johnson295189b2012-06-20 16:38:30 -070014201 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14202 pNewStaEntry->numClient = pStaEntry->numClient;
14203 pNewStaEntry->periodicity = pStaEntry->periodicity;
14204 pNewStaEntry->statsMask = pStaEntry->statsMask;
14205 pNewStaEntry->pMac = pStaEntry->pMac;
14206 pNewStaEntry->staId = pStaEntry->staId;
14207 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14208 pNewStaEntry->rspPending = pStaEntry->rspPending;
14209
14210 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014211 return pNewStaEntry;
14212}
Jeff Johnson295189b2012-06-20 16:38:30 -070014213eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14214 tCsrRssiCallback callback,
14215 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14216{
14217 eHalStatus status = eHAL_STATUS_SUCCESS;
14218 vos_msg_t msg;
14219 tANI_U32 sessionId;
14220
14221 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014222 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014223 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14224 if ( !HAL_STATUS_SUCCESS(status) )
14225 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014226 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014227 return status;
14228 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014229 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14230
14231 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14232 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14233 pMsg->sessionId = sessionId;
14234 pMsg->staId = staId;
14235 pMsg->rssiCallback = callback;
14236 pMsg->pDevContext = pContext;
14237 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014238 msg.type = eWNI_SME_GET_RSSI_REQ;
14239 msg.bodyptr = pMsg;
14240 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014241 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14242 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014243 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014244 palFreeMemory(pMac->hHdd, (void *)pMsg);
14245 status = eHAL_STATUS_FAILURE;
14246 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014247 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014248 return status;
14249}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014250
14251#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14252eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14253 tCsrRssiCallback callback,
14254 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14255{
14256 eHalStatus status = eHAL_STATUS_SUCCESS;
14257 tAniGetRssiReq *pMsg;
14258
14259 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14260 if ( !HAL_STATUS_SUCCESS(status) )
14261 {
14262 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
14263 return status;
14264 }
14265 // need to initiate a stats request to PE
14266 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
14267 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14268 pMsg->staId = staId;
14269 pMsg->rssiCallback = callback;
14270 pMsg->pDevContext = pContext;
14271 pMsg->pVosContext = pVosContext;
14272 status = palSendMBMessage(pMac->hHdd, pMsg );
14273 if(!HAL_STATUS_SUCCESS(status))
14274 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070014275 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
14276 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014277 status = eHAL_STATUS_FAILURE;
14278 }
14279 return status;
14280}
14281#endif
14282
Jeff Johnson295189b2012-06-20 16:38:30 -070014283eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
14284 tANI_U32 statsMask,
14285 tCsrStatsCallback callback,
14286 tANI_U32 periodicity, tANI_BOOLEAN cache,
14287 tANI_U8 staId, void *pContext)
14288{
14289 tCsrStatsClientReqInfo staEntry;
14290 tCsrStatsClientReqInfo *pStaEntry = NULL;
14291 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14292 tListElem *pEntry = NULL;
14293 tANI_BOOLEAN found = FALSE;
14294 eHalStatus status = eHAL_STATUS_SUCCESS;
14295 tANI_BOOLEAN insertInClientList = FALSE;
14296 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070014297 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014298
14299 if( csrIsAllSessionDisconnected(pMac) )
14300 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014301 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014302 return eHAL_STATUS_FAILURE;
14303 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014304 if((!statsMask) && (!callback))
14305 {
14306 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014307 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070014308 return eHAL_STATUS_FAILURE;
14309 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014310 //for the search list method for deregister
14311 staEntry.requesterId = requesterId;
14312 staEntry.statsMask = statsMask;
14313 //requester wants to deregister or just an error
14314 if((statsMask) && (!callback))
14315 {
14316 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
14317 if(!pEntry)
14318 {
14319 //msg
14320 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014321 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014322 return eHAL_STATUS_FAILURE;
14323 }
14324 else
14325 {
14326 //clean up & return
14327 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070014328 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014329 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014330 pStaEntry->pPeStaEntry->numClient--;
14331 //check if we need to delete the entry from peStatsReqList too
14332 if(!pStaEntry->pPeStaEntry->numClient)
14333 {
14334 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14335 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014336 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014337
Jeff Johnson295189b2012-06-20 16:38:30 -070014338 //check if we need to stop the tl stats timer too
14339 pMac->roam.tlStatsReqInfo.numClient--;
14340 if(!pMac->roam.tlStatsReqInfo.numClient)
14341 {
14342 if(pMac->roam.tlStatsReqInfo.timerRunning)
14343 {
14344 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14345 if(!HAL_STATUS_SUCCESS(status))
14346 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014347 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014348 return eHAL_STATUS_FAILURE;
14349 }
14350 }
14351 pMac->roam.tlStatsReqInfo.periodicity = 0;
14352 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14353 }
14354 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014355 // Destroy the vos timer...
14356 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14357 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14358 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014359 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014360 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014361 csrRoamRemoveStatListEntry(pMac, pEntry);
14362 pStaEntry = NULL;
14363 return eHAL_STATUS_SUCCESS;
14364 }
14365 }
14366
14367 if(cache && !periodicity)
14368 {
14369 //return the cached stats
14370 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14371 }
14372 else
14373 {
14374 //add the request in the client req list
14375 staEntry.callback = callback;
14376 staEntry.pContext = pContext;
14377 staEntry.periodicity = periodicity;
14378 staEntry.pPeStaEntry = NULL;
14379 staEntry.staId = staId;
14380 staEntry.pMac = pMac;
14381 staEntry.timerExpired = FALSE;
14382
14383
Jeff Johnson295189b2012-06-20 16:38:30 -070014384 //if periodic report requested with non cached result from PE/TL
14385 if(periodicity)
14386 {
14387
14388 //if looking for stats from PE
14389 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14390 {
14391
14392 //check if same request made already & waiting for rsp
14393 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14394 periodicity, &found, staId);
14395 if(!pPeStaEntry)
14396 {
14397 //bail out, maxed out on number of req for PE
14398 return eHAL_STATUS_FAILURE;
14399 }
14400 else
14401 {
14402 staEntry.pPeStaEntry = pPeStaEntry;
14403 }
14404
14405 }
14406 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14407 if(statsMask & (1 << eCsrGlobalClassDStats))
14408 {
14409 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14410 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014411 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014412 }
14413 else
14414 {
14415
14416 //update periodicity
14417 if(pMac->roam.tlStatsReqInfo.periodicity)
14418 {
14419 pMac->roam.tlStatsReqInfo.periodicity =
14420 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14421 }
14422 else
14423 {
14424 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14425 }
14426 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14427 {
14428 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14429 }
14430
14431 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14432 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014433 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14434 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014435 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014436 //req TL for class D stats
14437 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14438 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014439 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014440 }
14441 else
14442 {
14443 //save in SME
14444 csrRoamSaveStatsFromTl(pMac, pTlStats);
14445 }
14446 vos_mem_free(pTlStats);
14447 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014448 }
14449 else
14450 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014451 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014452 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014453
Jeff Johnson295189b2012-06-20 16:38:30 -070014454 if(pMac->roam.tlStatsReqInfo.periodicity)
14455 {
14456 //start timer
14457 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14458 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
14459 if(!HAL_STATUS_SUCCESS(status))
14460 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014461 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014462 return eHAL_STATUS_FAILURE;
14463 }
14464 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14465 }
14466 }
14467 }
14468 pMac->roam.tlStatsReqInfo.numClient++;
14469 }
14470
14471 insertInClientList = TRUE;
14472 }
14473 //if one time report requested with non cached result from PE/TL
14474 else if(!cache && !periodicity)
14475 {
14476 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14477 {
14478 //send down a req
14479 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14480 if(!HAL_STATUS_SUCCESS(status))
14481 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014482 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014483 }
14484 //so that when the stats rsp comes back from PE we respond to upper layer
14485 //right away
14486 staEntry.timerExpired = TRUE;
14487 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014488 }
14489 if(statsMask & (1 << eCsrGlobalClassDStats))
14490 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014491 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14492 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014493 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014494 //req TL for class D stats
14495 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14496 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014497 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014498 }
14499 else
14500 {
14501 //save in SME
14502 csrRoamSaveStatsFromTl(pMac, pTlStats);
14503 }
14504 vos_mem_free(pTlStats);
14505 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014506 }
14507 else
14508 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014509 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014510 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014511
14512 }
14513 //if looking for stats from TL only
14514 if(!insertInClientList)
14515 {
14516 //return the stats
14517 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14518 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014519 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014520 if(insertInClientList)
14521 {
14522 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14523 if(!pStaEntry)
14524 {
14525 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014526 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014527 return eHAL_STATUS_FAILURE;
14528 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014529 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014530 //Init & start timer if needed
14531 if(periodicity)
14532 {
14533 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14534 csrRoamStatsClientTimerHandler, pStaEntry );
14535 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14536 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014537 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014538 return eHAL_STATUS_FAILURE;
14539 }
14540 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14541 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14542 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014543 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014544 return eHAL_STATUS_FAILURE;
14545 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014547 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014548 }
14549 return eHAL_STATUS_SUCCESS;
14550}
14551
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014552#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
14553
14554static tSirRetStatus
14555csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
14556 tANI_U8* pBD,
14557 tANI_U8 type,
14558 tANI_U8 subType,
14559 tSirMacAddr peerAddr,
14560 tSirMacAddr selfMacAddr)
14561{
14562 tSirRetStatus statusCode = eSIR_SUCCESS;
14563 tpSirMacMgmtHdr pMacHdr;
14564
14565 /* Prepare MAC management header */
14566 pMacHdr = (tpSirMacMgmtHdr) (pBD);
14567
14568 /* Prepare FC */
14569 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14570 pMacHdr->fc.type = type;
14571 pMacHdr->fc.subType = subType;
14572
14573 /* Prepare Address 1 */
14574 palCopyMemory( pMac->hHdd,
14575 (tANI_U8 *) pMacHdr->da,
14576 (tANI_U8 *) peerAddr,
14577 sizeof( tSirMacAddr ));
14578
14579 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
14580
14581 /* Prepare Address 3 */
14582 palCopyMemory( pMac->hHdd,
14583 (tANI_U8 *) pMacHdr->bssId,
14584 (tANI_U8 *) peerAddr,
14585 sizeof( tSirMacAddr ));
14586 return statusCode;
14587} /*** csrRoamScanOffloadPopulateMacHeader() ***/
14588
14589static tSirRetStatus
14590csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
14591 tANI_U8 nChannelNum,
14592 tANI_U32 dot11mode,
14593 tSirMacAddr selfMacAddr,
14594 tANI_U8 *pFrame,
14595 tANI_U16 *pusLen)
14596{
14597 tDot11fProbeRequest pr;
14598 tANI_U32 nStatus, nBytes, nPayload;
14599 tSirRetStatus nSirStatus;
14600 /*Bcast tx*/
14601 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
14602 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14603
14604
14605 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
14606
14607 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
14608
14609 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
14610 {
14611 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
14612 }
14613
14614
14615 if (IS_DOT11_MODE_HT(dot11mode))
14616 {
14617 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
14618 }
14619
14620
14621 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
14622 if ( DOT11F_FAILED( nStatus ) )
14623 {
14624 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14625 "Failed to calculate the packed size f"
14626 "or a Probe Request (0x%08x).\n", nStatus );
14627
14628
14629 nPayload = sizeof( tDot11fProbeRequest );
14630 }
14631 else if ( DOT11F_WARNED( nStatus ) )
14632 {
14633 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14634 "There were warnings while calculating"
14635 "the packed size for a Probe Request ("
14636 "0x%08x).\n", nStatus );
14637 }
14638
14639 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
14640
14641 /* Prepare outgoing frame*/
14642 palZeroMemory( pMac->hHdd, pFrame, nBytes );
14643
14644
14645 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
14646 SIR_MAC_MGMT_PROBE_REQ, bssId ,selfMacAddr);
14647
14648 if ( eSIR_SUCCESS != nSirStatus )
14649 {
14650 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14651 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
14652 nSirStatus );
14653 return nSirStatus;
14654 }
14655
14656
14657 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
14658 sizeof( tSirMacMgmtHdr ),
14659 nPayload, &nPayload );
14660 if ( DOT11F_FAILED( nStatus ) )
14661 {
14662 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14663 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
14664 return eSIR_FAILURE;
14665 }
14666 else if ( DOT11F_WARNED( nStatus ) )
14667 {
14668 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14669 "There were warnings while packing a Probe Request (0x%08x).\n" );
14670 }
14671
14672 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
14673 return eSIR_SUCCESS;
14674}
14675
14676eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
14677{
14678 vos_msg_t msg;
14679 tSirRoamOffloadScanReq *pRequestBuf;
14680 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
14681 tCsrRoamSession *pSession;
14682 tANI_U8 i,num_channels = 0, ucDot11Mode;
14683 tANI_U8 *ChannelList = NULL;
14684 tANI_U32 sessionId;
14685 eHalStatus status = eHAL_STATUS_SUCCESS;
14686 tpCsrChannelInfo currChannelListInfo;
14687 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
14688
14689 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled)
14690 {
14691 return eHAL_STATUS_FAILURE;
14692 }
14693 status = csrRoamGetSessionIdFromBSSID(pMac,
14694 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
14695 &sessionId);
14696 /*The Dynamic Config Items Update may happen even if the state is in INIT.
14697 * It is important to ensure that the command is passed down to the FW only
14698 * if the Infra Station is in a connected state.A connected station could also be
14699 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
14700 * We also have to ensure that if there is a STOP command we always have to inform Riva,
14701 * irrespective of whichever state we are in.*/
14702 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
14703 (command != ROAM_SCAN_OFFLOAD_STOP))
14704 {
14705 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
14706 pMac->roam.neighborRoamInfo.neighborRoamState, command);
14707 return eHAL_STATUS_FAILURE;
14708 }
14709
14710 if ( !HAL_STATUS_SUCCESS( status ) )
14711 {
14712 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
14713 return eHAL_STATUS_FAILURE;
14714 }
14715 pSession = CSR_GET_SESSION( pMac, sessionId );
14716 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
14717 if (NULL == pRequestBuf)
14718 {
14719 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
14720 return eHAL_STATUS_FAILED_ALLOC;
14721 }
14722
14723 vos_mem_zero(pRequestBuf,sizeof(tSirRoamOffloadScanReq));
14724 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
14725 * host driver reloads, but Riva still up and running*/
14726 if(command == ROAM_SCAN_OFFLOAD_STOP)
14727 pRequestBuf->RoamScanOffloadEnabled = 0;
14728 else
14729 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
14730 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid, pNeighborRoamInfo->currAPbssid,
14731 sizeof(tCsrBssid));
14732 pRequestBuf->ConnectedNetwork.ssId.length =
14733 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
14734 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
14735 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
14736 pRequestBuf->ConnectedNetwork.ssId.length);
14737 pRequestBuf->ConnectedNetwork.authentication =
14738 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
14739 pRequestBuf->ConnectedNetwork.encryption =
14740 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
14741 pRequestBuf->ConnectedNetwork.mcencryption =
14742 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
14743 pRequestBuf->LookupThreshold =
14744 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
14745 pRequestBuf->RoamRssiDiff =
14746 pMac->roam.configParam.RoamRssiDiff;
14747 pRequestBuf->Command = command;
14748 pRequestBuf->StartScanReason = reason;
14749 pRequestBuf->NeighborScanTimerPeriod =
14750 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
14751 pRequestBuf->NeighborRoamScanRefreshPeriod =
14752 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
14753 pRequestBuf->NeighborScanChannelMinTime =
14754 pNeighborRoamInfo->cfgParams.minChannelScanTime;
14755 pRequestBuf->NeighborScanChannelMaxTime =
14756 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
14757 pRequestBuf->EmptyRefreshScanPeriod =
14758 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
14759#ifdef FEATURE_WLAN_CCX
14760 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
14761#endif
14762 if (
14763#ifdef FEATURE_WLAN_CCX
14764 ((pNeighborRoamInfo->isCCXAssoc) &&
14765 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
14766 eANI_BOOLEAN_FALSE)) ||
14767 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
14768#endif // CCX
14769 currChannelListInfo->numOfChannels == 0)
14770 {
14771
14772 /*Retreive the Channel Cache either from ini or from the Occupied Channels list.
14773 * Give Preference to INI Channels.*/
14774 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
14775 {
14776 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
14777 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels ;i++)
14778 {
14779 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14780 {
14781 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14782 }
14783 ChannelList++;
14784 }
14785 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14786 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
14787 }
14788 else{
14789 ChannelList = pMac->scan.occupiedChannels.channelList;
14790 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
14791 {
14792 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14793 {
14794 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14795 }
14796 ChannelList++;
14797 }
14798 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14799 /* If the profile changes as to what it was earlier, inform the FW through
14800 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
14801 * for the earlier profile and try to learn them afresh.*/
14802 if (reason == REASON_FLUSH_CHANNEL_LIST)
14803 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
14804 else {
14805 if (csrNeighborRoamIsNewConnectedProfile(pMac))
14806 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
14807 else
14808 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
14809 }
14810 }
14811 }
14812#ifdef FEATURE_WLAN_CCX
14813 else
14814 {
14815 /* If CCX is enabled, and a neighbor Report is received,then
14816 * Ignore the INI Channels or the Occupied Channel List. Consider
14817 * the channels in the neighbor list sent by the CCX AP.*/
14818 if (currChannelListInfo->numOfChannels != 0)
14819 {
14820 ChannelList = currChannelListInfo->ChannelList;
14821 for (i=0;i<currChannelListInfo->numOfChannels;i++)
14822 {
14823 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14824 {
14825 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14826 }
14827 ChannelList++;
14828 }
14829 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14830 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
14831 }
14832 }
14833#endif
14834 num_channels = 0;
14835 ChannelList = NULL;
14836
14837 /* Maintain the Valid Channels List*/
14838 if (0 == strncmp(pMac->scan.countryCodeCurrent, "KR", 2))
14839 {
14840 ChannelList = pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
14841 for(i=0; i<pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels; i++)
14842 {
14843 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14844 {
14845 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
14846 }
14847 ChannelList++;
14848 }
14849 pRequestBuf->ValidChannelCount = num_channels;
14850 } else {
14851 ChannelList = pMac->roam.validChannelList;
14852 for(i=0; i<pMac->roam.numValidChannels; i++)
14853 {
14854 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14855 {
14856 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
14857 }
14858 ChannelList++;
14859 }
14860 pRequestBuf->ValidChannelCount = num_channels;
14861 }
14862 pRequestBuf->MDID.mdiePresent = pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
14863 pRequestBuf->MDID.mobilityDomain = pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
14864 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
14865 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
14866 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
14867 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
14868 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
14869
14870 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
14871 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
14872 msg.type = WDA_START_ROAM_CANDIDATE_LOOKUP_REQ;
14873 msg.reserved = 0;
14874 msg.bodyptr = pRequestBuf;
14875 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
14876 {
14877 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_START_ROAM_CANDIDATE_LOOKUP_REQ message to WDA", __func__);
14878 vos_mem_free(pRequestBuf);
14879 return eHAL_STATUS_FAILURE;
14880 }
14881
14882 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
14883 return status;
14884}
14885#endif
14886
Jeff Johnson295189b2012-06-20 16:38:30 -070014887tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
14888 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
14889{
14890 tANI_BOOLEAN found = FALSE;
14891 eHalStatus status = eHAL_STATUS_SUCCESS;
14892 tCsrPeStatsReqInfo staEntry;
14893 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
14894 tListElem *pStaEntry = NULL;
14895 VOS_STATUS vosStatus;
14896 tPmcPowerState powerState;
14897 *pFound = FALSE;
14898
14899 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
14900 if(pStaEntry)
14901 {
14902 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
14903 if(pTempStaEntry->periodicity)
14904 {
14905 pTempStaEntry->periodicity =
14906 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
14907 }
14908 else
14909 {
14910 pTempStaEntry->periodicity = periodicity;
14911 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014912 pTempStaEntry->numClient++;
14913 found = TRUE;
14914 }
14915 else
14916 {
14917 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
14918 staEntry.numClient = 1;
14919 staEntry.periodicity = periodicity;
14920 staEntry.pMac = pMac;
14921 staEntry.rspPending = FALSE;
14922 staEntry.staId = staId;
14923 staEntry.statsMask = statsMask;
14924 staEntry.timerRunning = FALSE;
14925 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
14926 if(!pTempStaEntry)
14927 {
14928 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014929 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014930 return NULL;
14931 }
14932 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014933 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14934 if(ePMC_FULL_POWER == powerState)
14935 {
14936 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14937 {
14938 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14939 }
14940 }
14941 else
14942 {
14943 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14944 {
14945 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14946 }
14947 }
14948 if(!pTempStaEntry->timerRunning)
14949 {
14950 //send down a req in case of one time req, for periodic ones wait for timer to expire
14951 if(!pTempStaEntry->rspPending &&
14952 !pTempStaEntry->periodicity)
14953 {
14954 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14955 if(!HAL_STATUS_SUCCESS(status))
14956 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014957 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014958 }
14959 else
14960 {
14961 pTempStaEntry->rspPending = TRUE;
14962 }
14963 }
14964 if(pTempStaEntry->periodicity)
14965 {
14966 if(!found)
14967 {
14968
14969 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
14970 csrRoamPeStatsTimerHandler, pTempStaEntry );
14971 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14972 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014973 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014974 return NULL;
14975 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014976 }
14977 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014978 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070014979 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
14980 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14981 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014982 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014983 return NULL;
14984 }
14985 pTempStaEntry->timerRunning = TRUE;
14986 }
14987 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014988 *pFound = found;
14989 return pTempStaEntry;
14990}
14991
Jeff Johnson295189b2012-06-20 16:38:30 -070014992/*
14993 pStaEntry is no longer invalid upon the return of this function.
14994*/
14995static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
14996{
14997 if(pEntry)
14998 {
14999 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15000 {
15001 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015002 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015003 }
15004 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015005
15006void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15007{
15008 tListElem *pEntry;
15009 tCsrPeStatsReqInfo *pTempStaEntry;
15010 VOS_STATUS vosStatus;
15011 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015012 if(!pEntry)
15013 {
15014 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015015 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015016 return;
15017 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015018 while( pEntry )
15019 {
15020 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015021 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15022 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015023 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015024 if(pTempStaEntry->timerRunning)
15025 {
15026 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15027 /* If we are not able to stop the timer here, just remove
15028 * the entry from the linked list. Destroy the timer object
15029 * and free the memory in the timer CB
15030 */
15031 if( vosStatus == VOS_STATUS_SUCCESS )
15032 {
15033 /* the timer is successfully stopped */
15034 pTempStaEntry->timerRunning = FALSE;
15035
15036 /* Destroy the timer */
15037 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15038 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15039 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015040 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015041 }
15042 }
15043 else
15044 {
15045 // the timer could not be stopped. Hence destroy and free the
15046 // memory for the PE stat entry in the timer CB.
15047 pTempStaEntry->timerStopFailed = TRUE;
15048 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015049 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015050
15051 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15052 {
15053 // Only free the memory if we could stop the timer successfully
15054 if(!pTempStaEntry->timerStopFailed)
15055 {
15056 palFreeMemory(pMac->hHdd, pTempStaEntry);
15057 pTempStaEntry = NULL;
15058 }
15059 break;
15060 }
15061
15062 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15063 }
15064 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015065 return;
15066}
15067
15068
Jeff Johnsone7245742012-09-05 17:12:55 -070015069void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015070{
15071
Jeff Johnsone7245742012-09-05 17:12:55 -070015072 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15073 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15074 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15075 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15076 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15077 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15078 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015079 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015080 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15081 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15082 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15083 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15084 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15085 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015086 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015087 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15088 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015089
15090}
15091
Jeff Johnson295189b2012-06-20 16:38:30 -070015092void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15093 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15094{
15095 tANI_U8 stats[500];
15096 tANI_U8 *pStats = NULL;
15097 tANI_U32 tempMask = 0;
15098 tANI_U8 counter = 0;
15099 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015100 if(!callback)
15101 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015102 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015103 return;
15104 }
15105 if(!statsMask)
15106 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015107 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015108 return;
15109 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015110 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015111 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015112 while(tempMask)
15113 {
15114 if(tempMask & 1)
15115 {
15116 //new stats info from PE, fill up the stats strucutres in PMAC
15117 switch(counter)
15118 {
15119 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015120 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015121 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
15122 sizeof(tCsrSummaryStatsInfo));
15123 if(!HAL_STATUS_SUCCESS(status))
15124 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015125 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015126 }
15127 pStats += sizeof(tCsrSummaryStatsInfo);
15128 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015129 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015130 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015131 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
15132 sizeof(tCsrGlobalClassAStatsInfo));
15133 if(!HAL_STATUS_SUCCESS(status))
15134 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015135 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015136 }
15137 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015138 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015139 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015140 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015141 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
15142 sizeof(tCsrGlobalClassBStatsInfo));
15143 if(!HAL_STATUS_SUCCESS(status))
15144 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015145 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015146 }
15147 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015148 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015149 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015150 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015151 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
15152 sizeof(tCsrGlobalClassCStatsInfo));
15153 if(!HAL_STATUS_SUCCESS(status))
15154 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015155 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015156 }
15157 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015158 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015159 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015160 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015161 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
15162 sizeof(tCsrGlobalClassDStatsInfo));
15163 if(!HAL_STATUS_SUCCESS(status))
15164 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015165 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015166 }
15167 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015168 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015169 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015170 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015171 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
15172 sizeof(tCsrPerStaStatsInfo));
15173 if(!HAL_STATUS_SUCCESS(status))
15174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015175 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015176 }
15177 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015178 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015179 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015180 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015181 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015182 }
15183 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015184 tempMask >>=1;
15185 counter++;
15186 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015187 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070015188}
15189
Jeff Johnson295189b2012-06-20 16:38:30 -070015190eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
15191{
15192 tListElem *pEntry = NULL;
15193 tListElem *pPrevEntry = NULL;
15194 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15195 eHalStatus status = eHAL_STATUS_SUCCESS;
15196 VOS_STATUS vosStatus;
15197 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015198 if(!pEntry)
15199 {
15200 //list empty
15201 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015202 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015203 return status;
15204 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015205 while( pEntry )
15206 {
15207 if(pPrevEntry)
15208 {
15209 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15210 //send up the stats report
15211 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15212 pTempStaEntry->staId, pTempStaEntry->pContext);
15213 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15214 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015215 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015216 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
15217 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015218 pTempStaEntry->pPeStaEntry->numClient--;
15219 //check if we need to delete the entry from peStatsReqList too
15220 if(!pTempStaEntry->pPeStaEntry->numClient)
15221 {
15222 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
15223 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015224 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015225 //check if we need to stop the tl stats timer too
15226 pMac->roam.tlStatsReqInfo.numClient--;
15227 if(!pMac->roam.tlStatsReqInfo.numClient)
15228 {
15229 if(pMac->roam.tlStatsReqInfo.timerRunning)
15230 {
15231 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15232 if(!HAL_STATUS_SUCCESS(status))
15233 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015234 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015235 //we will continue
15236 }
15237 }
15238 pMac->roam.tlStatsReqInfo.periodicity = 0;
15239 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15240 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015241 if (pTempStaEntry->periodicity)
15242 {
15243 //While creating StaEntry in csrGetStatistics,
15244 //Initializing and starting timer only when periodicity is set.
15245 //So Stop and Destroy timer only when periodicity is set.
15246
Jeff Johnsone7245742012-09-05 17:12:55 -070015247 vos_timer_stop( &pTempStaEntry->timer );
15248 // Destroy the vos timer...
15249 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
15250 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15251 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015252 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015253 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015254 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015255
Jeff Johnson295189b2012-06-20 16:38:30 -070015256
15257 pPrevEntry = pEntry;
15258 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15259 }
15260 //the last one
15261 if(pPrevEntry)
15262 {
15263 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15264 //send up the stats report
15265 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15266 pTempStaEntry->staId, pTempStaEntry->pContext);
15267 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15268 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015269 return status;
15270
15271}
15272
Jeff Johnson295189b2012-06-20 16:38:30 -070015273eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
15274 tRequestFullPowerReason *pReason,
15275 tANI_BOOLEAN *pfNeedPower )
15276{
15277 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15278 tRequestFullPowerReason reason = eSME_REASON_OTHER;
15279 tPmcState pmcState;
15280 eHalStatus status = eHAL_STATUS_SUCCESS;
15281 // TODO : Session info unavailable
15282 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015283 if( pfNeedPower )
15284 {
15285 *pfNeedPower = eANI_BOOLEAN_FALSE;
15286 }
15287 //We only handle CSR commands
15288 if( !(eSmeCsrCommandMask & pCommand->command) )
15289 {
15290 return eHAL_STATUS_SUCCESS;
15291 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015292 //Check PMC state first
15293 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015294 switch( pmcState )
15295 {
15296 case REQUEST_IMPS:
15297 case IMPS:
15298 if( eSmeCommandScan == pCommand->command )
15299 {
15300 switch( pCommand->u.scanCmd.reason )
15301 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015302#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15303 case eCsrScanGetLfrResult:
15304#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015305 case eCsrScanGetResult:
15306 case eCsrScanBGScanAbort:
15307 case eCsrScanBGScanEnable:
15308 case eCsrScanGetScanChnInfo:
15309 //Internal process, no need for full power
15310 fNeedFullPower = eANI_BOOLEAN_FALSE;
15311 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015312 default:
15313 //Other scans are real scan, ask for power
15314 fNeedFullPower = eANI_BOOLEAN_TRUE;
15315 break;
15316 } //switch
15317 }
15318 else
15319 {
15320 //ask for power for roam and status change
15321 fNeedFullPower = eANI_BOOLEAN_TRUE;
15322 }
15323 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015324 case REQUEST_BMPS:
15325 case BMPS:
15326 case REQUEST_START_UAPSD:
15327 case UAPSD:
15328 //We treat WOWL same as BMPS
15329 case REQUEST_ENTER_WOWL:
15330 case WOWL:
15331 if( eSmeCommandRoam == pCommand->command )
15332 {
15333 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
15334 tCsrScanResult *pScanResult;
15335 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015336 switch ( pCommand->u.roamCmd.roamReason )
15337 {
15338 case eCsrForcedDisassoc:
15339 case eCsrForcedDisassocMICFailure:
15340 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15341 fNeedFullPower = eANI_BOOLEAN_TRUE;
15342 break;
15343 case eCsrSmeIssuedDisassocForHandoff:
15344 case eCsrForcedDeauth:
15345 case eCsrHddIssuedReassocToSameAP:
15346 case eCsrSmeIssuedReassocToSameAP:
15347 fNeedFullPower = eANI_BOOLEAN_TRUE;
15348 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015349 case eCsrCapsChange:
15350 fNeedFullPower = eANI_BOOLEAN_TRUE;
15351 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015352 default:
15353 //Check whether the profile is already connected. If so, no need for full power
15354 //Note: IBSS is ignored for now because we don't support powersave in IBSS
15355 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
15356 {
15357 //Only need to check the first one
15358 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
15359 if( pEntry )
15360 {
15361 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
15362#if 0
15363 // TODO : Session Specific info pConnectBssDesc
15364 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
15365 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
15366 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
15367 {
15368 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
15369 // with Authenticating first. To force this, stop the current association (Disassociate) and
15370 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
15371 // a new Association.
15372 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
15373 {
15374 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
15375 {
15376 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
15377 //No need for full power
15378 //Set the flag so the code later can avoid to do the above
15379 //check again.
15380 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
15381 break;
15382 }
15383 }
15384 }
15385#endif
15386 }
15387 }
15388 //If we are here, full power is needed
15389 fNeedFullPower = eANI_BOOLEAN_TRUE;
15390 break;
15391 }
15392 }
15393 else if( eSmeCommandWmStatusChange == pCommand->command )
15394 {
15395 //need full power for all
15396 fNeedFullPower = eANI_BOOLEAN_TRUE;
15397 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
15398 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015399#ifdef FEATURE_WLAN_TDLS
15400 else if( eSmeCommandTdlsAddPeer == pCommand->command )
15401 {
15402 //TDLS link is getting established. need full power
15403 fNeedFullPower = eANI_BOOLEAN_TRUE;
15404 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
15405 }
15406#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015407 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015408 case REQUEST_STOP_UAPSD:
15409 case REQUEST_EXIT_WOWL:
15410 if( eSmeCommandRoam == pCommand->command )
15411 {
15412 fNeedFullPower = eANI_BOOLEAN_TRUE;
15413 switch ( pCommand->u.roamCmd.roamReason )
15414 {
15415 case eCsrForcedDisassoc:
15416 case eCsrForcedDisassocMICFailure:
15417 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15418 break;
15419 default:
15420 break;
15421 }
15422 }
15423 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015424 case STOPPED:
15425 case REQUEST_STANDBY:
15426 case STANDBY:
15427 case LOW_POWER:
15428 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015429 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070015430 status = eHAL_STATUS_FAILURE;
15431 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015432 case FULL_POWER:
15433 case REQUEST_FULL_POWER:
15434 default:
15435 //No need to ask for full power. This has to be FULL_POWER state
15436 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015437 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070015438 if( pReason )
15439 {
15440 *pReason = reason;
15441 }
15442 if( pfNeedPower )
15443 {
15444 *pfNeedPower = fNeedFullPower;
15445 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015446 return ( status );
15447}
15448
Jeff Johnson295189b2012-06-20 16:38:30 -070015449static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15450{
15451 eHalStatus status = eHAL_STATUS_SUCCESS;
15452 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15453 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070015454 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070015455 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
15456 {
15457 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
15458 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015459 return ( status );
15460}
15461
Jeff Johnson295189b2012-06-20 16:38:30 -070015462tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
15463{
15464 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015465 if( pCmd )
15466 {
15467 pMac->roam.sPendingCommands++;
15468 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015469 return ( pCmd );
15470}
15471
Jeff Johnson295189b2012-06-20 16:38:30 -070015472void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
15473{
15474 if (pMac->roam.sPendingCommands > 0)
15475 {
15476 //All command allocated through csrGetCommandBuffer need to
15477 //decrement the pending count when releasing.
15478 pMac->roam.sPendingCommands--;
15479 smeReleaseCommand( pMac, pCommand );
15480 }
15481 else
15482 {
15483 smsLog(pMac, LOGE, FL( "no pending commands"));
15484 VOS_ASSERT(0);
15485 }
15486}
15487
Jeff Johnson295189b2012-06-20 16:38:30 -070015488//Return SUCCESS is the command is queued, failed
15489eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
15490{
15491 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015492 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
15493 {
15494 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
15495 pCommand->u.scanCmd.reason);
15496 return eHAL_STATUS_CSR_WRONG_STATE;
15497 }
15498
15499 //We can call request full power first before putting the command into pending Q
15500 //because we are holding SME lock at this point.
15501 status = csrRequestFullPower( pMac, pCommand );
15502 if( HAL_STATUS_SUCCESS( status ) )
15503 {
15504 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070015505 //make sure roamCmdPendingList is not empty first
15506 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
15507 if( fNoCmdPending )
15508 {
15509 smePushCommand( pMac, pCommand, fHighPriority );
15510 }
15511 else
15512 {
15513 //Other commands are waiting for PMC callback, queue the new command to the pending Q
15514 //no list lock is needed since SME lock is held
15515 if( !fHighPriority )
15516 {
15517 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15518 }
15519 else {
15520 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15521 }
15522 }
15523 }
15524 else if( eHAL_STATUS_PMC_PENDING == status )
15525 {
15526 //no list lock is needed since SME lock is held
15527 if( !fHighPriority )
15528 {
15529 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15530 }
15531 else {
15532 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15533 }
15534 //Let caller know the command is queue
15535 status = eHAL_STATUS_SUCCESS;
15536 }
15537 else
15538 {
15539 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
15540 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015541 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070015542 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015543 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015544}
Jeff Johnson295189b2012-06-20 16:38:30 -070015545eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
15546{
15547 eHalStatus status = eHAL_STATUS_SUCCESS;
15548 tSirUpdateAPWPSIEsReq *pMsg;
15549 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
15550
15551 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15552 if (NULL == pSession)
15553 {
15554 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15555 return eHAL_STATUS_FAILURE;
15556 }
15557
Jeff Johnson295189b2012-06-20 16:38:30 -070015558 do
15559 {
15560 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15561 if (!HAL_STATUS_SUCCESS(status)) break;
15562 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15563 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
15564
15565 pBuf = (tANI_U8 *)&pMsg->transactionId;
15566 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015567 // transactionId
15568 *pBuf = 0;
15569 *( pBuf + 1 ) = 0;
15570 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015571 // bssId
15572 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15573 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015574 //sessionId
15575 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015576 // APWPSIEs
15577 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
15578 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070015579 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015580 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015581 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015582 return ( status );
15583}
Jeff Johnson295189b2012-06-20 16:38:30 -070015584eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
15585{
15586 eHalStatus status = eHAL_STATUS_SUCCESS;
15587 tSirUpdateAPWPARSNIEsReq *pMsg;
15588 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015589 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15590 if (NULL == pSession)
15591 {
15592 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15593 return eHAL_STATUS_FAILURE;
15594 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015595 do
15596 {
15597 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
15598 if (!HAL_STATUS_SUCCESS(status)) break;
15599 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
15600 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015601 pBuf = (tANI_U8 *)&pMsg->transactionId;
15602 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015603 // transactionId
15604 *pBuf = 0;
15605 *( pBuf + 1 ) = 0;
15606 pBuf += sizeof(tANI_U16);
15607
15608 // bssId
15609 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15610 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015611 // sessionId
15612 *pBuf++ = (tANI_U8)sessionId;
15613
15614 // APWPARSNIEs
15615 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
15616 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015617 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015618 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015619 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015620 return ( status );
15621}
Jeff Johnson295189b2012-06-20 16:38:30 -070015622
15623#ifdef WLAN_FEATURE_VOWIFI_11R
15624//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
15625eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
15626{
15627 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15628 tpSirFTPreAuthReq pftPreAuthReq;
15629 tANI_U16 auth_req_len = 0;
15630 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015631 auth_req_len = sizeof(tSirFTPreAuthReq);
15632 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
15633 if (pftPreAuthReq == NULL)
15634 {
15635 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
15636 return eHAL_STATUS_RESOURCES;
15637 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015638 // Save the SME Session ID here. We need it while processing the preauth response
15639 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015640 vos_mem_zero(pftPreAuthReq, auth_req_len);
15641
15642 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
15643 sizeof(pBssDescription->length) + pBssDescription->length);
15644
15645 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
15646
15647 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
15648
Jeff Johnson295189b2012-06-20 16:38:30 -070015649 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015650 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
15651
Jeff Johnson295189b2012-06-20 16:38:30 -070015652#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080015653 if (csrRoamIs11rAssoc(pMac) &&
15654 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070015655 {
15656 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15657 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15658 pMac->ft.ftSmeContext.auth_ft_ies_length);
15659 }
15660 else
15661#endif
15662 {
15663 pftPreAuthReq->ft_ies_length = 0;
15664 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070015665 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
15666 sizeof(pBssDescription->length) + pBssDescription->length);
15667 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015668 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15669}
Jeff Johnson295189b2012-06-20 16:38:30 -070015670/*--------------------------------------------------------------------------
15671 * This will receive and process the FT Pre Auth Rsp from the current
15672 * associated ap.
15673 *
15674 * This will invoke the hdd call back. This is so that hdd can now
15675 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15676 ------------------------------------------------------------------------*/
15677void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15678{
15679 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15680 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015681#ifdef FEATURE_WLAN_LFR
15682 tCsrRoamInfo roamInfo;
15683#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015684
15685#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015686 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015687#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015688#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015689 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015690 if (status != eHAL_STATUS_SUCCESS) {
15691 /*
15692 * Bail out if pre-auth was not even processed.
15693 */
15694 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15695 return;
15696 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015697#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015698 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15699 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15700 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015701 // Implies a success
15702 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015703 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15704 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
15705 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070015706 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15707 * actual transition from the current to handoff AP is triggered */
15708 status = palTimerStart(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15709 60 * PAL_TIMER_TO_MS_UNIT,
15710 eANI_BOOLEAN_FALSE);
15711 if (eHAL_STATUS_SUCCESS != status)
15712 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015713 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015714 return;
15715 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015716 // Save the received response
15717 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15718 if (csrRoamIs11rAssoc(pMac))
15719 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15720 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15721
15722 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015723#ifdef FEATURE_WLAN_LFR
15724 // If Legacy Fast Roaming is enabled, signal the supplicant
15725 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015726 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015727 {
15728 // Save the bssid from the received response
15729 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15730 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15731 }
15732
15733#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015734
15735 // Done with it, init it.
15736 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15737}
15738#endif
15739#ifdef FEATURE_WLAN_BTAMP_UT_RF
15740void csrRoamJoinRetryTimerHandler(void *pv)
15741{
15742 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
15743 tpAniSirGlobal pMac = pInfo->pMac;
15744 tANI_U32 sessionId = pInfo->sessionId;
15745 tCsrRoamSession *pSession;
15746
15747 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15748 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015749 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015750 pSession = CSR_GET_SESSION( pMac, sessionId );
15751 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
15752 {
15753 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
15754 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015755 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015756 }
15757 }
15758 }
15759}
Jeff Johnson295189b2012-06-20 16:38:30 -070015760eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
15761{
15762 eHalStatus status = eHAL_STATUS_FAILURE;
15763 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15764
15765 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
15766 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015767 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070015768 pSession->maxRetryCount--;
15769 pSession->joinRetryTimerInfo.pMac = pMac;
15770 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
15771 status = palTimerStart(pMac->hHdd, pSession->hTimerJoinRetry, interval, eANI_BOOLEAN_FALSE);
15772 if(!HAL_STATUS_SUCCESS(status))
15773 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015774 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015775 }
15776 }
15777 else
15778 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015779 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070015780 pSession->maxRetryCount);
15781 }
15782
15783 return (status);
15784}
Jeff Johnson295189b2012-06-20 16:38:30 -070015785eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
15786{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015787 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070015788 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15789 {
15790 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerJoinRetry));
15791 }
15792
15793 return eHAL_STATUS_SUCCESS;
15794}
15795#endif
15796
15797
15798/*
15799 pBuf points to the beginning of the message
15800 LIM packs disassoc rsp as below,
15801 messageType - 2 bytes
15802 messageLength - 2 bytes
15803 sessionId - 1 byte
15804 transactionId - 2 bytes (tANI_U16)
15805 reasonCode - 4 bytes (sizeof(tSirResultCodes))
15806 peerMacAddr - 6 bytes
15807 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
15808*/
15809static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
15810{
15811 if(pBuf && pRsp)
15812 {
15813 pBuf += 4; //skip type and length
15814 pRsp->sessionId = *pBuf++;
15815 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
15816 pBuf += 2;
15817 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
15818 pBuf += 4;
15819 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
15820 }
15821}
15822
Jeff Johnsond13512a2012-07-17 11:42:19 -070015823eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15824{
15825 static uNvTables nvTables;
15826 eHalStatus status = eHAL_STATUS_SUCCESS;
15827 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
15828
15829 /* read the country code from NV and use it */
15830 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
15831 {
15832 palCopyMemory( pMac->hHdd, pCountry,
15833 nvTables.defaultCountryTable.countryCode,
15834 WNI_CFG_COUNTRY_CODE_LEN );
15835 return status;
15836 }
15837 else
15838 {
15839 palCopyMemory( pMac->hHdd, pCountry,
15840 "XXX",
15841 WNI_CFG_COUNTRY_CODE_LEN );
15842 status = eHAL_STATUS_FAILURE;
15843 return status;
15844 }
15845}
15846
15847eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15848{
15849 palCopyMemory( pMac->hHdd, pCountry,
15850 pMac->scan.countryCode11d,
15851 WNI_CFG_COUNTRY_CODE_LEN );
15852 return eHAL_STATUS_SUCCESS;
15853}
schang86c22c42013-03-13 18:41:24 -070015854
15855eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
15856{
15857 tSirSetTxPowerReq *pMsg = NULL;
15858 eHalStatus status = eHAL_STATUS_SUCCESS;
15859 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15860
15861 if (!pSession)
15862 {
15863 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15864 return eHAL_STATUS_FAILURE;
15865 }
15866
15867 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetTxPowerReq));
15868 if (HAL_STATUS_SUCCESS(status))
15869 {
15870 palZeroMemory(pMac->hHdd, (void *)pMsg, sizeof(tSirSetTxPowerReq));
15871 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
15872 pMsg->length = sizeof(tSirSetTxPowerReq);
15873 pMsg->mwPower = mW;
15874 palCopyMemory( pMac->hHdd,
15875 (tSirMacAddr *)pMsg->bssId,
15876 &pSession->selfMacAddr,
15877 sizeof(tSirMacAddr) );
15878 status = palSendMBMessage(pMac->hHdd, pMsg);
15879 if (!HAL_STATUS_SUCCESS(status))
15880 {
15881 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015882 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070015883 }
15884 }
15885 return status;
15886}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015887
15888/* Returns whether a session is in VOS_STA_MODE...or not */
15889tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
15890{
15891 tCsrRoamSession *pSession = NULL;
15892 pSession = CSR_GET_SESSION ( pMac, sessionId );
15893 if(!pSession)
15894 {
15895 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
15896 return eANI_BOOLEAN_FALSE;
15897 }
15898 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
15899 {
15900 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
15901 return eANI_BOOLEAN_FALSE;
15902 }
15903 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
15904 {
15905 return eANI_BOOLEAN_FALSE;
15906 }
15907 /* There is a possibility that the above check may fail,because
15908 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
15909 * when it is connected.So,we may sneak through the above check even
15910 * if we are not a STA mode INFRA station. So, if we sneak through
15911 * the above condition, we can use the following check if we are
15912 * really in STA Mode.*/
15913
15914 if ( NULL != pSession->pCurRoamProfile )
15915 {
15916 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
15917 {
15918 return eANI_BOOLEAN_TRUE;
15919 } else {
15920 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
15921 return eANI_BOOLEAN_FALSE;
15922 }
15923 }
15924
15925 return eANI_BOOLEAN_FALSE;
15926}