blob: 28acdc79fca7ee1ba64869935180a63014f1bc40 [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;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700723
724 if((csrIsConnStateConnected(pMac, sessionId)) ||
725 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 {
727 if(pProfile)
728 {
729 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
730 }
731 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 return (status);
733}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700734
Jeff Johnson295189b2012-06-20 16:38:30 -0700735eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
736{
737 eHalStatus status = eHAL_STATUS_SUCCESS;
738
739 if(pProfile->pBssDesc)
740 {
741 palFreeMemory(pMac->hHdd, pProfile->pBssDesc);
742 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700743 if(pProfile->pAddIEAssoc)
744 {
745 palFreeMemory(pMac->hHdd, pProfile->pAddIEAssoc);
746 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700747 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamConnectedProfile));
748 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
749 return (status);
750}
751
Jeff Johnson295189b2012-06-20 16:38:30 -0700752static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
753{
754 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700755 if( pConnectedInfo->pbFrames )
756 {
757 palFreeMemory( pMac->hHdd, pConnectedInfo->pbFrames );
758 pConnectedInfo->pbFrames = NULL;
759 }
760 pConnectedInfo->nBeaconLength = 0;
761 pConnectedInfo->nAssocReqLength = 0;
762 pConnectedInfo->nAssocRspLength = 0;
763 pConnectedInfo->staId = 0;
764#ifdef WLAN_FEATURE_VOWIFI_11R
765 pConnectedInfo->nRICRspLength = 0;
766#endif
767#ifdef FEATURE_WLAN_CCX
768 pConnectedInfo->nTspecIeLength = 0;
769#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 return ( status );
771}
772
Jeff Johnson295189b2012-06-20 16:38:30 -0700773
774
Jeff Johnsone7245742012-09-05 17:12:55 -0700775
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700776void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
777{
778 csrReinitPreauthCmd(pMac, pCommand);
779 csrReleaseCommand( pMac, pCommand );
780}
781
Jeff Johnson295189b2012-06-20 16:38:30 -0700782void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
783{
784 csrReinitRoamCmd(pMac, pCommand);
785 csrReleaseCommand( pMac, pCommand );
786}
787
Jeff Johnson295189b2012-06-20 16:38:30 -0700788void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
789{
790 csrReinitScanCmd(pMac, pCommand);
791 csrReleaseCommand( pMac, pCommand );
792}
793
Jeff Johnson295189b2012-06-20 16:38:30 -0700794void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
795{
796 csrReinitWmStatusChangeCmd(pMac, pCommand);
797 csrReleaseCommand( pMac, pCommand );
798}
799
Jeff Johnson295189b2012-06-20 16:38:30 -0700800void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
801{
802 palZeroMemory(pMac->hHdd, &pCommand->u.setKeyCmd, sizeof(tSetKeyCmd));
803}
804
Jeff Johnson295189b2012-06-20 16:38:30 -0700805void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
806{
807 palZeroMemory(pMac->hHdd, &pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd));
808}
809
Jeff Johnson295189b2012-06-20 16:38:30 -0700810void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
811{
812 csrReinitSetKeyCmd(pMac, pCommand);
813 csrReleaseCommand( pMac, pCommand );
814}
Jeff Johnson295189b2012-06-20 16:38:30 -0700815void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
816{
817 csrReinitRemoveKeyCmd(pMac, pCommand);
818 csrReleaseCommand( pMac, pCommand );
819}
Jeff Johnson295189b2012-06-20 16:38:30 -0700820void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
821{
822
823 if( eSmeCsrCommandMask & pCommand->command )
824 {
825 switch (pCommand->command)
826 {
827 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800828 // We need to inform the requester before dropping the scan command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800829 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback 0x%X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700830 __func__, pCommand->u.scanCmd.reason, (unsigned int)pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700831 if (NULL != pCommand->u.scanCmd.callback)
832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800833 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
835 }
836 csrReleaseCommandScan( pMac, pCommand );
837 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 case eSmeCommandRoam:
839 csrReleaseCommandRoam( pMac, pCommand );
840 break;
841
842 case eSmeCommandWmStatusChange:
843 csrReleaseCommandWmStatusChange( pMac, pCommand );
844 break;
845
846 case eSmeCommandSetKey:
847 csrReleaseCommandSetKey( pMac, pCommand );
848 break;
849
850 case eSmeCommandRemoveKey:
851 csrReleaseCommandRemoveKey( pMac, pCommand );
852 break;
853
854 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800855 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 csrReleaseCommand( pMac, pCommand );
857 break;
858 }
859 }
860}
861
Jeff Johnson295189b2012-06-20 16:38:30 -0700862void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
863{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800864 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]", NewSubstate, pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700865
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 if(pMac->roam.curSubState[sessionId] == NewSubstate)
867 {
868 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700869 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700870 pMac->roam.curSubState[sessionId] = NewSubstate;
871}
872
Jeff Johnson295189b2012-06-20 16:38:30 -0700873eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
874{
875 eCsrRoamState PreviousState;
876
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800877 smsLog( pMac, LOG1, "CSR RoamState: [ %d <== %d ]", NewRoamState, pMac->roam.curState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700878
879 PreviousState = pMac->roam.curState[sessionId];
880
881 if ( NewRoamState != pMac->roam.curState[sessionId] )
882 {
883 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
884 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
885 {
886 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
887 }
888
889 pMac->roam.curState[sessionId] = NewRoamState;
890 }
891 return( PreviousState );
892}
893
Jeff Johnson295189b2012-06-20 16:38:30 -0700894void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_U8 catOffset)
895{
896 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 if(catOffset)
898 {
899 pMac->roam.configParam.bCatRssiOffset = catOffset;
900 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
901 {
902 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)CSR_BEST_RSSI_VALUE - (int)(i * catOffset);
903 }
904 }
905}
906
Jeff Johnson295189b2012-06-20 16:38:30 -0700907static void initConfigParam(tpAniSirGlobal pMac)
908{
909 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
911 pMac->roam.configParam.channelBondingMode24GHz = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
912 pMac->roam.configParam.channelBondingMode5GHz = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700913
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
915 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
916 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
917 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
918 pMac->roam.configParam.HeartbeatThresh24 = 40;
919 pMac->roam.configParam.HeartbeatThresh50 = 40;
920 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
921 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
922 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700923 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 pMac->roam.configParam.RTSThreshold = 2346;
925 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
926 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
927 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
928 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
929 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
930 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
931 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
932 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
933 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
934 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
935 {
936 pMac->roam.configParam.BssPreferValue[i] = i;
937 }
938 csrAssignRssiForCategory(pMac, CSR_DEFAULT_RSSI_DB_GAP);
939 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
940 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
941 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
943 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
944 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
945 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
946 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
947 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800948 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
949 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -0700950 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700951#ifdef WLAN_AP_STA_CONCURRENCY
952 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
953 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
954 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
955 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
956 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700957 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
958 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700959#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700960 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
961 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
962 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
963 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700964#ifdef WLAN_FEATURE_VOWIFI_11R
965 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
966#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700967#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
968 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
969 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
970 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
971 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
972 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
973 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
974 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
975 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
976 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
977 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
978 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -0800979 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700980#endif
Jeff Johnsone7245742012-09-05 17:12:55 -0700981#ifdef WLAN_FEATURE_11AC
982 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
983#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700984
985 pMac->roam.configParam.addTSWhenACMIsOff = 0;
986 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -0700987
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700988 //Remove this code once SLM_Sessionization is supported
989 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -0700990 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700991
Jeff Johnsone7245742012-09-05 17:12:55 -0700992}
Jeff Johnson295189b2012-06-20 16:38:30 -0700993eCsrBand csrGetCurrentBand(tHalHandle hHal)
994{
995 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
996 return pMac->roam.configParam.bandCapability;
997}
Srinivas Girigowdade697412013-02-14 16:31:48 -0800998
999#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1000tANI_BOOLEAN csrIsChannelInCountryValidList(tpAniSirGlobal pMac, tANI_U8 channel)
1001{
1002 /* Get country code from CFG */
1003 tANI_U8 *pCountryCode = pMac->scan.countryCodeCurrent;
1004 tANI_U8 i = 0;
1005 v_BOOL_t retVal = FALSE;
1006 tANI_U8 *pCountryValidChannelList = pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
1007 tANI_U8 *pNumChannels = &pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
1008
1009 /* Compare against KR valid list */
1010 if ((0 == strncmp(pCountryCode, "KR", 2)) &&
1011 (NULL != pCountryValidChannelList))
1012 {
1013 for (i = 0; i <(*pNumChannels); i++)
1014 {
1015 if (channel == pCountryValidChannelList[i])
1016 {
1017 retVal = TRUE;
1018 break;
1019 }
1020 }
1021 }
1022 else
1023 {
1024 retVal = csrRoamIsChannelValid(pMac, channel);
1025 }
1026
1027 return retVal;
1028}
1029
1030void csr_SetRevision(tpAniSirGlobal pMac, tANI_U8 revision)
1031{
1032 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1033 pNeighborRoamInfo->cfgParams.countryChannelInfo.revision = revision;
1034}
1035
1036/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001037 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001038*/
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001039eHalStatus csrFlushBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001040{
1041 eHalStatus status = eHAL_STATUS_SUCCESS;
1042 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1043
1044 /* Free up the memory first (if required) */
1045 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1046 {
1047 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1048 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001049 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001050 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001051 return status;
1052}
1053
1054
1055
1056/*
1057 This function flushes the roam scan cache and creates fresh cache
1058 based on the input channel list
1059*/
1060eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1061 const tANI_U8 *pChannelList,
1062 const tANI_U8 numChannels)
1063{
1064 eHalStatus status = eHAL_STATUS_SUCCESS;
1065 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1066
Srinivas Girigowdade697412013-02-14 16:31:48 -08001067 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1068
1069 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1070 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1071
1072 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1073 {
1074 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1075 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1076 return eHAL_STATUS_RESOURCES;
1077 }
1078
1079 /* Update the roam global structure */
1080 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1081 pChannelList,
1082 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1083 return status;
1084}
1085
1086/* This function modifies the bgscan channel list set via config ini or
1087 runtime, whenever the band changes.
1088 if the band is auto, then no operation is performed on the channel list
1089 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1090 if the band is 5G, then make sure channel list contains only 5G valid channels
1091*/
1092eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1093 eCsrBand eBand)
1094{
1095 eHalStatus status = eHAL_STATUS_SUCCESS;
1096 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1097 tANI_U8 outNumChannels = 0;
1098 tANI_U8 inNumChannels = 0;
1099 tANI_U8 *inPtr = NULL;
1100 tANI_U8 i = 0;
1101 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1102
1103 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1104
1105 {
1106 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1107 "No update required for channel list "
1108 "either cfg.ini channel list is not set up or "
1109 "auto band (Band %d)", eBand);
1110 return status;
1111 }
1112
1113 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1114 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1115 if (eCSR_BAND_24 == eBand)
1116 {
1117 for (i = 0; i < inNumChannels; i++)
1118 {
1119 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrIsChannelInCountryValidList(pMac, inPtr[i]))
1120 {
1121 ChannelList[outNumChannels++] = inPtr[i];
1122 }
1123 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001124 csrFlushBgScanRoamChannelList(pMac);
1125 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001126 }
1127 else if (eCSR_BAND_5G == eBand)
1128 {
1129 for (i = 0; i < inNumChannels; i++)
1130 {
1131 /* Add 5G Non-DFS channel */
1132 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1133 csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1134 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1135 {
1136 ChannelList[outNumChannels++] = inPtr[i];
1137 }
1138 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001139 csrFlushBgScanRoamChannelList(pMac);
1140 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001141 }
1142 else if (eCSR_BAND_ALL == eBand)
1143 {
1144 for (i = 0; i < inNumChannels; i++)
1145 {
1146 if (csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1147 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1148 {
1149 ChannelList[outNumChannels++] = inPtr[i];
1150 }
1151 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001152 csrFlushBgScanRoamChannelList(pMac);
1153 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001154 }
1155 else
1156 {
1157 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1158 "Invalid band, No operation carried out (Band %d)", eBand);
1159 status = eHAL_STATUS_INVALID_PARAMETER;
1160 }
1161
1162 return status;
1163}
1164
1165/*
1166 This function initializes the valid channel list based on country code
1167*/
1168eHalStatus csrInitCountryValidChannelList(tpAniSirGlobal pMac,
1169 tANI_U8 Revision)
1170{
1171 eHalStatus status = eHAL_STATUS_SUCCESS;
1172 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001173 tANI_U8 **pOutChannelList = &pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001174 tANI_U8 *pNumChannels = &pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
1175 const tANI_U8 *pChannelList = NULL;
1176
1177 if (SME_KR_3 == Revision)
1178 {
1179 pChannelList = KR_3;
1180 *pNumChannels = sizeof(KR_3)/sizeof(KR_3[0]);
1181 }
1182 else if (SME_KR_24 == Revision)
1183 {
1184 pChannelList = KR_24;
1185 *pNumChannels = sizeof(KR_24)/sizeof(KR_24[0]);
1186 }
1187 else if (SME_KR_25 == Revision)
1188 {
1189 pChannelList = KR_25;
1190 *pNumChannels = sizeof(KR_25)/sizeof(KR_25[0]);
1191 }
1192 else
1193 return eHAL_STATUS_INVALID_PARAMETER;
1194
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001195 /* Free any existing channel list */
1196 vos_mem_free(*pOutChannelList);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001197
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001198 *pOutChannelList = vos_mem_malloc(*pNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001199
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001200 if (NULL == *pOutChannelList)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001201 {
1202 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1203 *pNumChannels = 0;
1204 return eHAL_STATUS_RESOURCES;
1205 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001206 /* Update the roam global structure */
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001207 palCopyMemory(pMac->hHdd, *pOutChannelList, pChannelList, *pNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001208 return status;
1209}
1210
1211#endif
1212
Jeff Johnson295189b2012-06-20 16:38:30 -07001213eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1214{
1215 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1216 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001217 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1218 (eBand == eCSR_BAND_24))
1219 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001220 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001222 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001223 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001224 pMac->roam.configParam.uCfgDot11Mode, eBand);
1225 return eHAL_STATUS_INVALID_PARAMETER;
1226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001227 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1228 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1229 (eBand == eCSR_BAND_5G))
1230 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001231 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001233 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001234 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 pMac->roam.configParam.uCfgDot11Mode, eBand);
1236 return eHAL_STATUS_INVALID_PARAMETER;
1237 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001238 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001239 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001240 pMac->roam.configParam.eBand = eBand;
1241 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 csrScanGetSupportedChannels( pMac );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001243#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1244 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
1245#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 status = csrInitGetChannels( pMac );
1247 if (eHAL_STATUS_SUCCESS == status)
1248 csrInitChannelList( hHal );
1249 return status;
1250}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001251
1252
Jeff Johnsone7245742012-09-05 17:12:55 -07001253/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1254 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1255 * Ideally we should have kept the ini value and enum value same and representing the same
1256 * cb values as in 11n standard i.e.
1257 * Set to 1 (SCA) if the secondary channel is above the primary channel
1258 * Set to 3 (SCB) if the secondary channel is below the primary channel
1259 * Set to 0 (SCN) if no secondary channel is present
1260 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1261 * 0 - secondary none
1262 * 1 - secondary LOW
1263 * 2 - secondary HIGH
1264 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1265 * The enum values are as follows:
1266 * PHY_SINGLE_CHANNEL_CENTERED = 0
1267 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1268 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1269 */
1270ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1271{
1272
1273 ePhyChanBondState phyCbState;
1274 switch (cbIniValue) {
1275 // secondary none
1276 case 0:
1277 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1278 break;
1279 // secondary LOW
1280 case 1:
1281 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1282 break;
1283 // secondary HIGH
1284 case 2:
1285 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1286 break;
1287#ifdef WLAN_FEATURE_11AC
1288 case 3:
1289 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1290 break;
1291 case 4:
1292 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1293 break;
1294 case 5:
1295 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1296 break;
1297 case 6:
1298 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1299 break;
1300 case 7:
1301 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1302 break;
1303 case 8:
1304 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1305 break;
1306 case 9:
1307 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1308 break;
1309#endif
1310 default:
1311 // If an invalid value is passed, disable CHANNEL BONDING
1312 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1313 break;
1314 }
1315 return phyCbState;
1316}
1317
1318v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1319{
1320
1321 v_U32_t cbIniValue;
1322 switch (phyCbState) {
1323 // secondary none
1324 case PHY_SINGLE_CHANNEL_CENTERED:
1325 cbIniValue = 0;
1326 break;
1327 // secondary LOW
1328 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1329 cbIniValue = 1;
1330 break;
1331 // secondary HIGH
1332 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1333 cbIniValue = 2;
1334 break;
1335#ifdef WLAN_FEATURE_11AC
1336 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1337 cbIniValue = 3;
1338 break;
1339 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1340 cbIniValue = 4;
1341 break;
1342 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1343 cbIniValue = 5;
1344 break;
1345 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1346 cbIniValue = 6;
1347 break;
1348 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1349 cbIniValue = 7;
1350 break;
1351 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1352 cbIniValue = 8;
1353 break;
1354 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1355 cbIniValue = 9;
1356 break;
1357#endif
1358 default:
1359 // return some invalid value
1360 cbIniValue = 10;
1361 break;
1362 }
1363 return cbIniValue;
1364}
Jeff Johnson295189b2012-06-20 16:38:30 -07001365
1366eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1367{
1368 eHalStatus status = eHAL_STATUS_SUCCESS;
1369
1370 if(pParam)
1371 {
1372 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1373 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1374 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1375 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1376 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1377 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1378
1379 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001380 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1381
Jeff Johnsone7245742012-09-05 17:12:55 -07001382 /* channelBondingMode5GHz plays a dual role right now
1383 * 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
1384 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1385 */
1386 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1387 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001388 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001389 }
1390 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1391 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1392 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001393 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001394 }
1395 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001396 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1397 pMac->roam.configParam.phyMode = pParam->phyMode;
1398 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1399 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1400 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1401 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1402 pMac->roam.configParam.TxRate = pParam->TxRate;
1403 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1404 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1405 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1406 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1407 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001408 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 //if HDD passed down non zero values then only update,
1410 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001411 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001412 {
1413 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1414 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001415 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001416 {
1417 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1418 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001419 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 {
1421 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1422 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001423 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 {
1425 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1426 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001427 if (pParam->nActiveMaxChnTimeBtc)
1428 {
1429 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1430 }
1431 if (pParam->nActiveMinChnTimeBtc)
1432 {
1433 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1434 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001435#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001436 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001437 {
1438 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1439 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001440 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001441 {
1442 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1443 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001444 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001445 {
1446 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1447 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001448 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001449 {
1450 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1451 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001452 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001453 {
1454 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1455 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001456 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001457 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001458 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1459 }
1460 if (pParam->nNumP2PChanCombinedConc)
1461 {
1462 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001463 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001464#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001465 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001466 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001467 {
1468 //Change the unit from second to microsecond
1469 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1471 {
1472 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1473 }
1474 else
1475 {
1476 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1477 }
1478 }
1479 else
1480 {
1481 pMac->roam.configParam.impsSleepTime = 0;
1482 }
1483 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1485 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 //if HDD passed down non zero values for age params, then only update,
1487 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001488 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 {
1490 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001492 if(pParam->scanAgeTimeNCNPS)
1493 {
1494 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 if(pParam->scanAgeTimeNCPS)
1497 {
1498 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001500 if(pParam->scanAgeTimeCNPS)
1501 {
1502 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1503 }
1504 if(pParam->scanAgeTimeCPS)
1505 {
1506 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1507 }
1508
1509 csrAssignRssiForCategory(pMac, pParam->bCatRssiOffset);
1510 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1511 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1512 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1513 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1514 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001515 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1516 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001517 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1518 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1519 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1520 //Assign this before calling CsrInit11dInfo
1521 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 if( csrIs11dSupported( pMac ) )
1523 {
1524 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1525 }
1526 else
1527 {
1528 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1529 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001530
1531 /* Initialize the power + channel information if 11h is enabled.
1532 If 11d is enabled this information has already been initialized */
1533 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1534 {
1535 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1536 }
1537
1538
Jeff Johnson295189b2012-06-20 16:38:30 -07001539#ifdef WLAN_FEATURE_VOWIFI_11R
1540 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001541 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001542#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001543#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001545 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001546 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001547 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001548 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001549 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001550 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001551 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001552 pMac->roam.configParam.nProbes = pParam->nProbes;
1553 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001554#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001555#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1556 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
1557#endif
1558#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001559 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
1560#endif
1561
Jeff Johnson295189b2012-06-20 16:38:30 -07001562#ifdef FEATURE_WLAN_CCX
1563 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1564#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001565#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1566 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.neighborRoamConfig, &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001567 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1568 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1569 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1570 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1571 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1572 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1573 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1574 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 {
1576 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001577 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 -07001578 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1579 {
1580 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1581 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001582 smsLog( pMac, LOG1, "");
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 }
1584#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1586 pMac->scan.fValidateList = pParam->fValidateList;
1587 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1588 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001589 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001591 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1592 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1593 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1594 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1595 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1596 * single session
1597 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001598 //Remove this code once SLM_Sessionization is supported
1599 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001600 pMac->roam.configParam.doBMPSWorkaround = 0;
1601
Jeff Johnsone7245742012-09-05 17:12:55 -07001602#ifdef WLAN_FEATURE_11AC
1603 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001604 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001605 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001606 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001607#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001608 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 }
1610
1611 return status;
1612}
1613
Jeff Johnson295189b2012-06-20 16:38:30 -07001614eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1615{
1616 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 if(pParam)
1618 {
1619 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1620 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1621 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1622 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1623 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1624 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001625 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1626 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1628 pParam->phyMode = pMac->roam.configParam.phyMode;
1629 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1630 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1631 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1632 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1633 pParam->TxRate = pMac->roam.configParam.TxRate;
1634 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1635 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1636 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1637 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1638 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001639 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1640 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1641 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1642 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001643 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1644 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1645 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001646#ifdef WLAN_AP_STA_CONCURRENCY
1647 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1648 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1649 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1650 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1651 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001652 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1653 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001654#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 //Change the unit from microsecond to second
1656 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1657 pParam->eBand = pMac->roam.configParam.eBand;
1658 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1659 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1660 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1661 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1662 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1663 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1664 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1665 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1666 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1667 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1668 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1669 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1670 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1672 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1673 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1674 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1676 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1677 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1678 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1679 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001680 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001681 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001682 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001683 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001684
1685#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1686 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1687#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001688#ifdef WLAN_FEATURE_11AC
1689 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001690 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001691 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001692#endif
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001693 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
Jeff Johnson295189b2012-06-20 16:38:30 -07001694 csrSetChannels(pMac, pParam);
1695
1696 status = eHAL_STATUS_SUCCESS;
1697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 return (status);
1699}
1700
Jeff Johnson295189b2012-06-20 16:38:30 -07001701eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1702{
1703 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1704 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1705 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1706 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001707 do
1708 {
1709 if(eCSR_BAND_24 == eBand)
1710 {
1711 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1712 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1713 }
1714 if(eCSR_BAND_5G == eBand)
1715 {
1716 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1717 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1718 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1719 )
1720 {
1721 break;
1722 }
1723 }
1724 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1725 {
1726 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1727 }
1728 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1729 {
1730 newPhyMode = eCSR_DOT11_MODE_AUTO;
1731 }
1732 else
1733 {
1734 //Check for dual band and higher capability first
1735 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1736 {
1737 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1738 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1739 }
1740 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1741 {
1742 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1743 if(eCSR_BAND_24 == eBand) break;
1744 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1745 eBand = eCSR_BAND_5G;
1746 }
1747 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1748 {
1749 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1750 if(eCSR_BAND_5G == eBand) break;
1751 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1752 eBand = eCSR_BAND_24;
1753 }
1754 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1755 {
1756 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1757 if(eCSR_BAND_5G == eBand) break;
1758 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1759 eBand = eCSR_BAND_24;
1760 }
1761 else if(eCSR_DOT11_MODE_11n & phyMode)
1762 {
1763 newPhyMode = eCSR_DOT11_MODE_11n;
1764 }
1765 else if(eCSR_DOT11_MODE_abg & phyMode)
1766 {
1767 newPhyMode = eCSR_DOT11_MODE_abg;
1768 }
1769 else if(eCSR_DOT11_MODE_11a & phyMode)
1770 {
1771 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1772 {
1773 if(eCSR_BAND_ALL == eBand)
1774 {
1775 newPhyMode = eCSR_DOT11_MODE_abg;
1776 }
1777 else
1778 {
1779 //bad setting
1780 break;
1781 }
1782 }
1783 else
1784 {
1785 newPhyMode = eCSR_DOT11_MODE_11a;
1786 eBand = eCSR_BAND_5G;
1787 }
1788 }
1789 else if(eCSR_DOT11_MODE_11g & phyMode)
1790 {
1791 newPhyMode = eCSR_DOT11_MODE_11g;
1792 eBand = eCSR_BAND_24;
1793 }
1794 else if(eCSR_DOT11_MODE_11b & phyMode)
1795 {
1796 newPhyMode = eCSR_DOT11_MODE_11b;
1797 eBand = eCSR_BAND_24;
1798 }
1799 else
1800 {
1801 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001802 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 newPhyMode = eCSR_DOT11_MODE_AUTO;
1804 }
1805 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001806 //Done validating
1807 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001808 //Now we need to check whether a restart is needed.
1809 if(eBand != pMac->roam.configParam.eBand)
1810 {
1811 fRestartNeeded = eANI_BOOLEAN_TRUE;
1812 break;
1813 }
1814 if(newPhyMode != pMac->roam.configParam.phyMode)
1815 {
1816 fRestartNeeded = eANI_BOOLEAN_TRUE;
1817 break;
1818 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 if(HAL_STATUS_SUCCESS(status))
1821 {
1822 pMac->roam.configParam.eBand = eBand;
1823 pMac->roam.configParam.phyMode = newPhyMode;
1824 if(pfRestartNeeded)
1825 {
1826 *pfRestartNeeded = fRestartNeeded;
1827 }
1828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 return (status);
1830}
1831
Jeff Johnson295189b2012-06-20 16:38:30 -07001832void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
1833{
1834 tANI_U8 Index;
1835 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 // for dual band NICs, don't need to trim the channel list....
1837 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
1838 {
1839 // 2.4 GHz band operation requires the channel list to be trimmed to
1840 // the 2.4 GHz channels only...
1841 if ( CSR_IS_24_BAND_ONLY( pMac ) )
1842 {
1843 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
1844 Index++ )
1845 {
1846 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
1847 {
1848 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1849 cChannels++;
1850 }
1851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1853 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1854 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1855 // only if we need to.
1856 //
1857 // The amount of memory to clear is the number of channesl that we trimmed
1858 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1859
1860 if ( pChannelList->numChannels > cChannels )
1861 {
1862 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1863 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1864
1865 }
1866
1867 pChannelList->numChannels = cChannels;
1868 }
1869 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
1870 {
1871 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
1872 {
1873 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
1874 {
1875 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1876 cChannels++;
1877 }
1878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1880 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1881 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1882 // only if we need to.
1883 //
1884 // The amount of memory to clear is the number of channesl that we trimmed
1885 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1886 if ( pChannelList->numChannels > cChannels )
1887 {
1888 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1889 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1890 }
1891
1892 pChannelList->numChannels = cChannels;
1893 }
1894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001895}
Jeff Johnson295189b2012-06-20 16:38:30 -07001896#define INFRA_AP_DEFAULT_CHANNEL 6
1897eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
1898{
1899 tANI_U8 index= 0;
1900 eHalStatus status = eHAL_STATUS_FAILURE;
1901 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
1902 {
1903 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
1904 status = eHAL_STATUS_SUCCESS;
1905 break;
1906 }
1907 }
1908 return status;
1909}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001910
1911eHalStatus csrGet5GChannels(tpAniSirGlobal pMac)
1912{
1913 eHalStatus status = eHAL_STATUS_SUCCESS;
1914 tANI_U8 num20MHzChannelsFound = 0;
1915 VOS_STATUS vosStatus;
1916 tANI_U8 num40MHzChannelsFound = 0;
1917 tANI_U8 Index = 0;
1918 tANI_U8 channelList = 0;
1919
1920 // Updating the defaultpower Table for changed Domain Id
1921 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1922 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1923
1924 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1925 {
1926 smsLog( pMac, LOGE, FL("failed to get channels"));
1927 status = eHAL_STATUS_FAILURE;
1928 }
1929 else
1930 {
1931 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1932 {
1933 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1934 }
1935
1936 // Move the only 5GHZ channel list to the global data,
1937 // As 2.4GHZ list coming from the AP for the changed domain
1938 // structure -- this will be used as the scan list
1939 for(channelList = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1940 {
1941 // If Channel is 5GHz just break the for loop
1942 if(!(pMac->scan.base20MHzChannels.channelList[ channelList ] > 0 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 14))
1943 break;
1944 }
1945 // Update the 5G channels from nv.bin
1946 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1947 {
1948 if(pMac->scan.defaultPowerTable[Index].chanId >= 36 && pMac->scan.defaultPowerTable[Index].chanId <= 165)
1949 {
Krunal Sonia75019a2013-05-01 01:08:22 -07001950 if (channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN)
1951 {
1952 pMac->scan.base20MHzChannels.channelList[ channelList ] = pMac->scan.defaultPowerTable[Index].chanId;
1953 channelList++;
1954 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001955 }
1956 }
1957
1958 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1959 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1960 // Filling the remaining index as Zero Just for causion
1961 for(Index = pMac->scan.base20MHzChannels.numChannels; Index < WNI_CFG_VALID_CHANNEL_LIST_LEN; Index++)
1962 pMac->scan.base20MHzChannels.channelList[ Index ] = 0;
1963 }
1964 return status;
1965}
1966
1967eHalStatus csrGet24GChannels(tpAniSirGlobal pMac)
1968{
1969 eHalStatus status = eHAL_STATUS_SUCCESS;
1970 tANI_U8 num20MHzChannelsFound = 0;
1971 VOS_STATUS vosStatus;
1972 tANI_U8 Index = 0;
1973 tANI_U8 num40MHzChannelsFound = 0;
1974 tANI_U8 channelList5GBackup[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}, nuum5GchannelListBackup;
1975 tANI_U8 channelList = 0;
1976
1977 // Read the scan channel list (including the power limit) from EEPROM
1978 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1979 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1980
1981 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1982 {
1983 smsLog( pMac, LOGE, FL("failed to get channels \n"));
1984 status = eHAL_STATUS_FAILURE;
1985 }
1986 else
1987 {
1988 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1989 {
1990 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1991 }
1992
1993 // Move the 2.4GHZ channel list only to the global data,
1994 // As 5GHz list been provided by AP as part of 11d IE
1995 // structure -- this will be used as the scan list
1996 for(channelList = 0, nuum5GchannelListBackup = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1997 {
1998 if(pMac->scan.base20MHzChannels.channelList[ channelList ] >= 36 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 165)
1999 {
2000 // First taking the 5GHz channel list backup
2001 channelList5GBackup[nuum5GchannelListBackup] = pMac->scan.base20MHzChannels.channelList[ channelList ];
2002 nuum5GchannelListBackup++;
2003 }
2004 }
2005 // Updating the 2.4GHz list
2006 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2007 {
2008 if(pMac->scan.defaultPowerTable[Index].chanId > 0 && pMac->scan.defaultPowerTable[Index].chanId <= 14)
2009 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[Index].chanId;
2010 }
2011 // Restoring the Backed up 5 GHZ channels
2012 for(channelList = 0;channelList < nuum5GchannelListBackup; channelList++ )
2013 {
Krunal Sonia75019a2013-05-01 01:08:22 -07002014 if (Index < WNI_CFG_VALID_CHANNEL_LIST_LEN)
2015 {
2016 pMac->scan.base20MHzChannels.channelList[ Index ] = channelList5GBackup[channelList];
2017 Index++;
2018 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002019 }
2020
2021 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > Index) ? num20MHzChannelsFound : Index;
2022 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > Index) ? num20MHzChannelsFound : Index;
2023 }
2024 return (status);
2025}
2026
Jeff Johnson295189b2012-06-20 16:38:30 -07002027eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2028{
2029 eHalStatus status = eHAL_STATUS_SUCCESS;
2030 tANI_U8 num20MHzChannelsFound = 0;
2031 VOS_STATUS vosStatus;
2032 tANI_U8 Index = 0;
2033 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002034
Jeff Johnson295189b2012-06-20 16:38:30 -07002035
2036 //TODO: this interface changed to include the 40MHz channel list
2037 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2038 // Read the scan channel list (including the power limit) from EEPROM
2039 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2040 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2041 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2042 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002043 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002044 status = eHAL_STATUS_FAILURE;
2045 }
2046 else
2047 {
2048 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2049 {
2050 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2051 }
2052 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2053 // Move the channel list to the global data
2054 // structure -- this will be used as the scan list
2055 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2056 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 }
2059 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2060 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2061 {
2062 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2063 }
2064 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2065 {
2066 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2067 }
2068 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2069 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 return (status);
2071}
2072
Jeff Johnson295189b2012-06-20 16:38:30 -07002073eHalStatus csrInitChannelList( tHalHandle hHal )
2074{
2075 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2076 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2078 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002079 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2080 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002081 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002082 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002083
2084 return (status);
2085}
Jeff Johnson295189b2012-06-20 16:38:30 -07002086eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2087 tCsrUpdateConfigParam *pUpdateConfigParam)
2088{
2089 eHalStatus status = eHAL_STATUS_FAILURE;
2090 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2092 status = CsrInit11dInfo(pMac, ps11dinfo);
2093 return status;
2094}
2095
Jeff Johnson295189b2012-06-20 16:38:30 -07002096static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2097{
2098 eHalStatus status = eHAL_STATUS_FAILURE;
2099 tANI_U8 index;
2100 tANI_U32 count=0;
2101 tSirMacChanInfo *pChanInfo;
2102 tSirMacChanInfo *pChanInfoStart;
2103 tANI_BOOLEAN applyConfig = TRUE;
2104
2105 if(!ps11dinfo)
2106 {
2107 return (status);
2108 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2110 {
2111 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2112 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
2113 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
2114 if(!HAL_STATUS_SUCCESS(status)) return (status);
2115 }
2116 else
2117 {
2118 //No change
2119 return (eHAL_STATUS_SUCCESS);
2120 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 //legacy maintenance
2122 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
2123 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2124 if(!HAL_STATUS_SUCCESS(status)) return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002125 //Tush: at csropen get this initialized with default, during csr reset if this
2126 // already set with some value no need initilaize with default again
2127 if(0 == pMac->scan.countryCodeCurrent[0])
2128 {
2129 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
2130 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2131 if(!HAL_STATUS_SUCCESS(status)) return (status);
2132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 // need to add the max power channel list
2134 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2135 {
2136 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2137 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002138 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2139 {
2140 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2141 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2142 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2143 pChanInfo++;
2144 count++;
2145 }
2146 if(count)
2147 {
2148 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2149 }
2150 palFreeMemory(pMac->hHdd, pChanInfoStart);
2151 }
2152 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2153 if( HAL_STATUS_SUCCESS(status) )
2154 {
2155 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2156 {
2157 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2158 {
2159 applyConfig = FALSE;
2160 }
2161 }
2162
2163 if(TRUE == applyConfig)
2164 {
2165 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002166 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002167 }
2168
2169 }
2170 return (status);
2171}
2172/* Initialize the Channel + Power List in the local cache and in the CFG */
2173eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2174{
2175 tANI_U8 index;
2176 tANI_U32 count=0;
2177 tSirMacChanInfo *pChanInfo;
2178 tSirMacChanInfo *pChanInfoStart;
2179
2180 if(!ps11dinfo || !pMac)
2181 {
2182 return eHAL_STATUS_FAILURE;
2183 }
2184
2185 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2186 {
2187 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2188 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002189
2190 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2191 {
2192 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2193 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2194 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2195 pChanInfo++;
2196 count++;
2197 }
2198 if(count)
2199 {
2200 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2201 }
2202 palFreeMemory(pMac->hHdd, pChanInfoStart);
2203 }
2204
Jeff Johnsone7245742012-09-05 17:12:55 -07002205 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002206}
2207
2208//pCommand may be NULL
2209//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2210void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2211{
2212 tListElem *pEntry, *pNextEntry;
2213 tSmeCmd *pDupCommand;
2214 tDblLinkList localList;
2215
2216 vos_mem_zero(&localList, sizeof(tDblLinkList));
2217 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2218 {
2219 smsLog(pMac, LOGE, FL(" failed to open list"));
2220 return;
2221 }
2222 csrLLLock( &pMac->sme.smeCmdPendingList );
2223 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2224 while( pEntry )
2225 {
2226 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2227 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002228 // Remove the previous command if..
2229 // - the new roam command is for the same RoamReason...
2230 // - the new roam command is a NewProfileList.
2231 // - the new roam command is a Forced Dissoc
2232 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2233 if (
2234 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2235 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002236 /* This peermac check is requried for Softap/GO scenarios
2237 * For STA scenario below OR check will suffice as pCommand will
2238 * always be NULL for STA scenarios
2239 */
2240 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2242 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2243 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2244 ||
2245 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002246 ( (sessionId == pDupCommand->sessionId) &&
2247 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002248 ((eCsrForcedDisassoc == eRoamReason) ||
2249 (eCsrHddIssued == eRoamReason))
2250 )
2251 )
2252 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002253 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 // Remove the 'stale' roam command from the pending list...
2255 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2256 {
2257 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2258 }
2259 }
2260 pEntry = pNextEntry;
2261 }
2262 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2263
2264 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2265 {
2266 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2267 //Tell caller that the command is cancelled
2268 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2269 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2270 csrReleaseCommandRoam(pMac, pDupCommand);
2271 }
2272 csrLLClose(&localList);
2273}
Jeff Johnson295189b2012-06-20 16:38:30 -07002274eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2275 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2276{
2277 eHalStatus status = eHAL_STATUS_SUCCESS;
2278#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2279 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2280#endif
2281 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002282 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2283 {
2284 pSession = CSR_GET_SESSION( pMac, sessionId );
2285 }
2286 else
2287 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002288 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 VOS_ASSERT(0);
2290 return eHAL_STATUS_FAILURE;
2291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2293 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002294 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002296 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2297 /*
2298 * Decrement bRefAssocStartCnt for FT reassoc failure.
2299 * Reason: For FT reassoc failures, we first call
2300 * csrRoamCallCallback before notifying a failed roam
2301 * completion through csrRoamComplete. The latter in
2302 * turn calls csrRoamProcessResults which tries to
2303 * once again call csrRoamCallCallback if bRefAssocStartCnt
2304 * is non-zero. Since this is redundant for FT reassoc
2305 * failure, decrement bRefAssocStartCnt.
2306 */
2307 pSession->bRefAssocStartCnt--;
2308 }
2309
Jeff Johnson295189b2012-06-20 16:38:30 -07002310 if ( (pSession == NULL) ||
2311 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2312 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002313 smsLog(pMac, LOG1, "Session ID is not valid");
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 return eHAL_STATUS_FAILURE;
2315 }
2316
2317 if(NULL != pSession->callback)
2318 {
2319 if( pRoamInfo )
2320 {
2321 pRoamInfo->sessionId = (tANI_U8)sessionId;
2322 }
2323
2324 /* avoid holding the global lock when making the roaming callback , original change came
2325 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2326 is possible on other OS ports where the callback may need to take locks to protect
2327 HDD state
2328 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2329 that may actually depend on the lock being held */
2330 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2331 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2332 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2333 }
2334 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2335 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2336#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2337 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
2338 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2339 {
2340 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2341 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2342 if(NULL != pRoamInfo->pBssDesc)
2343 {
2344 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2345 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2348 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2349 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
2350 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2351 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2352 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002354 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2355 {
2356 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2357 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2358 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002360 if(eCSR_ROAM_RESULT_FORCED == u2)
2361 {
2362 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2363 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2364 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2365 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002366 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2367 {
2368 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2369 connectionStatus.reason = eCSR_REASON_DISASSOC;
2370 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002372 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2373 {
2374 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2375 connectionStatus.reason = eCSR_REASON_DEAUTH;
2376 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002378#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2379
2380 return (status);
2381}
Jeff Johnson295189b2012-06-20 16:38:30 -07002382// Returns whether handoff is currently in progress or not
2383tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2384{
2385#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2386 return csrNeighborRoamIsHandoffInProgress(pMac);
2387#else
2388 return eANI_BOOLEAN_FALSE;
2389#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002390}
Jeff Johnson295189b2012-06-20 16:38:30 -07002391eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2392 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2393{
2394 eHalStatus status = eHAL_STATUS_SUCCESS;
2395 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2396 tANI_U16 reasonCode;
2397 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002398
2399 if(!pSession)
2400 {
2401 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2402 return eHAL_STATUS_FAILURE;
2403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002404
2405 //Restore AC weight in case we change it
2406 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2407 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002408 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 -07002409 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2410 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2411 }
2412
2413 if ( fMICFailure )
2414 {
2415 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2416 }
2417 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2418 {
2419 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002420 }
2421 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 {
2423 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2424 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002425#ifdef WLAN_FEATURE_VOWIFI_11R
2426 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2427 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2428 {
2429 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2430 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002431 }
2432 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002433#endif
2434 if(pSession->pConnectBssDesc)
2435 {
2436 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2437 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002438
Jeff Johnson295189b2012-06-20 16:38:30 -07002439
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002440 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2441 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2442 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2443
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2445
2446 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2447
2448 if(HAL_STATUS_SUCCESS(status))
2449 {
2450 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002451#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2452 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2453 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2454 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002455 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2457 }
2458#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002459 }
2460 else
2461 {
2462 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2463 }
2464
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 return (status);
2466}
Jeff Johnson295189b2012-06-20 16:38:30 -07002467
Jeff Johnson295189b2012-06-20 16:38:30 -07002468/* ---------------------------------------------------------------------------
2469 \fn csrRoamIssueDisassociateStaCmd
2470 \brief csr function that HDD calls to disassociate a associated station
2471 \param sessionId - session Id for Soft AP
2472 \param pPeerMacAddr - MAC of associated station to delete
2473 \param reason - reason code, be one of the tSirMacReasonCodes
2474 \return eHalStatus
2475 ---------------------------------------------------------------------------*/
2476eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2477 tANI_U32 sessionId,
2478 tANI_U8 *pPeerMacAddr,
2479 tANI_U32 reason)
2480{
2481 eHalStatus status = eHAL_STATUS_SUCCESS;
2482 tSmeCmd *pCommand;
2483
2484 do
2485 {
2486 pCommand = csrGetCommandBuffer( pMac );
2487 if ( !pCommand )
2488 {
2489 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2490 status = eHAL_STATUS_RESOURCES;
2491 break;
2492 }
2493 pCommand->command = eSmeCommandRoam;
2494 pCommand->sessionId = (tANI_U8)sessionId;
2495 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2496 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2497 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2498 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2499 if( !HAL_STATUS_SUCCESS( status ) )
2500 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002501 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 csrReleaseCommandRoam( pMac, pCommand );
2503 }
2504 }while(0);
2505
2506 return status;
2507}
2508
2509
Jeff Johnson295189b2012-06-20 16:38:30 -07002510/* ---------------------------------------------------------------------------
2511 \fn csrRoamIssueDeauthSta
2512 \brief csr function that HDD calls to delete a associated station
2513 \param sessionId - session Id for Soft AP
2514 \param pPeerMacAddr - MAC of associated station to delete
2515 \param reason - reason code, be one of the tSirMacReasonCodes
2516 \return eHalStatus
2517 ---------------------------------------------------------------------------*/
2518eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2519 tANI_U32 sessionId,
2520 tANI_U8 *pPeerMacAddr,
2521 tANI_U32 reason)
2522{
2523 eHalStatus status = eHAL_STATUS_SUCCESS;
2524 tSmeCmd *pCommand;
2525
2526 do
2527 {
2528 pCommand = csrGetCommandBuffer( pMac );
2529 if ( !pCommand )
2530 {
2531 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2532 status = eHAL_STATUS_RESOURCES;
2533 break;
2534 }
2535 pCommand->command = eSmeCommandRoam;
2536 pCommand->sessionId = (tANI_U8)sessionId;
2537 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2538 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2539 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2540 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2541 if( !HAL_STATUS_SUCCESS( status ) )
2542 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002543 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 csrReleaseCommandRoam( pMac, pCommand );
2545 }
2546 }while(0);
2547
2548 return status;
2549}
Jeff Johnson295189b2012-06-20 16:38:30 -07002550eHalStatus
2551csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2552 tANI_BOOLEAN bEnable )
2553{
2554 eHalStatus status = eHAL_STATUS_FAILURE;
2555 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2556 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 if (!pSession)
2558 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002559 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 return (status);
2561 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 if (pSession->pConnectBssDesc)
2563 {
2564 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2565 }
2566 else
2567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002568 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 return (status);
2570 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002571 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 -07002572 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2573 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] , bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2575 return (status);
2576}
Jeff Johnson295189b2012-06-20 16:38:30 -07002577eHalStatus
2578csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2579 VOS_MODULE_ID modId, void *pUsrContext,
2580 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2581{
2582 eHalStatus status = eHAL_STATUS_SUCCESS;
2583 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2584 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 if (!pSession)
2586 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002587 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002588 return (status);
2589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 if(pSession->pConnectBssDesc)
2591 {
2592 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2593 }
2594 else
2595 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002596 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 return (status);
2598 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002599 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2601 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2603 return (status);
2604}
Jeff Johnson295189b2012-06-20 16:38:30 -07002605eHalStatus
2606csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2607 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2608{
2609 eHalStatus status = eHAL_STATUS_SUCCESS;
2610 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2611 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2612
2613 if (!pSession)
2614 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002615 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 return (status);
2617 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 if(pSession->pConnectBssDesc)
2619 {
2620 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2621 }
2622 else
2623 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002624 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002625 return (status);
2626 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002627 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002628 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2629 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2630
2631 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2632
2633 return (status);
2634}
Jeff Johnson295189b2012-06-20 16:38:30 -07002635eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2636{
2637 eHalStatus status = eHAL_STATUS_SUCCESS;
2638 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2639 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002640
2641 if (!pSession)
2642 {
2643 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2644 return eHAL_STATUS_FAILURE;
2645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002646
2647 if(pSession->pConnectBssDesc)
2648 {
2649 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2650 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002651 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002652 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2653 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002654 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2655
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302656 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002657 if(!HAL_STATUS_SUCCESS(status))
2658 {
2659 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2660 }
2661
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 return (status);
2663}
2664
Jeff Johnson295189b2012-06-20 16:38:30 -07002665eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2666{
2667 eHalStatus status = eHAL_STATUS_SUCCESS;
2668 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2669 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002670
2671 if(!pSession)
2672 {
2673 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2674 return eHAL_STATUS_FAILURE;
2675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002676
2677 // If no BSS description was found in this connection (happens with start IBSS), then
2678 // nix the BSS description that we keep around for the connected BSS) and get out...
2679 if(NULL == pBssDesc)
2680 {
2681 csrFreeConnectBssDesc(pMac, sessionId);
2682 }
2683 else
2684 {
2685 size = pBssDesc->length + sizeof( pBssDesc->length );
2686 if(NULL != pSession->pConnectBssDesc)
2687 {
2688 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2689 {
2690 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2691 csrFreeConnectBssDesc(pMac, sessionId);
2692 }
2693 }
2694 if(NULL == pSession->pConnectBssDesc)
2695 {
2696 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2697 }
2698 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2699 {
2700 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2701 }
2702 }
2703
2704 return (status);
2705}
2706
Jeff Johnson295189b2012-06-20 16:38:30 -07002707eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2708 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2709 tDot11fBeaconIEs *pIes)
2710{
2711 eHalStatus status = eHAL_STATUS_SUCCESS;
2712 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302714 if (pIes == NULL)
2715 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002716
Jeff Johnson295189b2012-06-20 16:38:30 -07002717 do
2718 {
2719 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2720 //get qos
2721 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2722 //get SSID
2723 if(pIes->SSID.present)
2724 {
2725 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2726 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2727 }
2728 else
2729 pBssConfig->SSID.length = 0;
2730 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2731 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002732 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 //Return failed if profile doesn't have an SSID either.
2734 if(pProfile->SSIDs.numOfSSIDs == 0)
2735 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002736 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 status = eHAL_STATUS_FAILURE;
2738 break;
2739 }
2740 }
2741 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2742 {
2743 pBssConfig->eBand = eCSR_BAND_5G;
2744 }
2745 else
2746 {
2747 pBssConfig->eBand = eCSR_BAND_24;
2748 }
2749 //phymode
2750 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2751 {
2752 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2753 }
2754 else
2755 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002756 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 //force it
2758 if(eCSR_BAND_24 == pBssConfig->eBand)
2759 {
2760 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2761 }
2762 else
2763 {
2764 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2765 }
2766 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 //Qos
2768 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2769 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2770 {
2771 //Joining BSS is not 11n capable and WMM is disabled on client.
2772 //Disable QoS and WMM
2773 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2774 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302775
2776 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302777 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302778 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2779 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2780 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2781 {
2782 //Joining BSS is 11n capable and WMM is disabled on AP.
2783 //Assume all HT AP's are QOS AP's and enable WMM
2784 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2785 }
2786
Jeff Johnson295189b2012-06-20 16:38:30 -07002787 //auth type
2788 switch( pProfile->negotiatedAuthType )
2789 {
2790 default:
2791 case eCSR_AUTH_TYPE_WPA:
2792 case eCSR_AUTH_TYPE_WPA_PSK:
2793 case eCSR_AUTH_TYPE_WPA_NONE:
2794 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2795 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2796 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 case eCSR_AUTH_TYPE_SHARED_KEY:
2798 pBssConfig->authType = eSIR_SHARED_KEY;
2799 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 case eCSR_AUTH_TYPE_AUTOSWITCH:
2801 pBssConfig->authType = eSIR_AUTO_SWITCH;
2802 break;
2803 }
2804 //short slot time
2805 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2806 {
2807 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2808 }
2809 else
2810 {
2811 pBssConfig->uShortSlotTime = 0;
2812 }
2813 if(pBssConfig->BssCap.ibss)
2814 {
2815 //We don't support 11h on IBSS
2816 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2817 }
2818 else
2819 {
2820 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2821 }
2822 //power constraint
2823 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2824 //heartbeat
2825 if ( CSR_IS_11A_BSS( pBssDesc ) )
2826 {
2827 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2828 }
2829 else
2830 {
2831 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2832 }
2833 //Join timeout
2834 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002835 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 if ( pBssDesc->beaconInterval )
2837 {
2838 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002839 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 }
2841 else
2842 {
2843 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2844 }
2845 //validate CB
2846 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2847 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002848 return (status);
2849}
2850
Jeff Johnson295189b2012-06-20 16:38:30 -07002851static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2852 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2853{
2854 eHalStatus status = eHAL_STATUS_SUCCESS;
2855 tANI_U8 operationChannel = 0;
2856 tANI_U8 qAPisEnabled = FALSE;
2857 //SSID
2858 pBssConfig->SSID.length = 0;
2859 if(pProfile->SSIDs.numOfSSIDs)
2860 {
2861 //only use the first one
2862 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2863 }
2864 else
2865 {
2866 //SSID must present
2867 return eHAL_STATUS_FAILURE;
2868 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 //Settomg up the capabilities
2870 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2871 {
2872 pBssConfig->BssCap.ibss = 1;
2873 }
2874 else
2875 {
2876 pBssConfig->BssCap.ess = 1;
2877 }
2878 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2879 {
2880 pBssConfig->BssCap.privacy = 1;
2881 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002882 pBssConfig->eBand = pMac->roam.configParam.eBand;
2883 //phymode
2884 if(pProfile->ChannelInfo.ChannelList)
2885 {
2886 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2889 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002890 //QOS
2891 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 if ( pBssConfig->BssCap.ess == 1 )
2893 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002894 /*For Softap case enable WMM*/
2895 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2896 qAPisEnabled = TRUE;
2897 }
2898 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2900 qAPisEnabled = TRUE;
2901 } else {
2902 qAPisEnabled = FALSE;
2903 }
2904 } else {
2905 qAPisEnabled = TRUE;
2906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2908 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2909 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2910 )
2911 {
2912 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2913 } else {
2914 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2915 }
2916
2917 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08002918 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 {
2920 default:
2921 case eCSR_AUTH_TYPE_WPA:
2922 case eCSR_AUTH_TYPE_WPA_PSK:
2923 case eCSR_AUTH_TYPE_WPA_NONE:
2924 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2925 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2926 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 case eCSR_AUTH_TYPE_SHARED_KEY:
2928 pBssConfig->authType = eSIR_SHARED_KEY;
2929 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002930 case eCSR_AUTH_TYPE_AUTOSWITCH:
2931 pBssConfig->authType = eSIR_AUTO_SWITCH;
2932 break;
2933 }
2934 //short slot time
2935 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
2936 {
2937 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2938 }
2939 else
2940 {
2941 pBssConfig->uShortSlotTime = 0;
2942 }
2943 //power constraint. We don't support 11h on IBSS
2944 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2945 pBssConfig->uPowerLimit = 0;
2946 //heartbeat
2947 if ( eCSR_BAND_5G == pBssConfig->eBand )
2948 {
2949 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2950 }
2951 else
2952 {
2953 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2954 }
2955 //Join timeout
2956 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002957
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 return (status);
2959}
Jeff Johnson295189b2012-06-20 16:38:30 -07002960static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
2961{
2962 eHalStatus status = eHAL_STATUS_FAILURE;
2963 tDot11fBeaconIEs *pIes = NULL;
2964
2965 do
2966 {
2967 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
2968 {
2969 //err msg
2970 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002971 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 break;
2973 }
2974 //check if the AP is QAP & it supports APSD
2975 if( CSR_IS_QOS_BSS(pIes) )
2976 {
2977 return eHAL_STATUS_SUCCESS;
2978 }
2979 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 return status;
2981}
2982
Jeff Johnson295189b2012-06-20 16:38:30 -07002983void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
2984{
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
2986 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
2987 // See !!Note: below in this function...
2988 tANI_U32 PrivacyEnabled = 0;
2989 tANI_U32 RsnEnabled = 0;
2990 tANI_U32 WepDefaultKeyId = 0;
2991 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
2992 tANI_U32 Key0Length = 0;
2993 tANI_U32 Key1Length = 0;
2994 tANI_U32 Key2Length = 0;
2995 tANI_U32 Key3Length = 0;
2996
2997 // Reserve for the biggest key
2998 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
2999 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3000 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3001 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3002
3003 switch ( pProfile->negotiatedUCEncryptionType )
3004 {
3005 case eCSR_ENCRYPT_TYPE_NONE:
3006
3007 // for NO encryption, turn off Privacy and Rsn.
3008 PrivacyEnabled = 0;
3009 RsnEnabled = 0;
3010
3011 // WEP key length and Wep Default Key ID don't matter in this case....
3012
3013 // clear out the WEP keys that may be hanging around.
3014 Key0Length = 0;
3015 Key1Length = 0;
3016 Key2Length = 0;
3017 Key3Length = 0;
3018
3019 break;
3020
3021 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303022 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003023
3024 // Privacy is ON. NO RSN for Wep40 static key.
3025 PrivacyEnabled = 1;
3026 RsnEnabled = 0;
3027
3028 // Set the Wep default key ID.
3029 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 // Wep key size if 5 bytes (40 bits).
3031 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3032
3033 // set encryption keys in the CFG database or clear those that are not present in this profile.
3034 if ( pProfile->Keys.KeyLength[0] )
3035 {
3036 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
3037 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3038 }
3039 else
3040 {
3041 Key0Length = 0;
3042 }
3043
3044 if ( pProfile->Keys.KeyLength[1] )
3045 {
3046 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
3047 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
3048 }
3049 else
3050 {
3051 Key1Length = 0;
3052 }
3053
3054 if ( pProfile->Keys.KeyLength[2] )
3055 {
3056 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
3057 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3058 }
3059 else
3060 {
3061 Key2Length = 0;
3062 }
3063
3064 if ( pProfile->Keys.KeyLength[3] )
3065 {
3066 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
3067 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3068 }
3069 else
3070 {
3071 Key3Length = 0;
3072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 break;
3074
3075 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303076 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003077
3078 // Privacy is ON. NO RSN for Wep40 static key.
3079 PrivacyEnabled = 1;
3080 RsnEnabled = 0;
3081
3082 // Set the Wep default key ID.
3083 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3084
3085 // Wep key size if 13 bytes (104 bits).
3086 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3087
3088 // set encryption keys in the CFG database or clear those that are not present in this profile.
3089 if ( pProfile->Keys.KeyLength[0] )
3090 {
3091 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3092 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3093 }
3094 else
3095 {
3096 Key0Length = 0;
3097 }
3098
3099 if ( pProfile->Keys.KeyLength[1] )
3100 {
3101 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3102 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3103 }
3104 else
3105 {
3106 Key1Length = 0;
3107 }
3108
3109 if ( pProfile->Keys.KeyLength[2] )
3110 {
3111 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3112 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3113 }
3114 else
3115 {
3116 Key2Length = 0;
3117 }
3118
3119 if ( pProfile->Keys.KeyLength[3] )
3120 {
3121 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3122 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3123 }
3124 else
3125 {
3126 Key3Length = 0;
3127 }
3128
3129 break;
3130
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 case eCSR_ENCRYPT_TYPE_TKIP:
3132 case eCSR_ENCRYPT_TYPE_AES:
3133#ifdef FEATURE_WLAN_WAPI
3134 case eCSR_ENCRYPT_TYPE_WPI:
3135#endif /* FEATURE_WLAN_WAPI */
3136 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3137 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3138 PrivacyEnabled = (0 != fPrivacy);
3139
3140 // turn on RSN enabled for WPA associations
3141 RsnEnabled = 1;
3142
3143 // WEP key length and Wep Default Key ID don't matter in this case....
3144
3145 // clear out the static WEP keys that may be hanging around.
3146 Key0Length = 0;
3147 Key1Length = 0;
3148 Key2Length = 0;
3149 Key3Length = 0;
3150
3151 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 default:
3153 PrivacyEnabled = 0;
3154 RsnEnabled = 0;
3155 break;
3156 }
3157
3158 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3159 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3160 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3161 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3162 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3163 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3164 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3165 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3166}
3167
Jeff Johnson295189b2012-06-20 16:38:30 -07003168static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3169{
3170 tANI_U32 len = 0;
3171 if(pSSID->length <= WNI_CFG_SSID_LEN)
3172 {
3173 len = pSSID->length;
3174 }
3175 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3176}
3177
Jeff Johnson295189b2012-06-20 16:38:30 -07003178eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3179{
3180 eHalStatus status = eHAL_STATUS_SUCCESS;
3181 tANI_U32 QoSEnabled;
3182 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003183 // set the CFG enable/disable variables based on the qosType being configured...
3184 switch( qosType )
3185 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3187 QoSEnabled = FALSE;
3188 WmeEnabled = TRUE;
3189 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3191 QoSEnabled = FALSE;
3192 WmeEnabled = TRUE;
3193 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3195 QoSEnabled = FALSE;
3196 WmeEnabled = TRUE;
3197 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3199 QoSEnabled = TRUE;
3200 WmeEnabled = FALSE;
3201 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 case eCSR_MEDIUM_ACCESS_11e_HCF:
3203 QoSEnabled = TRUE;
3204 WmeEnabled = FALSE;
3205 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003206 default:
3207 case eCSR_MEDIUM_ACCESS_DCF:
3208 QoSEnabled = FALSE;
3209 WmeEnabled = FALSE;
3210 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 }
3212 //save the WMM setting for later use
3213 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003214 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3215 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 return (status);
3217}
Jeff Johnson295189b2012-06-20 16:38:30 -07003218static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3219 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3220{
3221 eHalStatus status = eHAL_STATUS_FAILURE;
3222 int i;
3223 eCsrCfgDot11Mode cfgDot11Mode;
3224 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
3226 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003228
3229 if( NULL != pIes )
3230 {
3231 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003232 // Originally, we thought that for 11a networks, the 11a rates are always
3233 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3234 // appear in the Operational Rate set. Consequently, in either case, we
3235 // would blindly put the rates we support into our Operational Rate set
3236 // (including the basic rates, which we have already verified are
3237 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 // However, it turns out that this is not always the case. Some AP's
3239 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3240 // too. Now, we're a little more careful:
3241 pDstRate = pOpRateSet->rate;
3242 if(pIes->SuppRates.present)
3243 {
3244 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3245 {
3246 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3247 {
3248 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003249 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 }
3251 }
3252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3254 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3255 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3256 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3257 {
3258 // If there are Extended Rates in the beacon, we will reflect those
3259 // extended rates that we support in out Extended Operational Rate
3260 // set:
3261 pDstRate = pExRateSet->rate;
3262 if(pIes->ExtSuppRates.present)
3263 {
3264 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3265 {
3266 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3267 {
3268 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3269 pExRateSet->numRates++;
3270 }
3271 }
3272 }
3273 }
3274 }//Parsing BSSDesc
3275 else
3276 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003277 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 }
3279 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3280 return status;
3281}
3282
3283static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3284 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3285{
3286 int i;
3287 tANI_U8 *pDstRate;
3288 eCsrCfgDot11Mode cfgDot11Mode;
3289 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3290 tANI_U32 OperationalRatesLength = 0;
3291 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3292 tANI_U32 ExtendedOperationalRatesLength = 0;
3293 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3294 tANI_U32 ProprietaryOperationalRatesLength = 0;
3295 tANI_U32 PropRatesEnable = 0;
3296 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3297 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 if( NULL != pIes )
3300 {
3301 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 // Originally, we thought that for 11a networks, the 11a rates are always
3303 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3304 // appear in the Operational Rate set. Consequently, in either case, we
3305 // would blindly put the rates we support into our Operational Rate set
3306 // (including the basic rates, which we have already verified are
3307 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 // However, it turns out that this is not always the case. Some AP's
3309 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3310 // too. Now, we're a little more careful:
3311 pDstRate = OperationalRates;
3312 if(pIes->SuppRates.present)
3313 {
3314 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3315 {
3316 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3317 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3318 {
3319 *pDstRate++ = pIes->SuppRates.rates[ i ];
3320 OperationalRatesLength++;
3321 }
3322 }
3323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3325 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3326 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3327 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3328 {
3329 // If there are Extended Rates in the beacon, we will reflect those
3330 // extended rates that we support in out Extended Operational Rate
3331 // set:
3332 pDstRate = ExtendedOperationalRates;
3333 if(pIes->ExtSuppRates.present)
3334 {
3335 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3336 {
3337 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3338 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3339 {
3340 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3341 ExtendedOperationalRatesLength++;
3342 }
3343 }
3344 }
3345 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 // Enable proprietary MAC features if peer node is Airgo node and STA
3347 // user wants to use them
3348 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3349 {
3350 PropRatesEnable = 1;
3351 }
3352 else
3353 {
3354 PropRatesEnable = 0;
3355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003356 // For ANI network companions, we need to populate the proprietary rate
3357 // set with any proprietary rates we found in the beacon, only if user
3358 // allows them...
3359 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3360 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3361 {
3362 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3363 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3364 {
3365 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3366 }
3367 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3368 }
3369 else {
3370 // No proprietary modes...
3371 ProprietaryOperationalRatesLength = 0;
3372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 /* Get MCS Rate */
3374 pDstRate = MCSRateIdxSet;
3375 if ( pIes->HTCaps.present )
3376 {
3377 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3378 {
3379 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3380 {
3381 MCSRateLength++;
3382 *pDstRate++ = i;
3383 }
3384 }
3385 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 // Set the operational rate set CFG variables...
3387 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3388 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3389 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3390 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3391 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3392 ProprietaryOperationalRates,
3393 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3394 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3395 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3396 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3397 }//Parsing BSSDesc
3398 else
3399 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003400 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 }
3402}
3403
Jeff Johnson295189b2012-06-20 16:38:30 -07003404static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3405 tCsrRoamProfile *pProfile )
3406{
3407 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3408 { 8,
3409 { SIR_MAC_RATE_6,
3410 SIR_MAC_RATE_9,
3411 SIR_MAC_RATE_12,
3412 SIR_MAC_RATE_18,
3413 SIR_MAC_RATE_24,
3414 SIR_MAC_RATE_36,
3415 SIR_MAC_RATE_48,
3416 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3418 { 4,
3419 { SIR_MAC_RATE_1,
3420 SIR_MAC_RATE_2,
3421 SIR_MAC_RATE_5_5,
3422 SIR_MAC_RATE_11 } } };
3423
3424
3425 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3426 { SIR_MAC_RATE_72,
3427 SIR_MAC_RATE_96,
3428 SIR_MAC_RATE_108 } };
3429 eCsrCfgDot11Mode cfgDot11Mode;
3430 eCsrBand eBand;
3431 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3432 tANI_U32 OperationalRatesLength = 0;
3433 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3434 tANI_U32 ExtendedOperationalRatesLength = 0;
3435 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3436 tANI_U32 ProprietaryOperationalRatesLength = 0;
3437 tANI_U32 PropRatesEnable = 0;
3438 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 if(pProfile->ChannelInfo.ChannelList)
3440 {
3441 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3442 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3445 // networks, the 11b rates appear in the Operational Rate set. In either case,
3446 // we can blindly put the rates we support into our Operational Rate set
3447 // (including the basic rates, which we have already verified are supported
3448 // earlier in the roaming decision).
3449 if ( eCSR_BAND_5G == eBand )
3450 {
3451 // 11a rates into the Operational Rate Set.
3452 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3453 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3454 palCopyMemory( pMac->hHdd, OperationalRates,
3455 DefaultSupportedRates11a.supportedRateSet.rate,
3456 OperationalRatesLength );
3457
3458 // Nothing in the Extended rate set.
3459 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 // populate proprietary rates if user allows them
3461 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3462 {
3463 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3464 sizeof(*DefaultSupportedPropRates.propRate);
3465 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3466 DefaultSupportedPropRates.propRate,
3467 ProprietaryOperationalRatesLength );
3468 }
3469 else
3470 {
3471 // No proprietary modes
3472 ProprietaryOperationalRatesLength = 0;
3473 }
3474 }
3475 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3476 {
3477 // 11b rates into the Operational Rate Set.
3478 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3479 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3480 palCopyMemory( pMac->hHdd, OperationalRates,
3481 DefaultSupportedRates11b.supportedRateSet.rate,
3482 OperationalRatesLength );
3483 // Nothing in the Extended rate set.
3484 ExtendedOperationalRatesLength = 0;
3485 // No proprietary modes
3486 ProprietaryOperationalRatesLength = 0;
3487 }
3488 else
3489 {
3490 // 11G
3491
3492 // 11b rates into the Operational Rate Set.
3493 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3494 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3495 palCopyMemory( pMac->hHdd, OperationalRates,
3496 DefaultSupportedRates11b.supportedRateSet.rate,
3497 OperationalRatesLength );
3498
3499 // 11a rates go in the Extended rate set.
3500 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3501 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3502 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3503 DefaultSupportedRates11a.supportedRateSet.rate,
3504 ExtendedOperationalRatesLength );
3505
3506 // populate proprietary rates if user allows them
3507 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3508 {
3509 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3510 sizeof(*DefaultSupportedPropRates.propRate);
3511 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3512 DefaultSupportedPropRates.propRate,
3513 ProprietaryOperationalRatesLength );
3514 }
3515 else
3516 {
3517 // No proprietary modes
3518 ProprietaryOperationalRatesLength = 0;
3519 }
3520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3522 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3523 {
3524 PropRatesEnable = 1;
3525 }
3526 else
3527 {
3528 PropRatesEnable = 0;
3529 }
3530
3531 // Set the operational rate set CFG variables...
3532 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3533 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3534 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3535 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3536 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3537 ProprietaryOperationalRates,
3538 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3539 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003540}
Jeff Johnson295189b2012-06-20 16:38:30 -07003541void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3542{
3543 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003544
Jeff Johnson295189b2012-06-20 16:38:30 -07003545 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3546 tANI_U32 sessionId;
3547 tSmeCmd *pCommand = NULL;
3548
3549 if(NULL == pEntry)
3550 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003551 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003552 return;
3553 }
3554 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3555 sessionId = pCommand->sessionId;
3556
3557 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3558 {
3559 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3560 }
3561}
3562
Jeff Johnson295189b2012-06-20 16:38:30 -07003563//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3564tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3565{
3566 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3567 {
3568 return (WNI_CFG_PHY_MODE_11B);
3569 }
3570 else
3571 {
3572 if(eCSR_BAND_24 == band)
3573 return (WNI_CFG_PHY_MODE_11G);
3574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003575 return (WNI_CFG_PHY_MODE_11A);
3576}
Jeff Johnson295189b2012-06-20 16:38:30 -07003577
Jeff Johnsone7245742012-09-05 17:12:55 -07003578
3579#ifdef WLAN_FEATURE_11AC
3580ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3581{
3582 switch ( aniCBMode )
3583 {
3584 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3585 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3586 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3587 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3588 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3589 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3590 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3591 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3592 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003593 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003594 return PHY_SINGLE_CHANNEL_CENTERED;
3595 }
3596}
3597#endif
3598
Jeff Johnson295189b2012-06-20 16:38:30 -07003599//pIes may be NULL
3600eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3601 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3602 tDot11fBeaconIEs *pIes)
3603{
3604 eHalStatus status = eHAL_STATUS_SUCCESS;
3605 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3606 tANI_U8 channel = 0;
3607 //Make sure we have the domain info for the BSS we try to connect to.
3608 //Do we need to worry about sequence for OSs that are not Windows??
3609 if(pBssDesc)
3610 {
3611 if(csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
3612 {
3613 //Make sure the 11d info from this BSSDesc can be applied
3614 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3615 csrApplyCountryInformation( pMac, TRUE );
3616 }
Kiran4a17ebe2013-01-31 10:43:43 -08003617 if ((csrIs11dSupported (pMac)) && pIes)
3618 {
3619 if (!pIes->Country.present)
3620 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 //Qos
3624 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3625 //SSID
3626 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3627 //fragment threshold
3628 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3629 //RTS threshold
3630 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3631
3632 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3633
3634 //Auth type
3635 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3636 //encryption type
3637 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3638 //short slot time
3639 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 //11d
3641 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3642 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3643 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 /*//11h
3645 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3646 */
3647 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3648 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003649
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003650 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003651 {
3652 channel = pProfile->operationChannel;
3653 }
3654 else
3655 {
3656 if(pBssDesc)
3657 {
3658 channel = pBssDesc->channelId;
3659 }
3660 }
3661 if(0 != channel)
3662 {
3663 if(CSR_IS_CHANNEL_24GHZ(channel))
3664 {//for now if we are on 2.4 Ghz, CB will be always disabled
3665 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3666 }
3667 else
3668 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003669 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 }
3671 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003672#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003673 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3674 // in function csrConvertCBIniValueToPhyCBState()
3675 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3676 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003677 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003678 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003679 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003680 }
3681 else
3682 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003683 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003684 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003685 }
3686 else
3687#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3689 //Rate
3690 //Fixed Rate
3691 if(pBssDesc)
3692 {
3693 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3694 }
3695 else
3696 {
3697 csrSetCfgRateSetFromProfile(pMac, pProfile);
3698 }
3699 //Make this the last CFG to set. The callback will trigger a join_req
3700 //Join time out
3701 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3702
3703 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003704 return (status);
3705}
3706
Jeff Johnson295189b2012-06-20 16:38:30 -07003707eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3708 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3709{
3710 eHalStatus status;
3711 tBssConfigParam *pBssConfig;
3712 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003713
3714 if(!pSession)
3715 {
3716 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3717 return eHAL_STATUS_FAILURE;
3718 }
3719
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3721 if(HAL_STATUS_SUCCESS(status))
3722 {
3723 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3724 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3725 if(HAL_STATUS_SUCCESS(status))
3726 {
3727 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003728 /* This will allow to pass cbMode during join req */
3729 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 //For IBSS, we need to prepare some more information
3731 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 )
3734 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003735 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 }
3737 // If we are in an IBSS, then stop the IBSS...
3738 ////Not worry about WDS connection for now
3739 if ( csrIsConnStateIbss( pMac, sessionId ) )
3740 {
3741 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3742 }
3743 else
3744 {
3745 // if we are in an Infrastructure association....
3746 if ( csrIsConnStateInfra( pMac, sessionId ) )
3747 {
3748 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3749 // across SSIDs (roaming to a new SSID)... //
3750 //Not worry about WDS connection for now
3751 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
3752 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
3753 {
3754 // then we need to disassociate from the Infrastructure network...
3755 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
3756 }
3757 else
3758 {
3759 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3760 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
3761 if ( pBssDesc )
3762 {
3763 // Set parameters for this Bss.
3764 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3765 }
3766 }
3767 }
3768 else
3769 {
3770 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3771 // Nothing to stop.
3772 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003773 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003774 )
3775 {
3776 // Set parameters for this Bss.
3777 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3778 }
3779 }
3780 }
3781 }//Success getting BSS config info
3782 palFreeMemory(pMac->hHdd, pBssConfig);
3783 }//Allocate memory
3784
3785 return (status);
3786}
3787
Jeff Johnson295189b2012-06-20 16:38:30 -07003788eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3789 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3790{
3791 eCsrJoinState eRoamState = eCsrContinueRoaming;
3792 eHalStatus status;
3793 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3794 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3795 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003796
3797 if(!pSession)
3798 {
3799 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3800 return (eCsrStopRoaming);
3801 }
3802
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 if( CSR_IS_WDS_STA( pProfile ) )
3804 {
3805 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3806 if( !HAL_STATUS_SUCCESS( status ) )
3807 {
3808 eRoamState = eCsrStopRoaming;
3809 }
3810 }
3811 else
3812 {
3813 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3814 {
3815 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3816 return (eCsrStopRoaming);
3817 }
3818 if ( csrIsInfraBssDesc( pBssDesc ) )
3819 {
3820 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3821 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3822 // have changed and handle the changes (without disturbing the current association).
3823
3824 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3825 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3826 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3827 )
3828 {
3829 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3830 // with Authenticating first. To force this, stop the current association (Disassociate) and
3831 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3832 // a new Association.
3833 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3834 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003835 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d"), pProfile->AuthType, pProfile->EncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3837 {
3838 eRoamState = eCsrReassocToSelfNoCapChange;
3839 }
3840 else
3841 {
3842 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 //The key changes
3844 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3845 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3846 if(HAL_STATUS_SUCCESS(status))
3847 {
3848 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003849 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 //Reapply the config including Keys so reassoc is happening.
3851 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, &bssConfig, pIesLocal);
3852 if(!HAL_STATUS_SUCCESS(status))
3853 {
3854 eRoamState = eCsrStopRoaming;
3855 }
3856 }
3857 else
3858 {
3859 eRoamState = eCsrStopRoaming;
3860 }
3861 }//same profile
3862 }
3863 else
3864 {
3865 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
3866 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3867 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003868 smsLog(pMac, LOGW, FL(" fail to issue disassociate"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 eRoamState = eCsrStopRoaming;
3870 }
3871 }
3872 }
3873 else
3874 {
3875 // note: we used to pre-auth here with open authentication networks but that was not working so well.
3876 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
3877 // work much better.
3878 //
3879 //
3880 // stop the existing network before attempting to join the new network...
3881 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3882 {
3883 eRoamState = eCsrStopRoaming;
3884 }
3885 }
3886 }//Infra
3887 else
3888 {
3889 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3890 {
3891 eRoamState = eCsrStopRoaming;
3892 }
3893 }
3894 if( pIesLocal && !pScanResult->pvIes )
3895 {
3896 palFreeMemory(pMac->hHdd, pIesLocal);
3897 }
3898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 return( eRoamState );
3900}
3901
Jeff Johnson295189b2012-06-20 16:38:30 -07003902eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3903 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3904{
3905 eHalStatus status = eHAL_STATUS_SUCCESS;
3906 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3908 roamInfo.pBssDesc = pBssDesc;
3909 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3910 return (status);
3911}
Jeff Johnson295189b2012-06-20 16:38:30 -07003912//In case no matching BSS is found, use whatever default we can find
3913static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3914{
3915 //Need to get all negotiated types in place first
3916 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003917 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 {
3919 default:
3920 case eCSR_AUTH_TYPE_WPA:
3921 case eCSR_AUTH_TYPE_WPA_PSK:
3922 case eCSR_AUTH_TYPE_WPA_NONE:
3923 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3924 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3925 break;
3926
3927 case eCSR_AUTH_TYPE_SHARED_KEY:
3928 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
3929 break;
3930
3931 case eCSR_AUTH_TYPE_AUTOSWITCH:
3932 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
3933 break;
3934 }
3935 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
3936 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3937 //In this case, the multicast encryption needs to follow the uncast ones.
3938 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
3939 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3940}
3941
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07003942
3943static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
3944{
3945 switch(pCommand->u.roamCmd.roamReason)
3946 {
3947 case eCsrLostLink1:
3948 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
3949 break;
3950 case eCsrLostLink2:
3951 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
3952 break;
3953 case eCsrLostLink3:
3954 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
3955 break;
3956 default:
3957 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
3958 pCommand->u.roamCmd.roamReason);
3959 break;
3960 }
3961}
3962
Jeff Johnson295189b2012-06-20 16:38:30 -07003963static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
3964{
3965 eHalStatus status;
3966 tCsrScanResult *pScanResult = NULL;
3967 eCsrJoinState eRoamState = eCsrStopRoaming;
3968 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
3969 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
3970 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
3971#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3972 v_U8_t acm_mask = 0;
3973#endif
3974 tANI_U32 sessionId = pCommand->sessionId;
3975 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3976 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
3977 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003978
3979 if(!pSession)
3980 {
3981 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3982 return (eCsrStopRoaming);
3983 }
3984
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 do
3986 {
3987 // Check for Cardbus eject condition, before trying to Roam to any BSS
3988 //***if( !balIsCardPresent(pAdapter) ) break;
3989
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07003990 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
3991 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 if(NULL != pBSSList)
3993 {
3994 // When handling AP's capability change, continue to associate to
3995 // same BSS and make sure pRoamBssEntry is not Null.
3996 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
3997 {
3998 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
3999 {
4000 //Try the first BSS
4001 pCommand->u.roamCmd.pLastRoamBss = NULL;
4002 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4003 }
4004 else
4005 {
4006 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4007 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4008 {
4009 //Done with all the BSSs
4010 //In this case, will tell HDD the completion
4011 break;
4012 }
4013 else
4014 {
4015 //We need to indicate to HDD that we are done with this one.
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004016 //palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07004017 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4018 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4019 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4020 pRoamInfo = &roamInfo;
4021 }
4022 }
4023 while(pCommand->u.roamCmd.pRoamBssEntry)
4024 {
4025 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004026 /*If concurrency enabled take the concurrent connected channel first. */
4027 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004028 if (vos_concurrent_sessions_running() &&
4029 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 {
4031 concurrentChannel =
4032 csrGetConcurrentOperationChannel(pMac);
4033 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004034 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 if ((concurrentChannel) &&
4036 (concurrentChannel ==
4037 pScanResult->Result.BssDescriptor.channelId))
4038 {
4039 //make this 0 because we do not want the
4040 //below check to pass as we don't want to
4041 //connect on other channel
4042 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4043 FL("Concurrent channel match =%d"),
4044 concurrentChannel);
4045 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 }
4047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004048
4049 if (!concurrentChannel)
4050 {
4051
4052 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4053 sessionId, &pScanResult->Result.BssDescriptor,
4054 pCommand->u.roamCmd.roamId)))
4055 {
4056 //Ok to roam this
4057 break;
4058 }
4059 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004060 else
4061 {
4062 eRoamState = eCsrStopRoamingDueToConcurrency;
4063 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4065 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4066 {
4067 //Done with all the BSSs
4068 fDone = eANI_BOOLEAN_TRUE;
4069 break;
4070 }
4071 }
4072 if(fDone)
4073 {
4074 break;
4075 }
4076 }
4077 }
4078 //We have something to roam, tell HDD when it is infra.
4079 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4080 //For WDS, the indication is eCSR_ROAM_WDS_IND
4081 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4082 {
4083 if(pRoamInfo)
4084 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004085 if(pSession->bRefAssocStartCnt)
4086 {
4087 pSession->bRefAssocStartCnt--;
4088 //Complete the last association attemp because a new one is about to be tried
4089 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4090 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004092 }
4093 }
4094 /* If the roaming has stopped, not to continue the roaming command*/
4095 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4096 {
4097 //No need to complete roaming here as it already completes
4098 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4099 pCommand->u.roamCmd.roamReason);
4100 eRoamState = eCsrStopRoaming;
4101 csrSetAbortRoamingCommand(pMac, pCommand);
4102 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 }
4104 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4105 if(pScanResult)
4106 {
4107 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4109 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004110 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 fDone = eANI_BOOLEAN_TRUE;
4112 eRoamState = eCsrStopRoaming;
4113 break;
4114 }
4115 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4116 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4117 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4118 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4119 CSR_IS_QOS_BSS(pIesLocal) &&
4120 CSR_IS_UAPSD_BSS(pIesLocal) )
4121 {
4122#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4124 pIesLocal);
4125 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4126#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 }
4128 else
4129 {
4130 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4131 }
4132 if( pIesLocal && !pScanResult->Result.pvIes)
4133 {
4134 palFreeMemory(pMac->hHdd, pIesLocal);
4135 }
4136 }
4137 else
4138 {
4139 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4140 }
4141 roamInfo.pProfile = pProfile;
4142 pSession->bRefAssocStartCnt++;
4143 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4144 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4147 {
4148 // If this is a start IBSS profile, then we need to start the IBSS.
4149 if ( CSR_IS_START_IBSS(pProfile) )
4150 {
4151 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 // Attempt to start this IBSS...
4153 csrRoamAssignDefaultParam( pMac, pCommand );
4154 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4155 if(HAL_STATUS_SUCCESS(status))
4156 {
4157 if ( fSameIbss )
4158 {
4159 eRoamState = eCsrStartIbssSameIbss;
4160 }
4161 else
4162 {
4163 eRoamState = eCsrContinueRoaming;
4164 }
4165 }
4166 else
4167 {
4168 //it somehow fail need to stop
4169 eRoamState = eCsrStopRoaming;
4170 }
4171 break;
4172 }
4173 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004174 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 )
4176 {
4177 // Attempt to start this WDS...
4178 csrRoamAssignDefaultParam( pMac, pCommand );
4179 /* For AP WDS, we dont have any BSSDescription */
4180 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4181 if(HAL_STATUS_SUCCESS(status))
4182 {
4183 eRoamState = eCsrContinueRoaming;
4184 }
4185 else
4186 {
4187 //it somehow fail need to stop
4188 eRoamState = eCsrStopRoaming;
4189 }
4190 }
4191 else
4192 {
4193 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004194 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 eRoamState = eCsrStopRoaming;
4196 break;
4197 }
4198 }
4199 else //We have BSS
4200 {
4201 //Need to assign these value because they are used in csrIsSameProfile
4202 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4203 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4204 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4205 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4206 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4207 {
4208 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4209 {
4210 eRoamState = eCsrStartIbssSameIbss;
4211 break;
4212 }
4213 }
4214 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4215 {
4216 //trying to connect to the one already connected
4217 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4218 eRoamState = eCsrReassocToSelfNoCapChange;
4219 break;
4220 }
4221 // Attempt to Join this Bss...
4222 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4223 break;
4224 }
4225
4226 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4228 {
4229 //Need to indicate association_completion if association_start has been done
4230 if(pSession->bRefAssocStartCnt > 0)
4231 {
4232 pSession->bRefAssocStartCnt--;
4233 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004234 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4236 eCSR_ROAM_ASSOCIATION_COMPLETION,
4237 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4238 }
4239 }
4240
4241 return( eRoamState );
4242}
4243
Jeff Johnson295189b2012-06-20 16:38:30 -07004244static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4245{
4246 eHalStatus status = eHAL_STATUS_SUCCESS;
4247 eCsrJoinState RoamState;
4248 tANI_U32 sessionId = pCommand->sessionId;
4249
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 //***if( hddIsRadioStateOn( pAdapter ) )
4251 {
4252 // Attept to join a Bss...
4253 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004254
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004256 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 {
4258 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 // and if connected in Infrastructure mode...
4260 if ( csrIsConnStateInfra(pMac, sessionId) )
4261 {
4262 //... then we need to issue a disassociation
4263 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4264 if(!HAL_STATUS_SUCCESS(status))
4265 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004266 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 //roam command is completed by caller in the failed case
4268 fComplete = eANI_BOOLEAN_TRUE;
4269 }
4270 }
4271 else if( csrIsConnStateIbss(pMac, sessionId) )
4272 {
4273 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4274 if(!HAL_STATUS_SUCCESS(status))
4275 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004276 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004277 //roam command is completed by caller in the failed case
4278 fComplete = eANI_BOOLEAN_TRUE;
4279 }
4280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004281 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4282 {
4283 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4284 if(!HAL_STATUS_SUCCESS(status))
4285 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004286 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 //roam command is completed by caller in the failed case
4288 fComplete = eANI_BOOLEAN_TRUE;
4289 }
4290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004291 else
4292 {
4293 fComplete = eANI_BOOLEAN_TRUE;
4294 }
4295 if(fComplete)
4296 {
4297 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004298 if(eCsrStopRoamingDueToConcurrency == RoamState)
4299 {
4300 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4301 }
4302 else
4303 {
4304 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004306 }
4307 }
4308 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4309 {
4310 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4311 }
4312 else if ( eCsrStartIbssSameIbss == RoamState )
4313 {
4314 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4315 }
4316 }//hddIsRadioStateOn
4317
4318 return status;
4319}
Jeff Johnson295189b2012-06-20 16:38:30 -07004320eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4321{
4322 tANI_U32 sessionId;
4323 tCsrRoamSession *pSession;
4324 tCsrScanResult *pScanResult = NULL;
4325 tSirBssDescription *pBssDesc = NULL;
4326 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004327 sessionId = pCommand->sessionId;
4328 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004329
4330 if(!pSession)
4331 {
4332 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4333 return eHAL_STATUS_FAILURE;
4334 }
4335
Jeff Johnson295189b2012-06-20 16:38:30 -07004336 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4337 {
4338 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004339 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4341 return eHAL_STATUS_FAILURE;
4342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 if (pCommand->u.roamCmd.pRoamBssEntry)
4344 {
4345 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4346 pBssDesc = &pScanResult->Result.BssDescriptor;
4347 }
4348 else
4349 {
4350 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004351 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004352 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4353 return eHAL_STATUS_FAILURE;
4354 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004355 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4356 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4357 return status;
4358}
4359
Jeff Johnson295189b2012-06-20 16:38:30 -07004360eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4361{
4362 eHalStatus status = eHAL_STATUS_SUCCESS;
4363 tCsrRoamInfo roamInfo;
4364 tANI_U32 sessionId = pCommand->sessionId;
4365 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004366
4367 if(!pSession)
4368 {
4369 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4370 return eHAL_STATUS_FAILURE;
4371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004372
4373 switch ( pCommand->u.roamCmd.roamReason )
4374 {
4375 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004377 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 case eCsrSmeIssuedDisassocForHandoff:
4380 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4381#if 0 // TODO : Confirm this change
4382 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4383#else
4384 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4385#endif
4386
4387 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004390 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004392 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004394 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 case eCsrHddIssuedReassocToSameAP:
4397 case eCsrSmeIssuedReassocToSameAP:
4398 {
4399 tDot11fBeaconIEs *pIes = NULL;
4400
Jeff Johnson295189b2012-06-20 16:38:30 -07004401 if( pSession->pConnectBssDesc )
4402 {
4403 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4404 if(!HAL_STATUS_SUCCESS(status) )
4405 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004406 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004407 }
4408 else
4409 {
4410 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4411 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4412 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4414 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4415 pSession->bRefAssocStartCnt++;
4416 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4417 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4418
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004419 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004420 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4421 &pCommand->u.roamCmd.roamProfile );
4422 if(!HAL_STATUS_SUCCESS(status))
4423 {
4424 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004425 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004426 }
4427
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 palFreeMemory(pMac->hHdd, pIes);
4429 pIes = NULL;
4430 }
4431 }
4432 break;
4433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004434 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004435 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4437 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4438 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 case eCsrSmeIssuedFTReassoc:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004440 smsLog(pMac, LOGE, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4442 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004443
Jeff Johnson295189b2012-06-20 16:38:30 -07004444 case eCsrStopBss:
4445 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4446 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4447 break;
4448
4449 case eCsrForcedDisassocSta:
4450 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4451 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4452 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4453 pCommand->u.roamCmd.reason);
4454 break;
4455
4456 case eCsrForcedDeauthSta:
4457 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4458 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4459 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4460 pCommand->u.roamCmd.reason);
4461 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004462
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004463 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004464 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004465 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4466 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004467 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004468
4469 default:
4470 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4471
4472 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4473 {
4474 //Remember the roaming profile
4475 csrFreeRoamProfile(pMac, sessionId);
4476 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4477 {
4478 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4479 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4480 }
4481 }
4482
4483 //At this point, original uapsd_mask is saved in pCurRoamProfile
4484 //uapsd_mask in the pCommand may change from this point on.
4485
4486 // Attempt to roam with the new scan results (if we need to..)
4487 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004488 if(!HAL_STATUS_SUCCESS(status))
4489 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004490 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 break;
4493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 return (status);
4495}
4496
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004497void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4498{
4499 pCommand->u.roamCmd.pLastRoamBss = NULL;
4500 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4501 //Because u.roamCmd is union and share with scanCmd and StatusChange
4502 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4503}
4504
Jeff Johnson295189b2012-06-20 16:38:30 -07004505void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4506{
4507 if(pCommand->u.roamCmd.fReleaseBssList)
4508 {
4509 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4510 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4511 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4512 }
4513 if(pCommand->u.roamCmd.fReleaseProfile)
4514 {
4515 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4516 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4517 }
4518 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4519 //Because u.roamCmd is union and share with scanCmd and StatusChange
4520 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4521}
4522
Jeff Johnson295189b2012-06-20 16:38:30 -07004523void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4524{
4525 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4526}
Jeff Johnson295189b2012-06-20 16:38:30 -07004527void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4528{
4529 tListElem *pEntry;
4530 tSmeCmd *pCommand;
4531 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004532 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4534 if ( pEntry )
4535 {
4536 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 // If the head of the queue is Active and it is a ROAM command, remove
4538 // and put this on the Free queue.
4539 if ( eSmeCommandRoam == pCommand->command )
4540 {
4541 //we need to process the result first before removing it from active list because state changes
4542 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4543 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4544 if( fReleaseCommand )
4545 {
4546 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4547 {
4548 csrReleaseCommandRoam( pMac, pCommand );
4549 }
4550 else
4551 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004552 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004553 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 }
4555 }
4556 else
4557 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004558 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004559 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 }
4561 }
4562 else
4563 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004564 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 }
4566 }
4567 else
4568 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004569 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 if( fReleaseCommand )
4572 {
4573 smeProcessPendingQueue( pMac );
4574 }
4575}
4576
Jeff Johnson295189b2012-06-20 16:38:30 -07004577void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4578{
4579 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004580 if(!pSession)
4581 {
4582 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4583 return;
4584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4586 pSession->NumPmkidCandidate = 0;
4587}
Jeff Johnson295189b2012-06-20 16:38:30 -07004588#ifdef FEATURE_WLAN_WAPI
4589void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4590{
4591 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004592 if(!pSession)
4593 {
4594 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4595 return;
4596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4598 pSession->NumBkidCandidate = 0;
4599}
4600#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004601extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4602
Jeff Johnson295189b2012-06-20 16:38:30 -07004603static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4604 tSirBssDescription *pSirBssDesc,
4605 tDot11fBeaconIEs *pIes)
4606{
4607 eHalStatus status = eHAL_STATUS_SUCCESS;
4608 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4609 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004610
4611 if(!pSession)
4612 {
4613 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4614 return eHAL_STATUS_FAILURE;
4615 }
4616
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 if((eCSR_AUTH_TYPE_WPA == authType) ||
4618 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4619 (eCSR_AUTH_TYPE_RSN == authType) ||
4620 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4621#if defined WLAN_FEATURE_VOWIFI_11R
4622 ||
4623 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4624 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4625#endif /* FEATURE_WLAN_WAPI */
4626#ifdef FEATURE_WLAN_WAPI
4627 ||
4628 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4629 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4630#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004631#ifdef WLAN_FEATURE_11W
4632 ||
4633 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4634#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 )
4636 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004637 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4638 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004639 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004640 }
4641 if( pIesLocal )
4642 {
4643 tANI_U32 nIeLen;
4644 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 if((eCSR_AUTH_TYPE_RSN == authType) ||
4646#if defined WLAN_FEATURE_VOWIFI_11R
4647 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4648 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4649#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004650#if defined WLAN_FEATURE_11W
4651 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4652#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4654 {
4655 if(pIesLocal->RSN.present)
4656 {
4657 //Calculate the actual length
4658 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4659 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4660 + 2 //akm_suite_count
4661 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4662 + 2; //reserved
4663 if( pIesLocal->RSN.pmkid_count )
4664 {
4665 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4666 }
4667 //nIeLen doesn't count EID and length fields
4668 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4669 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004670 palZeroMemory(pMac->hHdd, pSession->pWpaRsnRspIE, nIeLen + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4672 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4673 //copy upto akm_suites
4674 pIeBuf = pSession->pWpaRsnRspIE + 2;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004675 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, sizeof(pIesLocal->RSN.version));
4676 pIeBuf += sizeof(pIesLocal->RSN.version);
4677 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.gp_cipher_suite, sizeof(pIesLocal->RSN.gp_cipher_suite));
4678 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
4679 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count, sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
4680 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 if( pIesLocal->RSN.pwise_cipher_suite_count )
4682 {
4683 //copy pwise_cipher_suites
4684 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4685 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4686 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4687 }
4688 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4689 pIeBuf += 2;
4690 if( pIesLocal->RSN.akm_suite_count )
4691 {
4692 //copy akm_suites
4693 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4694 pIesLocal->RSN.akm_suite_count * 4);
4695 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4696 }
4697 //copy the rest
4698 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4699 pIesLocal->RSN.akm_suite_count * 4,
4700 2 + pIesLocal->RSN.pmkid_count * 4);
4701 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4702 }
4703 }
4704 }
4705 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4706 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4707 {
4708 if(pIesLocal->WPA.present)
4709 {
4710 //Calculate the actual length
4711 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4712 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4713 + 2 //auth_suite_count
4714 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4715 // The WPA capabilities follows the Auth Suite (two octects)--
4716 // this field is optional, and we always "send" zero, so just
4717 // remove it. This is consistent with our assumptions in the
4718 // frames compiler; c.f. bug 15234:
4719 //nIeLen doesn't count EID and length fields
4720 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4721 {
4722 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4723 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4724 pIeBuf = pSession->pWpaRsnRspIE + 2;
4725 //Copy WPA OUI
4726 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4727 pIeBuf += 4;
4728 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4729 pIesLocal->WPA.unicast_cipher_count * 4);
4730 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4731 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4732 pIesLocal->WPA.auth_suite_count * 4);
4733 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4734 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4735 }
4736 }
4737 }
4738#ifdef FEATURE_WLAN_WAPI
4739 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4740 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4741 {
4742 if(pIesLocal->WAPI.present)
4743 {
4744 //Calculate the actual length
4745 nIeLen = 4 //version + akm_suite_count
4746 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4747 + 2 //pwise_cipher_suite_count
4748 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4749 + 6; //gp_cipher_suite + preauth + reserved
4750 if( pIesLocal->WAPI.bkid_count )
4751 {
4752 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4753 }
4754
4755 //nIeLen doesn't count EID and length fields
4756 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4757 {
4758 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4759 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4760 pIeBuf = pSession->pWapiRspIE + 2;
4761 //copy upto akm_suite_count
4762 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 4);
4763 pIeBuf += 4;
4764 if( pIesLocal->WAPI.akm_suite_count )
4765 {
4766 //copy akm_suites
4767 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4768 pIesLocal->WAPI.akm_suite_count * 4);
4769 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4770 }
4771 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4772 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004773 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4774 {
4775 //copy pwise_cipher_suites
4776 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4777 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4778 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4779 }
4780 //gp_cipher_suite + preauth + reserved + bkid_count
4781 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.multicast_cipher_suite, 8);
4782 pIeBuf += 8;
4783 if( pIesLocal->WAPI.bkid_count )
4784 {
4785 //copy akm_suites
4786 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4787 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4788 }
4789 pSession->nWapiRspIeLength = nIeLen + 2;
4790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004791 }
4792 }
4793#endif /* FEATURE_WLAN_WAPI */
4794 if( !pIes )
4795 {
4796 //locally allocated
4797 palFreeMemory(pMac->hHdd, pIesLocal);
4798 }
4799 }
4800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004801 return (status);
4802}
4803
Jeff Johnson295189b2012-06-20 16:38:30 -07004804static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4805{
4806 v_U8_t bACWeights[WLANTL_MAX_AC];
4807 v_U8_t paramBk, paramBe, paramVi, paramVo;
4808 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004809 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4810 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4811 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4812 //This doesn't address the case where the lower AC needs a real higher weight
4813 if( pIEs->WMMParams.present )
4814 {
4815 //no change to the lowest ones
4816 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4817 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4818 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4819 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4820 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4821 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4822 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4823 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4824 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4825 {
4826 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4827 fWeightChange = VOS_TRUE;
4828 }
4829 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4830 {
4831 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4832 fWeightChange = VOS_TRUE;
4833 }
4834 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4835 {
4836 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4837 fWeightChange = VOS_TRUE;
4838 }
4839 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4840 {
4841 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4842 fWeightChange = VOS_TRUE;
4843 }
4844 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4845 {
4846 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4847 fWeightChange = VOS_TRUE;
4848 }
4849 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4850 {
4851 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4852 fWeightChange = VOS_TRUE;
4853 }
4854 if(fWeightChange)
4855 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004856 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07004857 bACWeights[2], bACWeights[3]);
4858 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4859 }
4860 }
4861}
Jeff Johnson295189b2012-06-20 16:38:30 -07004862#ifdef WLAN_FEATURE_VOWIFI_11R
4863//Returns whether the current association is a 11r assoc or not
4864tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4865{
4866#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4867 return csrNeighborRoamIs11rAssoc(pMac);
4868#else
4869 return eANI_BOOLEAN_FALSE;
4870#endif
4871}
4872#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004873#ifdef FEATURE_WLAN_CCX
4874//Returns whether the current association is a CCX assoc or not
4875tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4876{
4877#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4878 return csrNeighborRoamIsCCXAssoc(pMac);
4879#else
4880 return eANI_BOOLEAN_FALSE;
4881#endif
4882}
4883#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004884#ifdef FEATURE_WLAN_LFR
4885//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304886tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004887{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304888 tCsrRoamSession *pSession = NULL;
4889
4890 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4891 {
4892 pSession = CSR_GET_SESSION( pMac, sessionId );
4893 if (NULL != pSession->pCurRoamProfile)
4894 {
4895 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4896 {
4897 return eANI_BOOLEAN_FALSE;
4898 }
4899 }
4900 }
4901
Madan Mohan Koyyalamudi9ce36ec2012-10-15 16:03:17 -07004902 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07004903 (!csrIsConcurrentSessionRunning(pMac)));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004904}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004905#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4906//Returns whether "FW based BG scan" is currently enabled...or not
4907tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
4908{
4909 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
4910}
4911#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004912#endif
4913
Jeff Johnson295189b2012-06-20 16:38:30 -07004914//Return true means the command can be release, else not
4915static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4916 eCsrRoamCompleteResult Result, void *Context )
4917{
4918 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4919 tSirBssDescription *pSirBssDesc = NULL;
4920 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4921 tCsrScanResult *pScanResult = NULL;
4922 tCsrRoamInfo roamInfo;
4923 sme_QosAssocInfo assocInfo;
4924 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
4925 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
4926 tDot11fBeaconIEs *pIes = NULL;
4927 tANI_U32 sessionId = pCommand->sessionId;
4928 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4929 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4930 eRoamCmdStatus roamStatus;
4931 eCsrRoamResult roamResult;
4932 eHalStatus status;
4933 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004934 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004935
Jeff Johnson32d95a32012-09-10 13:15:23 -07004936 if(!pSession)
4937 {
4938 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4939 return eANI_BOOLEAN_FALSE;
4940 }
4941
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004942 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 switch( Result )
4944 {
4945 case eCsrJoinSuccess:
4946 // reset the IDLE timer
4947 // !!
4948 // !! fall through to the next CASE statement here is intentional !!
4949 // !!
4950 case eCsrReassocSuccess:
4951 if(eCsrReassocSuccess == Result)
4952 {
4953 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
4954 }
4955 else
4956 {
4957 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
4958 }
4959 // Success Join Response from LIM. Tell NDIS we are connected and save the
4960 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004961 smsLog(pMac, LOGW, FL("receives association indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4963 //always free the memory here
4964 if(pSession->pWpaRsnRspIE)
4965 {
4966 pSession->nWpaRsnRspIeLength = 0;
4967 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
4968 pSession->pWpaRsnRspIE = NULL;
4969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004970#ifdef FEATURE_WLAN_WAPI
4971 if(pSession->pWapiRspIE)
4972 {
4973 pSession->nWapiRspIeLength = 0;
4974 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
4975 pSession->pWapiRspIE = NULL;
4976 }
4977#endif /* FEATURE_WLAN_WAPI */
4978#ifdef FEATURE_WLAN_BTAMP_UT_RF
4979 //Reset counter so no join retry is needed.
4980 pSession->maxRetryCount = 0;
4981 csrRoamStopJoinRetryTimer(pMac, sessionId);
4982#endif
4983 /* This creates problem since we have not saved the connected profile.
4984 So moving this after saving the profile
4985 */
4986 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
4987 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4988 {
4989 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
4990 }
4991 else
4992 {
4993 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
4994 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 //Use the last connected bssdesc for reassoc-ing to the same AP.
4996 //NOTE: What to do when reassoc to a different AP???
4997 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
4998 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
4999 {
5000 pSirBssDesc = pSession->pConnectBssDesc;
5001 if(pSirBssDesc)
5002 {
5003 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5004 }
5005 }
5006 else
5007 {
5008
5009 if(pCommand->u.roamCmd.pRoamBssEntry)
5010 {
5011 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5012 if(pScanResult != NULL)
5013 {
5014 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5015 //this can be NULL
5016 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5017 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5018 }
5019 }
5020 }
5021 if( pSirBssDesc )
5022 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005023 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005024 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5025 //Save WPA/RSN IE
5026 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5027#ifdef FEATURE_WLAN_CCX
5028 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5029#endif
5030
5031 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5032 // substate change.
5033 // Moving even save profile above so that below mentioned conditon is also met.
5034 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5035 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005036 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5037 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5038 // will be dropped for the security context may not be set properly.
5039 //
5040 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5041 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5042 //
5043 // this reordering was done on titan_prod_usb branch and is being replicated here.
5044 //
5045
5046 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5047 !pProfile->bWPSAssociation)
5048 {
5049 // Issue the set Context request to LIM to establish the Unicast STA context
5050 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5051 pProfile->negotiatedUCEncryptionType,
5052 pSirBssDesc, &(pSirBssDesc->bssId),
5053 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5054 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005055 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005056 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5057 }
5058 // Issue the set Context request to LIM to establish the Broadcast STA context
5059 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5060 pSirBssDesc, &BroadcastMac,
5061 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5062 }
5063 else
5064 {
5065 //Need to wait for supplicant authtication
5066 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 //Set the subestate to WaitForKey in case authentiation is needed
5068 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5069
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 if(pProfile->bWPSAssociation)
5071 {
5072 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5073 }
5074 else
5075 {
5076 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5077 }
5078
5079 //Save sessionId in case of timeout
5080 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5081 //This time should be long enough for the rest of the process plus setting key
5082 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5083 {
5084 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005085 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5087 }
5088 }
5089
5090 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5091 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 if(Context)
5093 {
5094 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5095 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5097 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5098#ifdef WLAN_FEATURE_VOWIFI_11R
5099 len += pJoinRsp->parsedRicRspLen;
5100#endif /* WLAN_FEATURE_VOWIFI_11R */
5101#ifdef FEATURE_WLAN_CCX
5102 len += pJoinRsp->tspecIeLen;
5103#endif
5104 if(len)
5105 {
5106 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
5107 (void **)&pSession->connectedInfo.pbFrames, len)))
5108 {
5109 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
5110 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
5111 {
5112 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5113 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5114 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
5115#ifdef WLAN_FEATURE_VOWIFI_11R
5116 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
5117#endif /* WLAN_FEATURE_VOWIFI_11R */
5118#ifdef FEATURE_WLAN_CCX
5119 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
5120#endif
5121 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5122 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5123 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5124 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5125 }
5126 else
5127 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005128 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005129 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
5131 pSession->connectedInfo.pbFrames = NULL;
5132 }
5133 }
5134 }
5135 if(pCommand->u.roamCmd.fReassoc)
5136 {
5137 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5138 }
5139 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5140 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5141 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5142 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5143 }
5144 else
5145 {
5146 if(pCommand->u.roamCmd.fReassoc)
5147 {
5148 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5149 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5150 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5151 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5152 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5153 }
5154 }
5155#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5156 // Indicate SME-QOS with reassoc success event, only after
5157 // copying the frames
5158 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5159#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005160 roamInfo.pBssDesc = pSirBssDesc;
5161 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5162 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5163#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5164 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5165#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5166 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5168 //It may be better to let QoS do this????
5169 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5170 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005171 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005172 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5173 pmcStartUapsd( pMac, NULL, NULL );
5174 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305175 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5177 if( pSession->bRefAssocStartCnt > 0 )
5178 {
5179 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005180 //Remove this code once SLM_Sessionization is supported
5181 //BMPS_WORKAROUND_NOT_NEEDED
5182 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005183 {
5184 pMac->roam.configParam.doBMPSWorkaround = 1;
5185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005186 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5187 }
5188
5189 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 // reset the PMKID candidate list
5191 csrResetPMKIDCandidateList( pMac, sessionId );
5192 //Update TL's AC weight base on the current EDCA parameters
5193 //These parameters may change in the course of the connection, that sictuation
5194 //is not taken care here. This change is mainly to address a WIFI WMM test where
5195 //BE has a equal or higher TX priority than VI.
5196 //We only do this for infra link
5197 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5198 {
5199 csrCheckAndUpdateACWeight(pMac, pIes);
5200 }
5201#ifdef FEATURE_WLAN_WAPI
5202 // reset the BKID candidate list
5203 csrResetBKIDCandidateList( pMac, sessionId );
5204#endif /* FEATURE_WLAN_WAPI */
5205 }
5206 else
5207 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005208 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005210 csrScanCancelIdleScan(pMac);
5211 //Not to signal link up because keys are yet to be set.
5212 //The linkup function will overwrite the sub-state that we need to keep at this point.
5213 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5214 {
5215 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5218 //enough to let security and DHCP handshake succeed before entry into BMPS
5219 if (pmcShouldBmpsTimerRun(pMac))
5220 {
5221 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5222 != eHAL_STATUS_SUCCESS)
5223 {
5224 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5225 }
5226 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005228 break;
5229
Jeff Johnson295189b2012-06-20 16:38:30 -07005230 case eCsrStartBssSuccess:
5231 // on the StartBss Response, LIM is returning the Bss Description that we
5232 // are beaconing. Add this Bss Description to our scan results and
5233 // chain the Profile to this Bss Description. On a Start BSS, there was no
5234 // detected Bss description (no partner) so we issued the Start Bss to
5235 // start the Ibss without any Bss description. Lim was kind enough to return
5236 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005237 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005239 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Jeff Johnson295189b2012-06-20 16:38:30 -07005240 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5241 if( CSR_IS_IBSS( pProfile ) )
5242 {
5243 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5244 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005245 else if (CSR_IS_INFRA_AP(pProfile))
5246 {
5247 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5248 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 else
5250 {
5251 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5252 }
5253 if( !CSR_IS_WDS_STA( pProfile ) )
5254 {
5255 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5258 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005259 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005260 roamInfo.pBssDesc = pSirBssDesc;
5261 //We need to associate_complete it first, becasue Associate_start already indicated.
5262 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5263 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5264 break;
5265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005266 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005267 {
5268 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes );
5269 }
5270 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5271 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5272 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5273 if(pSirBssDesc)
5274 {
5275 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5276 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5277 }
5278 //We are doen with the IEs so free it
5279 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005280#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5281 {
5282 vos_log_ibss_pkt_type *pIbssLog;
5283 tANI_U32 bi;
5284
5285 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5286 if(pIbssLog)
5287 {
5288 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5289 {
5290 //We start the IBSS (didn't find any matched IBSS out there)
5291 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5292 }
5293 else
5294 {
5295 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5296 }
5297 if(pSirBssDesc)
5298 {
5299 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
5300 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5301 }
5302 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5303 {
5304 //***U8 is not enough for beacon interval
5305 pIbssLog->beaconInterval = (v_U8_t)bi;
5306 }
5307 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5308 }
5309 }
5310#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5311 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5312 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005313 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5314 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005315 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5316 csrRoamIssueSetContextReq( pMac, sessionId,
5317 pProfile->negotiatedMCEncryptionType,
5318 pSirBssDesc, &BroadcastMac,
5319 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5320 }
5321 }
5322 else
5323 {
5324 //Keep the state to eCSR_ROAMING_STATE_JOINING
5325 //Need to send join_req.
5326 if(pCommand->u.roamCmd.pRoamBssEntry)
5327 {
5328 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5329 {
5330 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5331 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5332 // Set the roaming substate to 'join attempt'...
5333 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005334 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005335 }
5336 }
5337 else
5338 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005339 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005340 VOS_ASSERT( 0 );
5341 }
5342 }
5343 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5344 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5345 //trigger the connection start indication in Vista
5346 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5347 {
5348 roamStatus = eCSR_ROAM_IBSS_IND;
5349 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5350 if( CSR_IS_WDS( pProfile ) )
5351 {
5352 roamStatus = eCSR_ROAM_WDS_IND;
5353 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5354 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005355 if( CSR_IS_INFRA_AP( pProfile ) )
5356 {
5357 roamStatus = eCSR_ROAM_INFRA_IND;
5358 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005360
5361 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5362 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5363 //trigger the connection start indication in Vista
5364 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5365 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5366 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5367 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5368 {
5369 //We start the IBSS (didn't find any matched IBSS out there)
5370 roamInfo.pBssDesc = pSirBssDesc;
5371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005372 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005373 vos_mem_copy (roamInfo.bssid, pSirBssDesc->bssId, sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005374 //Remove this code once SLM_Sessionization is supported
5375 //BMPS_WORKAROUND_NOT_NEEDED
5376 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005377 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005378 {
5379 pMac->roam.configParam.doBMPSWorkaround = 1;
5380 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005381
Jeff Johnson295189b2012-06-20 16:38:30 -07005382 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5383 }
5384
5385 csrScanCancelIdleScan(pMac);
5386 //Only use this timer for ibss. BAP has its own timer for WDS
5387 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
5388 {
5389 //start the join IBSS timer
5390 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
5391 pSession->ibss_join_pending = TRUE;
5392 }
5393 if( HAL_STATUS_SUCCESS( status ) )
5394 {
5395 //Already sent join_req for the WDS station
5396 fReleaseCommand = eANI_BOOLEAN_FALSE;
5397 }
5398 else if( CSR_IS_WDS_STA( pProfile ) )
5399 {
5400 //need to send stop BSS because we fail to send join_req
5401 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5402 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5403 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5404 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 case eCsrStartBssFailure:
5407#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5408 {
5409 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005410 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5411 if(pIbssLog)
5412 {
5413 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5414 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5415 }
5416 }
5417#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005418 roamStatus = eCSR_ROAM_IBSS_IND;
5419 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5420 if( CSR_IS_WDS( pProfile ) )
5421 {
5422 roamStatus = eCSR_ROAM_WDS_IND;
5423 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5424 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 if( CSR_IS_INFRA_AP( pProfile ) )
5426 {
5427 roamStatus = eCSR_ROAM_INFRA_IND;
5428 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5429 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 if(Context)
5431 {
5432 pSirBssDesc = (tSirBssDescription *)Context;
5433 }
5434 else
5435 {
5436 pSirBssDesc = NULL;
5437 }
5438 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5439 roamInfo.pBssDesc = pSirBssDesc;
5440 //We need to associate_complete it first, becasue Associate_start already indicated.
5441 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5442 csrSetDefaultDot11Mode( pMac );
5443 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 case eCsrSilentlyStopRoaming:
5445 // We are here because we try to start the same IBSS
5446 //No message to PE
5447 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005448 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005449 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5450 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5451 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5452 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5453 if( roamInfo.pBssDesc )
5454 {
5455 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5456 }
5457 //Since there is no change in the current state, simply pass back no result otherwise
5458 //HDD may be mistakenly mark to disconnected state.
5459 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5460 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 case eCsrSilentlyStopRoamingSaveState:
5463 //We are here because we try to connect to the same AP
5464 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005465 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005466 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5467
5468 //to aviod resetting the substate to NONE
5469 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5470 //No need to change substate to wai_for_key because there is no state change
5471 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5472 if( roamInfo.pBssDesc )
5473 {
5474 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005476 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5477 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5478 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5479 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5480 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5481 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5482 roamInfo.staId = pSession->connectedInfo.staId;
5483 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005484 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 pSession->bRefAssocStartCnt--;
5486 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5487 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5488 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5489 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005490 case eCsrReassocFailure:
5491#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5492 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5493#endif
5494 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005495 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 csrFreeConnectBssDesc(pMac, sessionId);
5497 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5498 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5499 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5500 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5501 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5502 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5503 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5504 eCSR_ROAM_WDS_IND,
5505 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5506 //Need to issue stop_bss
5507 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005508 case eCsrJoinFailure:
5509 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005510 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 default:
5512 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005513 smsLog(pMac, LOGW, FL("receives no association indication"));
5514 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005515 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005516 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5517 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5518 {
5519 //do not free for the other profiles as we need to send down stop BSS later
5520 csrFreeConnectBssDesc(pMac, sessionId);
5521 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5522 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5523 csrSetDefaultDot11Mode( pMac );
5524 }
5525
5526 switch( pCommand->u.roamCmd.roamReason )
5527 {
5528 // If this transition is because of an 802.11 OID, then we transition
5529 // back to INIT state so we sit waiting for more OIDs to be issued and
5530 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005531 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 case eCsrSmeIssuedAssocToSimilarAP:
5533 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005534 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005535 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5536 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5537 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5538 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5539 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005540 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tCsrBssid));
5541
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 /* Defeaturize this later if needed */
5543#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5544 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5545 if (csrRoamIsHandoffInProgress(pMac))
5546 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 /* Should indicate neighbor roam algorithm about the connect failure here */
5548 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5549 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005550#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 if(pSession->bRefAssocStartCnt > 0)
5552 {
5553 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005554 if(eCsrJoinFailureDueToConcurrency == Result)
5555 {
5556 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5557 eCSR_ROAM_ASSOCIATION_COMPLETION,
5558 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5559 }
5560 else
5561 {
5562 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 eCSR_ROAM_ASSOCIATION_COMPLETION,
5564 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005567 else
5568 {
5569 /* bRefAssocStartCnt is not incremented when
5570 * eRoamState == eCsrStopRoamingDueToConcurrency
5571 * in csrRoamJoinNextBss API. so handle this in
5572 * else case by sending assoc failure
5573 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005574 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005575 pCommand->u.scanCmd.roamId,
5576 eCSR_ROAM_ASSOCIATION_FAILURE,
5577 eCSR_ROAM_RESULT_FAILURE);
5578 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005579 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005580#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5581 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5582#endif
5583 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5584 csrScanStartIdleScan(pMac);
5585#ifdef FEATURE_WLAN_BTAMP_UT_RF
5586 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5587 //BT activity and not able to recevie WLAN traffic. Retry the join
5588 if( CSR_IS_WDS_STA(pProfile) )
5589 {
5590 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5591 }
5592#endif
5593 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005594 case eCsrHddIssuedReassocToSameAP:
5595 case eCsrSmeIssuedReassocToSameAP:
5596 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5597
5598 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5599#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5600 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5601#endif
5602 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5603 csrScanStartIdleScan(pMac);
5604 break;
5605 case eCsrForcedDisassoc:
5606 case eCsrForcedDeauth:
5607 case eCsrSmeIssuedIbssJoinFailure:
5608 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5609
5610 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5611 {
5612 // Notify HDD that IBSS join failed
5613 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5614 }
5615 else
5616 {
5617 csrRoamCallCallback(pMac, sessionId, NULL,
5618 pCommand->u.roamCmd.roamId,
5619 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5620 }
5621#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5622 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5623#endif
5624 csrRoamLinkDown(pMac, sessionId);
5625 csrScanStartIdleScan(pMac);
5626 break;
5627 case eCsrForcedIbssLeave:
5628 csrRoamCallCallback(pMac, sessionId, NULL,
5629 pCommand->u.roamCmd.roamId,
5630 eCSR_ROAM_IBSS_LEAVE,
5631 eCSR_ROAM_RESULT_IBSS_STOP);
5632 break;
5633 case eCsrForcedDisassocMICFailure:
5634 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5635
5636 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5637#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5638 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5639#endif
5640 csrScanStartIdleScan(pMac);
5641 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005642 case eCsrStopBss:
5643 csrRoamCallCallback(pMac, sessionId, NULL,
5644 pCommand->u.roamCmd.roamId,
5645 eCSR_ROAM_INFRA_IND,
5646 eCSR_ROAM_RESULT_INFRA_STOPPED);
5647 break;
5648 case eCsrForcedDisassocSta:
5649 case eCsrForcedDeauthSta:
5650 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5651 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5652 {
5653 pSession = CSR_GET_SESSION(pMac, sessionId);
5654 if (!pSession)
5655 break;
5656
5657 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5658 {
5659 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5660 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5661 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5662 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5663 roamInfo.statusCode = eSIR_SME_SUCCESS;
5664 status = csrRoamCallCallback(pMac, sessionId,
5665 &roamInfo, pCommand->u.roamCmd.roamId,
5666 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5667 }
5668 }
5669 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 case eCsrLostLink1:
5671 // if lost link roam1 failed, then issue lost link Scan2 ...
5672 csrScanRequestLostLink2(pMac, sessionId);
5673 break;
5674 case eCsrLostLink2:
5675 // if lost link roam2 failed, then issue lost link scan3 ...
5676 csrScanRequestLostLink3(pMac, sessionId);
5677 break;
5678 case eCsrLostLink3:
5679 default:
5680 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5681
5682 //We are done with one round of lostlink roaming here
5683 csrScanHandleFailedLostlink3(pMac, sessionId);
5684 break;
5685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005686 break;
5687 }
5688 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 return ( fReleaseCommand );
5690}
5691
Jeff Johnson295189b2012-06-20 16:38:30 -07005692eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5693{
5694 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005695 return (status);
5696}
5697
Jeff Johnson295189b2012-06-20 16:38:30 -07005698eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5699{
5700 eHalStatus status = eHAL_STATUS_SUCCESS;
5701 tANI_U32 size = 0;
5702
5703 do
5704 {
5705 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5706 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5707 {
5708 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5709 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5710 if(!HAL_STATUS_SUCCESS(status))
5711 {
5712 break;
5713 }
5714 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5715 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5716 }
5717 if(pSrcProfile->SSIDs.numOfSSIDs)
5718 {
5719 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5720 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5721 if(!HAL_STATUS_SUCCESS(status))
5722 {
5723 break;
5724 }
5725 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5726 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5727 }
5728 if(pSrcProfile->nWPAReqIELength)
5729 {
5730 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5731 if(!HAL_STATUS_SUCCESS(status))
5732 {
5733 break;
5734 }
5735 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5736 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5737 }
5738 if(pSrcProfile->nRSNReqIELength)
5739 {
5740 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5741 if(!HAL_STATUS_SUCCESS(status))
5742 {
5743 break;
5744 }
5745 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5746 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5747 }
5748#ifdef FEATURE_WLAN_WAPI
5749 if(pSrcProfile->nWAPIReqIELength)
5750 {
5751 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5752 if(!HAL_STATUS_SUCCESS(status))
5753 {
5754 break;
5755 }
5756 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5757 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5758 }
5759#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005760 if(pSrcProfile->nAddIEScanLength)
5761 {
5762 status = palAllocateMemory(pMac->hHdd,
5763 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5764 if(!HAL_STATUS_SUCCESS(status))
5765 {
5766 break;
5767 }
5768 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5769 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5770 pSrcProfile->nAddIEScanLength);
5771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005772 if(pSrcProfile->nAddIEAssocLength)
5773 {
5774 status = palAllocateMemory(pMac->hHdd,
5775 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5776 if(!HAL_STATUS_SUCCESS(status))
5777 {
5778 break;
5779 }
5780 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5781 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5782 pSrcProfile->nAddIEAssocLength);
5783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 if(pSrcProfile->ChannelInfo.ChannelList)
5785 {
5786 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5787 if(!HAL_STATUS_SUCCESS(status))
5788 {
5789 break;
5790 }
5791 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5792 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5793 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005794 pDstProfile->AuthType = pSrcProfile->AuthType;
5795 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5796 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5797 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5798 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5799 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07005800#ifdef WLAN_FEATURE_11W
5801 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
5802 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
5803 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
5804#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 pDstProfile->BSSType = pSrcProfile->BSSType;
5806 pDstProfile->phyMode = pSrcProfile->phyMode;
5807 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5808
5809#ifdef FEATURE_WLAN_WAPI
5810 if(csrIsProfileWapi(pSrcProfile))
5811 {
5812 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5813 {
5814 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5815 }
5816 }
5817#endif /* FEATURE_WLAN_WAPI */
5818 pDstProfile->CBMode = pSrcProfile->CBMode;
5819 /*Save the WPS info*/
5820 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5821 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 pDstProfile->privacy = pSrcProfile->privacy;
5824 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5825 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5826 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5827 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5828 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5829 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5830 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5831 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5832 pDstProfile->wps_state = pSrcProfile->wps_state;
5833 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005835#ifdef WLAN_FEATURE_VOWIFI_11R
5836 if (pSrcProfile->MDID.mdiePresent)
5837 {
5838 pDstProfile->MDID.mdiePresent = 1;
5839 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5840 }
5841#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 }while(0);
5843
5844 if(!HAL_STATUS_SUCCESS(status))
5845 {
5846 csrReleaseProfile(pMac, pDstProfile);
5847 pDstProfile = NULL;
5848 }
5849
5850 return (status);
5851}
Jeff Johnson295189b2012-06-20 16:38:30 -07005852eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5853{
5854 eHalStatus status = eHAL_STATUS_SUCCESS;
5855 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5856 do
5857 {
5858 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5859 if(pSrcProfile->bssid)
5860 {
5861 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5862 if(!HAL_STATUS_SUCCESS(status))
5863 {
5864 break;
5865 }
5866 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5867 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5868 }
5869 if(pSrcProfile->SSID.ssId)
5870 {
5871 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5872 if(!HAL_STATUS_SUCCESS(status))
5873 {
5874 break;
5875 }
5876 pDstProfile->SSIDs.numOfSSIDs = 1;
5877 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5878 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5879 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5880 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005881 if(pSrcProfile->nAddIEAssocLength)
5882 {
5883 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5884 if(!HAL_STATUS_SUCCESS(status))
5885 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005886 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005887 break;
5888 }
5889 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5890 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5891 pSrcProfile->nAddIEAssocLength);
5892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5894 if(!HAL_STATUS_SUCCESS(status))
5895 {
5896 break;
5897 }
5898 pDstProfile->ChannelInfo.numOfChannels = 1;
5899 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 pDstProfile->AuthType.numEntries = 1;
5901 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
5902 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
5903 pDstProfile->EncryptionType.numEntries = 1;
5904 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
5905 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
5906 pDstProfile->mcEncryptionType.numEntries = 1;
5907 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
5908 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
5909 pDstProfile->BSSType = pSrcProfile->BSSType;
5910 pDstProfile->CBMode = pSrcProfile->CBMode;
5911 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5912#ifdef WLAN_FEATURE_VOWIFI_11R
5913 if (pSrcProfile->MDID.mdiePresent)
5914 {
5915 pDstProfile->MDID.mdiePresent = 1;
5916 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5917 }
5918#endif
5919
5920 }while(0);
5921
5922 if(!HAL_STATUS_SUCCESS(status))
5923 {
5924 csrReleaseProfile(pMac, pDstProfile);
5925 pDstProfile = NULL;
5926 }
5927
5928 return (status);
5929}
5930
Jeff Johnson295189b2012-06-20 16:38:30 -07005931eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5932 tScanResultHandle hBSSList,
5933 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
5934 tANI_BOOLEAN fClearScan)
5935{
5936 eHalStatus status = eHAL_STATUS_SUCCESS;
5937 tSmeCmd *pCommand;
5938
5939 pCommand = csrGetCommandBuffer(pMac);
5940 if(NULL == pCommand)
5941 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005942 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 status = eHAL_STATUS_RESOURCES;
5944 }
5945 else
5946 {
5947 if( fClearScan )
5948 {
5949 csrScanCancelIdleScan(pMac);
5950 csrScanAbortMacScanNotForConnect(pMac);
5951 }
5952 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5953 if(NULL == pProfile)
5954 {
5955 //We can roam now
5956 //Since pProfile is NULL, we need to build our own profile, set everything to default
5957 //We can only support open and no encryption
5958 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
5959 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5960 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
5961 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5962 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
5963 }
5964 else
5965 {
5966 //make a copy of the profile
5967 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5968 if(HAL_STATUS_SUCCESS(status))
5969 {
5970 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5971 }
5972 }
5973 pCommand->command = eSmeCommandRoam;
5974 pCommand->sessionId = (tANI_U8)sessionId;
5975 pCommand->u.roamCmd.hBSSList = hBSSList;
5976 pCommand->u.roamCmd.roamId = roamId;
5977 pCommand->u.roamCmd.roamReason = reason;
5978 //We need to free the BssList when the command is done
5979 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
5980 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
5982 FL("CSR PERSONA=%d"),
5983 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5985 if( !HAL_STATUS_SUCCESS( status ) )
5986 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005987 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 csrReleaseCommandRoam( pMac, pCommand );
5989 }
5990 }
5991
5992 return (status);
5993}
Jeff Johnson295189b2012-06-20 16:38:30 -07005994eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5995 tCsrRoamModifyProfileFields *pMmodProfileFields,
5996 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5997{
5998 eHalStatus status = eHAL_STATUS_SUCCESS;
5999 tSmeCmd *pCommand;
6000
6001 pCommand = csrGetCommandBuffer(pMac);
6002 if(NULL == pCommand)
6003 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006004 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 status = eHAL_STATUS_RESOURCES;
6006 }
6007 else
6008 {
6009 csrScanCancelIdleScan(pMac);
6010 csrScanAbortMacScanNotForConnect(pMac);
6011 if(pProfile)
6012 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006013 //This is likely trying to reassoc to different profile
6014 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6015 //make a copy of the profile
6016 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6017 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 }
6019 else
6020 {
6021 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6022 //how to update WPA/WPA2 info in roamProfile??
6023 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 if(HAL_STATUS_SUCCESS(status))
6026 {
6027 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6028 }
6029 pCommand->command = eSmeCommandRoam;
6030 pCommand->sessionId = (tANI_U8)sessionId;
6031 pCommand->u.roamCmd.roamId = roamId;
6032 pCommand->u.roamCmd.roamReason = reason;
6033 //We need to free the BssList when the command is done
6034 //For reassoc there is no BSS list, so the boolean set to false
6035 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6036 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6037 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6039 if( !HAL_STATUS_SUCCESS( status ) )
6040 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006041 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6043 csrReleaseCommandRoam( pMac, pCommand );
6044 }
6045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 return (status);
6047}
6048
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006049eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6050 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
6051// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6052{
6053 eHalStatus status = eHAL_STATUS_SUCCESS;
6054 tSmeCmd *pCommand;
6055
6056 pCommand = csrGetCommandBuffer(pMac);
6057 if(NULL == pCommand)
6058 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006059 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006060 status = eHAL_STATUS_RESOURCES;
6061 }
6062 else
6063 {
6064 if(pBssDescription)
6065 {
6066 //copy over the parameters we need later
6067 pCommand->command = eSmeCommandRoam;
6068 pCommand->sessionId = (tANI_U8)sessionId;
6069 pCommand->u.roamCmd.roamReason = reason;
6070 //this is the important parameter
6071 //in this case we are using this field for the "next" BSS
6072 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6073 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6074 if( !HAL_STATUS_SUCCESS( status ) )
6075 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006076 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006077 csrReleaseCommandPreauth( pMac, pCommand );
6078 }
6079 }
6080 else
6081 {
6082 //Return failure
6083 status = eHAL_STATUS_RESOURCES;
6084 }
6085 }
6086 return (status);
6087}
6088
6089eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6090{
6091 tListElem *pEntry;
6092 tSmeCmd *pCommand;
6093 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6094 if ( pEntry )
6095 {
6096 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6097 if ( (eSmeCommandRoam == pCommand->command) &&
6098 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6099 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006100 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006101 pCommand->command, pCommand->u.roamCmd.roamReason);
6102 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6103 csrReleaseCommandPreauth( pMac, pCommand );
6104 }
6105 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006106 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006107 pCommand->command, pCommand->u.roamCmd.roamReason);
6108 }
6109 }
6110 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006111 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006112 }
6113 smeProcessPendingQueue( pMac );
6114 return eHAL_STATUS_SUCCESS;
6115}
6116
Jeff Johnson295189b2012-06-20 16:38:30 -07006117eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6118 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6119{
6120 eHalStatus status = eHAL_STATUS_FAILURE;
6121 tScanResultHandle hBSSList;
6122 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006123 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6124 if(HAL_STATUS_SUCCESS(status))
6125 {
6126 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6127 if(pRoamId)
6128 {
6129 *pRoamId = roamId;
6130 }
6131 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6132 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6133 if(!HAL_STATUS_SUCCESS(status))
6134 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006135 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 csrScanResultPurge(pMac, hBSSList);
6137 }
6138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006139 return (status);
6140}
6141
Jeff Johnson295189b2012-06-20 16:38:30 -07006142eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6143 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6144{
6145 eHalStatus status = eHAL_STATUS_SUCCESS;
6146 tScanResultHandle hBSSList;
6147 tCsrScanResultFilter *pScanFilter;
6148 tANI_U32 roamId = 0;
6149 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6150 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 if (NULL == pProfile)
6152 {
6153 smsLog(pMac, LOGP, FL("No profile specified"));
6154 return eHAL_STATUS_FAILURE;
6155 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006156 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006158 if( CSR_IS_WDS( pProfile ) &&
6159 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6160 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006161 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006162 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 return status;
6164 }
6165 csrRoamCancelRoaming(pMac, sessionId);
6166 csrScanRemoveFreshScanCommand(pMac, sessionId);
6167 csrScanCancelIdleScan(pMac);
6168 //Only abort the scan if it is not used for other roam/connect purpose
6169 csrScanAbortMacScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6171 {
6172 csrScanDisable(pMac);
6173 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6175 //Check whether ssid changes
6176 if(csrIsConnStateConnected(pMac, sessionId))
6177 {
6178 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6179 {
6180 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6181 }
6182 }
6183#ifdef FEATURE_WLAN_BTAMP_UT_RF
6184 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6185#endif
6186 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6187 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006188 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6190 if(pRoamId)
6191 {
6192 roamId = *pRoamId;
6193 }
6194 if(!HAL_STATUS_SUCCESS(status))
6195 {
6196 fCallCallback = eANI_BOOLEAN_TRUE;
6197 }
6198 }
6199 else
6200 {
6201 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6202 if(HAL_STATUS_SUCCESS(status))
6203 {
6204 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6205 //Try to connect to any BSS
6206 if(NULL == pProfile)
6207 {
6208 //No encryption
6209 pScanFilter->EncryptionType.numEntries = 1;
6210 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6211 }//we don't have a profile
6212 else
6213 {
6214 //Here is the profile we need to connect to
6215 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6216 }//We have a profile
6217 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6218 if(pRoamId)
6219 {
6220 *pRoamId = roamId;
6221 }
6222
6223 if(HAL_STATUS_SUCCESS(status))
6224 {
6225 /*Save the WPS info*/
6226 if(NULL != pProfile)
6227 {
6228 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6229 }
6230 else
6231 {
6232 pScanFilter->bWPSAssociation = 0;
6233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006234 do
6235 {
6236 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006237 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 )
6239 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006240 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006241 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6242 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6243 if(!HAL_STATUS_SUCCESS(status))
6244 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006245 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 fCallCallback = eANI_BOOLEAN_TRUE;
6247 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006248 else
6249 {
6250 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6251 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006252 break;
6253 }
6254 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006255 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006256 if(HAL_STATUS_SUCCESS(status))
6257 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6259 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6260 if(!HAL_STATUS_SUCCESS(status))
6261 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006262 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006263 csrScanResultPurge(pMac, hBSSList);
6264 fCallCallback = eANI_BOOLEAN_TRUE;
6265 }
6266 }//Have scan result
6267 else if(NULL != pProfile)
6268 {
6269 //Check whether it is for start ibss
6270 if(CSR_IS_START_IBSS(pProfile))
6271 {
6272 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6273 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6274 if(!HAL_STATUS_SUCCESS(status))
6275 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006276 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006277 fCallCallback = eANI_BOOLEAN_TRUE;
6278 }
6279 }
6280 else
6281 {
6282 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006283 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 if(!HAL_STATUS_SUCCESS(status))
6285 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006286 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006287 fCallCallback = eANI_BOOLEAN_TRUE;
6288 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006289 else
6290 {
6291 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6292 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006293 }
6294 }
6295 else
6296 {
6297 fCallCallback = eANI_BOOLEAN_TRUE;
6298 }
6299 } while (0);
6300 if(NULL != pProfile)
6301 {
6302 //we need to free memory for filter if profile exists
6303 csrFreeScanFilter(pMac, pScanFilter);
6304 }
6305 }//Got the scan filter from profile
6306
6307 palFreeMemory(pMac->hHdd, pScanFilter);
6308 }//allocated memory for pScanFilter
6309 }//No Bsslist coming in
6310 //tell the caller if we fail to trigger a join request
6311 if( fCallCallback )
6312 {
6313 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6314 }
6315
6316 return (status);
6317}
Jeff Johnson295189b2012-06-20 16:38:30 -07006318eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6319 tCsrRoamModifyProfileFields modProfileFields,
6320 tANI_U32 *pRoamId)
6321{
6322 eHalStatus status = eHAL_STATUS_SUCCESS;
6323 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6324 tANI_U32 roamId = 0;
6325 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 if (NULL == pProfile)
6327 {
6328 smsLog(pMac, LOGP, FL("No profile specified"));
6329 return eHAL_STATUS_FAILURE;
6330 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006331 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 -07006332 csrRoamCancelRoaming(pMac, sessionId);
6333 csrScanRemoveFreshScanCommand(pMac, sessionId);
6334 csrScanCancelIdleScan(pMac);
6335 csrScanAbortMacScanNotForConnect(pMac);
6336 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006337 if(csrIsConnStateConnected(pMac, sessionId))
6338 {
6339 if(pProfile)
6340 {
6341 if(pProfile->SSIDs.numOfSSIDs &&
6342 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6343 {
6344 fCallCallback = eANI_BOOLEAN_FALSE;
6345 }
6346 else
6347 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006348 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006349 }
6350 }
6351 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
6352 &pSession->connectedProfile.modifyProfileFields,
6353 sizeof(tCsrRoamModifyProfileFields)))
6354 {
6355 fCallCallback = eANI_BOOLEAN_FALSE;
6356 }
6357 else
6358 {
6359 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006360 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006361 }
6362 }
6363 else
6364 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006365 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 if(!fCallCallback)
6368 {
6369 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6370 if(pRoamId)
6371 {
6372 *pRoamId = roamId;
6373 }
6374
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6376 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006377 }
6378 else
6379 {
6380 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6381 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006383 return status;
6384}
Jeff Johnson295189b2012-06-20 16:38:30 -07006385eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6386{
6387 eHalStatus status = eHAL_STATUS_FAILURE;
6388 tScanResultHandle hBSSList = NULL;
6389 tCsrScanResultFilter *pScanFilter = NULL;
6390 tANI_U32 roamId;
6391 tCsrRoamProfile *pProfile = NULL;
6392 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006393
6394 if(!pSession)
6395 {
6396 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6397 return eHAL_STATUS_FAILURE;
6398 }
6399
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 do
6401 {
6402 if(pSession->pCurRoamProfile)
6403 {
6404 csrScanCancelIdleScan(pMac);
6405 csrScanAbortMacScanNotForConnect(pMac);
6406 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6407 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6408 if(!HAL_STATUS_SUCCESS(status))
6409 break;
6410 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6411 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6412 if(!HAL_STATUS_SUCCESS(status))
6413 break;
6414 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6415 if(!HAL_STATUS_SUCCESS(status))
6416 {
6417 break;
6418 }
6419 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6420 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6421 if(!HAL_STATUS_SUCCESS(status))
6422 {
6423 break;
6424 }
6425 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6426 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6427 if(HAL_STATUS_SUCCESS(status))
6428 {
6429 //we want to put the last connected BSS to the very beginning, if possible
6430 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6431 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6432 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6433 if(!HAL_STATUS_SUCCESS(status))
6434 {
6435 csrScanResultPurge(pMac, hBSSList);
6436 break;
6437 }
6438 }
6439 else
6440 {
6441 //Do a scan on this profile
6442 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006443 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006444 if(!HAL_STATUS_SUCCESS(status))
6445 {
6446 break;
6447 }
6448 }
6449 }//We have a profile
6450 else
6451 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006452 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 break;
6454 }
6455 }while(0);
6456 if(pScanFilter)
6457 {
6458 csrFreeScanFilter(pMac, pScanFilter);
6459 palFreeMemory(pMac->hHdd, pScanFilter);
6460 }
6461 if(NULL != pProfile)
6462 {
6463 csrReleaseProfile(pMac, pProfile);
6464 palFreeMemory(pMac->hHdd, pProfile);
6465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006466 return (status);
6467}
Jeff Johnson295189b2012-06-20 16:38:30 -07006468eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6469{
6470 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 if(csrIsConnStateConnected(pMac, sessionId))
6472 {
6473 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6474 if(HAL_STATUS_SUCCESS(status))
6475 {
6476 status = csrRoamJoinLastProfile(pMac, sessionId);
6477 }
6478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 return (status);
6480}
6481
Jeff Johnson295189b2012-06-20 16:38:30 -07006482eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6483{
6484 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006485 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 csrRoamCancelRoaming(pMac, sessionId);
6487 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6488 if(csrIsConnStateDisconnected(pMac, sessionId))
6489 {
6490 status = csrRoamJoinLastProfile(pMac, sessionId);
6491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006492 return (status);
6493}
6494
Jeff Johnson295189b2012-06-20 16:38:30 -07006495eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6496{
6497 eHalStatus status = eHAL_STATUS_SUCCESS;
6498 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6499 eCsrRoamSubState NewSubstate;
6500 tANI_U32 sessionId = pCommand->sessionId;
6501
6502 // change state to 'Roaming'...
6503 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6504
6505 if ( csrIsConnStateIbss( pMac, sessionId ) )
6506 {
6507 // If we are in an IBSS, then stop the IBSS...
6508 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6509 fComplete = (!HAL_STATUS_SUCCESS(status));
6510 }
6511 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6512 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006513 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 -07006514 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6515 //Restore AC weight in case we change it
6516 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6517 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6518 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6519 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6520 {
6521 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6522 }
6523 if( fDisassoc )
6524 {
6525 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6526 }
6527 else
6528 {
6529 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6530 }
6531 fComplete = (!HAL_STATUS_SUCCESS(status));
6532 }
6533 else if ( csrIsConnStateWds( pMac, sessionId ) )
6534 {
6535 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6536 {
6537 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6538 fComplete = (!HAL_STATUS_SUCCESS(status));
6539 }
6540 //This has to be WDS station
6541 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6542 {
6543
6544 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6545 if( fDisassoc )
6546 {
6547 status = csrRoamIssueDisassociate( pMac, sessionId,
6548 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6549 fComplete = (!HAL_STATUS_SUCCESS(status));
6550 }
6551 }
6552 } else {
6553 // we got a dis-assoc request while not connected to any peer
6554 // just complete the command
6555 fComplete = eANI_BOOLEAN_TRUE;
6556 status = eHAL_STATUS_FAILURE;
6557 }
6558 if(fComplete)
6559 {
6560 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6561 }
6562
6563 if(HAL_STATUS_SUCCESS(status))
6564 {
6565 if ( csrIsConnStateInfra( pMac, sessionId ) )
6566 {
6567 //Set the state to disconnect here
6568 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6569 }
6570 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006571 else
6572 {
6573 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006575 return (status);
6576}
6577
Jeff Johnson295189b2012-06-20 16:38:30 -07006578/* This is been removed from latest code base */
6579/*
6580static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6581{
6582 eHalStatus status;
6583 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006584 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6585 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006586 return ( status );
6587}
6588*/
6589
Jeff Johnson295189b2012-06-20 16:38:30 -07006590eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6591{
6592 eHalStatus status = eHAL_STATUS_SUCCESS;
6593 tSmeCmd *pCommand;
6594 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006595 do
6596 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006597 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006598 pCommand = csrGetCommandBuffer( pMac );
6599 if ( !pCommand )
6600 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006601 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 status = eHAL_STATUS_RESOURCES;
6603 break;
6604 }
6605 //Change the substate in case it is wait-for-key
6606 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6607 {
6608 csrRoamStopWaitForKeyTimer( pMac );
6609 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6610 }
6611 pCommand->command = eSmeCommandRoam;
6612 pCommand->sessionId = (tANI_U8)sessionId;
6613 switch ( reason )
6614 {
6615 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6616 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6617 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 case eCSR_DISCONNECT_REASON_DEAUTH:
6619 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6620 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006621 case eCSR_DISCONNECT_REASON_HANDOFF:
6622 fHighPriority = eANI_BOOLEAN_TRUE;
6623 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6624 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6626 case eCSR_DISCONNECT_REASON_DISASSOC:
6627 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6628 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6630 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6631 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6633 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6634 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 default:
6636 break;
6637 }
6638 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6639 if( !HAL_STATUS_SUCCESS( status ) )
6640 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006641 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 csrReleaseCommandRoam( pMac, pCommand );
6643 }
6644 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 return( status );
6646}
6647
Jeff Johnson295189b2012-06-20 16:38:30 -07006648eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6649{
6650 eHalStatus status = eHAL_STATUS_SUCCESS;
6651 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 pCommand = csrGetCommandBuffer( pMac );
6653 if ( NULL != pCommand )
6654 {
6655 //Change the substate in case it is wait-for-key
6656 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6657 {
6658 csrRoamStopWaitForKeyTimer( pMac );
6659 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6660 }
6661 pCommand->command = eSmeCommandRoam;
6662 pCommand->sessionId = (tANI_U8)sessionId;
6663 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6664 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6665 if( !HAL_STATUS_SUCCESS( status ) )
6666 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006667 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006668 csrReleaseCommandRoam( pMac, pCommand );
6669 }
6670 }
6671 else
6672 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006673 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006674 status = eHAL_STATUS_RESOURCES;
6675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 return ( status );
6677}
6678
Jeff Johnson295189b2012-06-20 16:38:30 -07006679eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6680{
6681 eHalStatus status = eHAL_STATUS_SUCCESS;
6682 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006683
6684 if(!pSession)
6685 {
6686 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6687 return eHAL_STATUS_FAILURE;
6688 }
6689
Jeff Johnson295189b2012-06-20 16:38:30 -07006690#ifdef FEATURE_WLAN_BTAMP_UT_RF
6691 //Stop te retry
6692 pSession->maxRetryCount = 0;
6693 csrRoamStopJoinRetryTimer(pMac, sessionId);
6694#endif
6695 //Not to call cancel roaming here
6696 //Only issue disconnect when necessary
6697 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6698 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6699 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6700
6701 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006702 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006703 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 return (status);
6706}
6707
Jeff Johnson295189b2012-06-20 16:38:30 -07006708eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6709{
6710 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006711
6712 if(!pSession)
6713 {
6714 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6715 return eHAL_STATUS_FAILURE;
6716 }
6717
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 csrRoamCancelRoaming(pMac, sessionId);
6719 pSession->ibss_join_pending = FALSE;
6720 csrRoamStopIbssJoinTimer(pMac, sessionId);
6721 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6722
6723 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6724}
6725
Jeff Johnson295189b2012-06-20 16:38:30 -07006726eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6727 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6728{
6729 eHalStatus status = eHAL_STATUS_SUCCESS;
6730 tDot11fBeaconIEs *pIesTemp = pIes;
6731 tANI_U8 index;
6732 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6733 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006734
6735 if(!pSession)
6736 {
6737 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6738 return eHAL_STATUS_FAILURE;
6739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006740
6741 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6742 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6743 pConnectProfile->AuthInfo = pProfile->AuthType;
6744 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6745 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6746 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6747 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6748 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6749 pConnectProfile->BSSType = pProfile->BSSType;
6750 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6751 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006752 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6753
Jeff Johnson295189b2012-06-20 16:38:30 -07006754 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006755 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6756 if(pProfile->nAddIEAssocLength)
6757 {
6758 status = palAllocateMemory(pMac->hHdd,
6759 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6760 if(!HAL_STATUS_SUCCESS(status))
6761 {
6762 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6763 return eHAL_STATUS_FAILURE;
6764 }
6765 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6766 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6767 pProfile->nAddIEAssocLength);
6768 }
6769
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 //Save bssid
6771 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6772#ifdef WLAN_FEATURE_VOWIFI_11R
6773 if (pSirBssDesc->mdiePresent)
6774 {
6775 pConnectProfile->MDID.mdiePresent = 1;
6776 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6777 }
6778#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07006779 if( NULL == pIesTemp )
6780 {
6781 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006783#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006784 if ((csrIsProfileCCX(pProfile) ||
6785 ((pIesTemp->CCXVersion.present)
6786 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6787 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6788 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6789 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07006790#ifdef WLAN_FEATURE_11W
6791 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
6792#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05306793 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006794 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006795 {
6796 pConnectProfile->isCCXAssoc = 1;
6797 }
6798#endif
6799 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07006800 if(HAL_STATUS_SUCCESS(status))
6801 {
6802 if(pIesTemp->SSID.present)
6803 {
6804 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6805 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6806 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6807 }
6808
6809 //Save the bss desc
6810 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306811
6812 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006813 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306814 //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 -07006815 pConnectProfile->qap = TRUE;
6816 }
6817 else
6818 {
6819 pConnectProfile->qap = FALSE;
6820 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006821 if ( NULL == pIes )
6822 {
6823 //Free memory if it allocated locally
6824 palFreeMemory(pMac->hHdd, pIesTemp);
6825 }
6826 }
6827 //Save Qos connection
6828 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6829
6830 if(!HAL_STATUS_SUCCESS(status))
6831 {
6832 csrFreeConnectBssDesc(pMac, sessionId);
6833 }
6834 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6835 {
6836 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6837 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6838 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6839 {
6840 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6841 break;
6842 }
6843 pConnectProfile->handoffPermitted = FALSE;
6844 }
6845
6846 return (status);
6847}
6848
Jeff Johnson295189b2012-06-20 16:38:30 -07006849static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6850{
6851 tListElem *pEntry = NULL;
6852 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 //The head of the active list is the request we sent
6854 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6855 if(pEntry)
6856 {
6857 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006859 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6860 {
6861 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6862 {
6863#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6864 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6865#endif
6866 }
6867 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6868 }
6869 else
6870 {
6871 tANI_U32 roamId = 0;
6872 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006873 if(!pSession)
6874 {
6875 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6876 return;
6877 }
6878
Jeff Johnson295189b2012-06-20 16:38:30 -07006879
6880 //The head of the active list is the request we sent
6881 //Try to get back the same profile and roam again
6882 if(pCommand)
6883 {
6884 roamId = pCommand->u.roamCmd.roamId;
6885 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006886 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6887 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006888 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07006889#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6890 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6891 if (csrRoamIsHandoffInProgress(pMac))
6892 {
6893 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6894 /* Should indicate neighbor roam algorithm about the connect failure here */
6895 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
6896 }
6897#endif
6898 if (pCommand)
6899 {
6900 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
6901 {
6902 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6903 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
6904 csrRoamReissueRoamCommand(pMac);
6905 }
6906 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
6907 {
6908 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6909 }
6910 else
6911 {
6912 csrRoam(pMac, pCommand);
6913 }
6914 }
6915 else
6916 {
6917 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6918 }
6919 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
6920}
6921
Jeff Johnson295189b2012-06-20 16:38:30 -07006922eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6923 tDot11fBeaconIEs *pIes,
6924 tCsrRoamProfile *pProfile, tANI_U32 roamId )
6925{
6926 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006927 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006928 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
6929 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
6930
6931 // Set the roaming substate to 'join attempt'...
6932 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006933 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006934 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 return (status);
6936}
6937
Jeff Johnson295189b2012-06-20 16:38:30 -07006938static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6939 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
6940{
6941 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006942 // Set the roaming substate to 'join attempt'...
6943 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
6944
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006945 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006946
6947 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006948 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07006949}
6950
Jeff Johnson295189b2012-06-20 16:38:30 -07006951void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
6952{
6953 tListElem *pEntry;
6954 tSmeCmd *pCommand;
6955 tCsrRoamInfo roamInfo;
6956 tANI_U32 sessionId;
6957 tCsrRoamSession *pSession;
6958
6959 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6960 if(pEntry)
6961 {
6962 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6963 if ( eSmeCommandRoam == pCommand->command )
6964 {
6965 sessionId = pCommand->sessionId;
6966 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006967
6968 if(!pSession)
6969 {
6970 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6971 return;
6972 }
6973
Jeff Johnson295189b2012-06-20 16:38:30 -07006974 if( pCommand->u.roamCmd.fStopWds )
6975 {
6976 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
6977 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6978 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6979 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07006980 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6982 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6983 eCSR_ROAM_WDS_IND,
6984 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07006985 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
6986 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6987 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6988 eCSR_ROAM_INFRA_IND,
6989 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
6990 }
6991
Jeff Johnson295189b2012-06-20 16:38:30 -07006992
Jeff Johnson295189b2012-06-20 16:38:30 -07006993 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
6994 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006995 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07006996 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6997 }
6998 }
6999 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7000 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007001 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007002 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7003 }
7004 }
7005 else
7006 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007007 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007008 }
7009 }
7010 else
7011 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007012 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007013 }
7014}
7015
Jeff Johnson295189b2012-06-20 16:38:30 -07007016tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7017{
7018 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7019 tListElem *pEntry;
7020 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 //alwasy lock active list before locking pending list
7022 csrLLLock( &pMac->sme.smeCmdActiveList );
7023 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7024 if(pEntry)
7025 {
7026 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7027 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7028 {
7029 fRet = eANI_BOOLEAN_TRUE;
7030 }
7031 }
7032 if(eANI_BOOLEAN_FALSE == fRet)
7033 {
7034 csrLLLock(&pMac->sme.smeCmdPendingList);
7035 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7036 while(pEntry)
7037 {
7038 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7039 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7040 {
7041 fRet = eANI_BOOLEAN_TRUE;
7042 break;
7043 }
7044 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7045 }
7046 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7047 }
7048 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007049 return (fRet);
7050}
7051
Jeff Johnson295189b2012-06-20 16:38:30 -07007052tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7053{
7054 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7055 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007056 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7057 {
7058 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7059 {
7060 break;
7061 }
7062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007063 return ( fRet );
7064}
7065
Jeff Johnson295189b2012-06-20 16:38:30 -07007066tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7067{
7068 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007069 //alwasy lock active list before locking pending list
7070 csrLLLock( &pMac->sme.smeCmdActiveList );
7071 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7072 if(eANI_BOOLEAN_FALSE == fRet)
7073 {
7074 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7075 }
7076 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007077 return (fRet);
7078}
7079
Jeff Johnson295189b2012-06-20 16:38:30 -07007080tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7081{
7082 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7083 tListElem *pEntry;
7084 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007085 //alwasy lock active list before locking pending list
7086 csrLLLock( &pMac->sme.smeCmdActiveList );
7087 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7088 if( pEntry )
7089 {
7090 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7091 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7092 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7093 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7094 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7095 {
7096 fRet = eANI_BOOLEAN_TRUE;
7097 }
7098 }
7099 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007100 return (fRet);
7101}
Jeff Johnson295189b2012-06-20 16:38:30 -07007102eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7103{
7104 eHalStatus status = eHAL_STATUS_SUCCESS;
7105 tSmeCmd *pCommand = NULL;
7106 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7107 tANI_BOOLEAN fRemoveCmd = FALSE;
7108 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007109 // Delete the old assoc command. All is setup for reassoc to be serialized
7110 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7111 if ( pEntry )
7112 {
7113 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7114 if ( !pCommand )
7115 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007116 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007117 return eHAL_STATUS_RESOURCES;
7118 }
7119 if ( eSmeCommandRoam == pCommand->command )
7120 {
7121 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7122 {
7123 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7124 }
7125 else
7126 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007127 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007128 }
7129 if (fRemoveCmd == FALSE)
7130 {
7131 // Implies we did not get the serialized assoc command we
7132 // were expecting
7133 pCommand = NULL;
7134 }
7135 }
7136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007137 if(NULL == pCommand)
7138 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007139 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007140 return eHAL_STATUS_RESOURCES;
7141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007142 do
7143 {
7144 //Change the substate in case it is wait-for-key
7145 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7146 {
7147 csrRoamStopWaitForKeyTimer( pMac );
7148 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7149 }
7150 pCommand->command = eSmeCommandRoam;
7151 pCommand->sessionId = (tANI_U8)sessionId;
7152 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7154 if( !HAL_STATUS_SUCCESS( status ) )
7155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007156 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007157 csrReleaseCommandRoam( pMac, pCommand );
7158 }
7159 } while( 0 );
7160
Jeff Johnson295189b2012-06-20 16:38:30 -07007161 return( status );
7162}
7163static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7164{
7165 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7166 tCsrScanResult *pScanResult = NULL;
7167 tSirBssDescription *pBssDesc = NULL;
7168 tSmeCmd *pCommand = NULL;
7169 tANI_U32 sessionId;
7170 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 if(NULL == pEntry)
7172 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007173 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007174 return;
7175 }
7176 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7177 sessionId = pCommand->sessionId;
7178 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007179
7180 if(!pSession)
7181 {
7182 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7183 return;
7184 }
7185
Jeff Johnson295189b2012-06-20 16:38:30 -07007186 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7187 {
7188 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007189 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007190 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7191 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007192 /* If the roaming has stopped, not to continue the roaming command*/
7193 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7194 {
7195 //No need to complete roaming here as it already completes
7196 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7197 pCommand->u.roamCmd.roamReason);
7198 csrSetAbortRoamingCommand( pMac, pCommand );
7199 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7200 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 else
7202 {
7203 if ( CCM_IS_RESULT_SUCCESS(result) )
7204 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007205 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007206 // Successfully set the configuration parameters for the new Bss. Attempt to
7207 // join the roaming Bss.
7208 if(pCommand->u.roamCmd.pRoamBssEntry)
7209 {
7210 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7211 pBssDesc = &pScanResult->Result.BssDescriptor;
7212 }
7213 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7214 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 )
7217 {
7218 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7219 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7220 pBssDesc, pCommand->u.roamCmd.roamId )))
7221 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007222 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007223 //We need to complete the command
7224 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7225 }
7226 }
7227 else
7228 {
7229 if (!pCommand->u.roamCmd.pRoamBssEntry)
7230 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007231 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 //We need to complete the command
7233 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7234 return;
7235 }
7236 // If we are roaming TO an Infrastructure BSS...
7237 VOS_ASSERT(pScanResult != NULL);
7238 if ( csrIsInfraBssDesc( pBssDesc ) )
7239 {
7240 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7242 {
7243 // ..and currently in an Infrastructure connection....
7244 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7245 {
7246 // ...and the SSIDs are equal, then we Reassoc.
7247 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7248 pIesLocal ) )
7249 // ..and currently in an infrastructure connection
7250 {
7251 // then issue a Reassoc.
7252 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7253 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7254 &pCommand->u.roamCmd.roamProfile );
7255 }
7256 else
7257 {
7258
7259 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7260 // previously associated AP.
7261 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7262 pIesLocal,
7263 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7264 {
7265 //try something else
7266 csrRoam( pMac, pCommand );
7267 }
7268 }
7269 }
7270 else
7271 {
7272 eHalStatus status = eHAL_STATUS_SUCCESS;
7273
7274 /* We need to come with other way to figure out that this is because of HO in BMP
7275 The below API will be only available for Android as it uses a different HO algorithm */
7276 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7277 * use join request */
7278#ifdef WLAN_FEATURE_VOWIFI_11R
7279 if (csrRoamIsHandoffInProgress(pMac) &&
7280 csrRoamIs11rAssoc(pMac))
7281 {
7282 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7283 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7284 }
7285 else
7286#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007287#ifdef FEATURE_WLAN_CCX
7288 if (csrRoamIsHandoffInProgress(pMac) &&
7289 csrRoamIsCCXAssoc(pMac))
7290 {
7291 // Now serialize the reassoc command.
7292 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7293 }
7294 else
7295#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007296#ifdef FEATURE_WLAN_LFR
7297 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307298 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007299 {
7300 // Now serialize the reassoc command.
7301 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7302 }
7303 else
7304#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007305 // else we are not connected and attempting to Join. Issue the
7306 // Join request.
7307 {
7308 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7309 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7310 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7311 }
7312 if(!HAL_STATUS_SUCCESS(status))
7313 {
7314 //try something else
7315 csrRoam( pMac, pCommand );
7316 }
7317 }
7318 if( !pScanResult->Result.pvIes )
7319 {
7320 //Locally allocated
7321 palFreeMemory(pMac->hHdd, pIesLocal);
7322 }
7323 }
7324 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7325 else
7326 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007327 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007328 }
7329 }//else
7330 }//if ( WNI_CFG_SUCCESS == result )
7331 else
7332 {
7333 // In the event the configuration failed, for infra let the roam processor
7334 //attempt to join something else...
7335 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7336 {
7337 csrRoam(pMac, pCommand);
7338 }
7339 else
7340 {
7341 //We need to complete the command
7342 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7343 {
7344 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7345 }
7346 else
7347 {
7348 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7349 }
7350 }
7351 }
7352 }//we have active entry
7353}
7354
Jeff Johnson295189b2012-06-20 16:38:30 -07007355static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7356{
7357 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007358 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007359 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7360 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007361 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007362 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7363 // join the new one...
7364 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007365 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7366 }
7367 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007368 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007369 /***profHandleLostLinkAfterReset(pAdapter);
7370 // In the event the authenticate fails, let the roam processor attempt to join something else...
7371 roamRoam( pAdapter );***/
7372 }
7373}
7374
Jeff Johnson295189b2012-06-20 16:38:30 -07007375static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7376{
7377 eCsrRoamCompleteResult result;
7378 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7379 tCsrRoamInfo roamInfo;
7380 tANI_U32 roamId = 0;
7381
7382 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007384 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007385 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007386 /* Defeaturize this part later if needed */
7387#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7388 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7389 * we need the response contents while processing the result in csrRoamProcessResults() */
7390 if (csrRoamIsHandoffInProgress(pMac))
7391 {
7392 /* Need to dig more on indicating events to SME QoS module */
7393 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7394 csrRoamComplete( pMac, result, pSmeJoinRsp);
7395 }
7396 else
7397#endif
7398 {
7399 csrRoamComplete( pMac, result, NULL );
7400 }
7401 }
7402 /* Should we handle this similar to handling the join failure? Is it ok
7403 * to call csrRoamComplete() with state as CsrJoinFailure */
7404 else
7405 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007406 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007407 result = eCsrReassocFailure;
7408#ifdef WLAN_FEATURE_VOWIFI_11R
7409 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7410 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7411 {
7412 // Inform HDD to turn off FT flag in HDD
7413 if (pNeighborRoamInfo)
7414 {
7415 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7416 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7417 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007418 /*
7419 * Since the above callback sends a disconnect
7420 * to HDD, we should clean-up our state
7421 * machine as well to be in sync with the upper
7422 * layers. There is no need to send a disassoc
7423 * since: 1) we will never reassoc to the current
7424 * AP in LFR, and 2) there is no need to issue a
7425 * disassoc to the AP with which we were trying
7426 * to reassoc.
7427 */
7428 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7429 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007430 }
7431 }
7432#endif
7433 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7434 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7435 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7436 //The disassoc rsp message will remove the command from active list
7437 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7438 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7439 {
7440 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7441 }
7442 }
7443}
7444
Jeff Johnson295189b2012-06-20 16:38:30 -07007445static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7446{
Jeff Johnson295189b2012-06-20 16:38:30 -07007447#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7448 {
7449 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007450 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7451 if(pIbssLog)
7452 {
7453 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7454 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7455 {
7456 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7457 }
7458 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7459 }
7460 }
7461#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007462 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7463 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7464 {
7465 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7466 }
7467 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7468 {
7469 csrRoamReissueRoamCommand(pMac);
7470 }
7471}
7472
Jeff Johnson295189b2012-06-20 16:38:30 -07007473void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7474{
7475 tSirResultCodes statusCode;
7476#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7477 tScanResultHandle hBSSList;
7478 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7479 eHalStatus status;
7480 tCsrRoamInfo roamInfo;
7481 tCsrScanResultFilter *pScanFilter = NULL;
7482 tANI_U32 roamId = 0;
7483 tCsrRoamProfile *pCurRoamProfile = NULL;
7484 tListElem *pEntry = NULL;
7485 tSmeCmd *pCommand = NULL;
7486#endif
7487 tANI_U32 sessionId;
7488 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007489
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 tSirSmeDisassocRsp SmeDisassocRsp;
7491
7492 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7493 sessionId = SmeDisassocRsp.sessionId;
7494 statusCode = SmeDisassocRsp.statusCode;
7495
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007496 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007497
7498 if ( csrIsConnStateInfra( pMac, sessionId ) )
7499 {
7500 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7501 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007502 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007503
7504 if(!pSession)
7505 {
7506 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7507 return;
7508 }
7509
Jeff Johnson295189b2012-06-20 16:38:30 -07007510 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7511 {
7512 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7513 }
7514 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7515 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7516 {
7517 if ( eSIR_SME_SUCCESS == statusCode )
7518 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007519 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007520 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7521 }
7522 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007524 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7525 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007526 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007527#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007528 /*
7529 * First ensure if the roam profile is in the scan cache.
7530 * If not, post a reassoc failure and disconnect.
7531 */
7532 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7533 if(HAL_STATUS_SUCCESS(status))
7534 {
7535 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7536 status = csrRoamPrepareFilterFromProfile(pMac,
7537 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7538 if(!HAL_STATUS_SUCCESS(status))
7539 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007540 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007541 __func__, status);
7542 goto POST_ROAM_FAILURE;
7543 }
7544 else
7545 {
7546 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7547 if (!HAL_STATUS_SUCCESS(status))
7548 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007549 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007550 __func__, status);
7551 goto POST_ROAM_FAILURE;
7552 }
7553 }
7554 }
7555 else
7556 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007557 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007558 __func__, status);
7559 goto POST_ROAM_FAILURE;
7560 }
7561
7562 /*
7563 * After ensuring that the roam profile is in the scan result list,
7564 * dequeue the command from the active list.
7565 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007566 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7567 if ( pEntry )
7568 {
7569 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007570 /* If the head of the queue is Active and it is a ROAM command, remove
7571 * and put this on the Free queue.
7572 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007573 if ( eSmeCommandRoam == pCommand->command )
7574 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007575
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007576 /*
7577 * we need to process the result first before removing it from active list
7578 * because state changes still happening insides roamQProcessRoamResults so
7579 * no other roam command should be issued.
7580 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007581 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7582 if(pCommand->u.roamCmd.fReleaseProfile)
7583 {
7584 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7585 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7586 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007587 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007588 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007589 else
7590 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007591 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007592 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007593 }
7594 }
7595 else
7596 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007597 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007598 }
7599 }
7600 else
7601 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007602 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007603 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007604
7605 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007606 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7607
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007608 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7609 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7610 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007611
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007612 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7613 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007614
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007615 /* Copy the connected profile to apply the same for this connection as well */
7616 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7617 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007618 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007619 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7620 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7621 //make sure to put it at the head of the cmd queue
7622 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7623 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7624 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7625
Jeff Johnson295189b2012-06-20 16:38:30 -07007626 if(!HAL_STATUS_SUCCESS(status))
7627 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007628 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007629 __func__, status);
7630 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007631 }
7632
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007633 /* Notify sub-modules like QoS etc. that handoff happening */
7634 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007635 csrReleaseProfile(pMac, pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007636 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007637 csrFreeScanFilter(pMac, pScanFilter);
7638 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007639 return;
7640 }
7641
7642POST_ROAM_FAILURE:
7643 if (pScanFilter)
7644 {
7645 csrFreeScanFilter(pMac, pScanFilter);
7646 palFreeMemory( pMac->hHdd, pScanFilter );
7647 }
7648 if (pCurRoamProfile)
7649 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7650
7651 /* Inform the upper layers that the reassoc failed */
7652 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7653 csrRoamCallCallback(pMac, sessionId,
7654 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7655
7656 /*
7657 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7658 * Upon success, we would re-enter this routine after receiving the disassoc
7659 * response and will fall into the reassoc fail sub-state. And, eventually
7660 * call csrRoamComplete which would remove the roam command from SME active
7661 * queue.
7662 */
7663 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7664 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7665 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007666 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007667 __func__, status);
7668 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007669 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007670#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007671
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7673 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7674 {
7675 // Disassoc due to Reassoc failure falls into this codepath....
7676 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7677 }
7678 else
7679 {
7680 if ( eSIR_SME_SUCCESS == statusCode )
7681 {
7682 // Successfully disassociated from the 'old' Bss...
7683 //
7684 // We get Disassociate response in three conditions.
7685 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7686 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7687 // Infrastructure network.
7688 // - Third is where we are doing an Infra to Infra roam between networks with different
7689 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7690
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007691 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007692 }
7693 else
7694 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007695 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007696 }
7697 //We are not done yet. Get the data and continue roaming
7698 csrRoamReissueRoamCommand(pMac);
7699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007700}
7701
Jeff Johnson295189b2012-06-20 16:38:30 -07007702static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7703{
7704 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007705 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007706 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007707 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7708 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7709 {
7710 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7711 }
7712 else
7713 {
7714 if ( eSIR_SME_SUCCESS == statusCode )
7715 {
7716 // Successfully deauth from the 'old' Bss...
7717 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007718 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007719 }
7720 else
7721 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007722 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007723 }
7724 //We are not done yet. Get the data and continue roaming
7725 csrRoamReissueRoamCommand(pMac);
7726 }
7727}
7728
Jeff Johnson295189b2012-06-20 16:38:30 -07007729static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7730{
7731 eCsrRoamCompleteResult result;
7732
7733 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7734 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007735 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007736 result = eCsrStartBssSuccess;
7737 }
7738 else
7739 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007740 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007741 //Let csrRoamComplete decide what to do
7742 result = eCsrStartBssFailure;
7743 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007744 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007745}
7746
Jeff Johnson295189b2012-06-20 16:38:30 -07007747/*
7748 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7749 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7750 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7751 For the messages where sender allocates memory for specific structures, then it can be
7752 cast accordingly.
7753*/
7754void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7755{
7756 tSirSmeRsp *pSmeRsp;
7757 tSmeIbssPeerInd *pIbssPeerInd;
7758 tCsrRoamInfo roamInfo;
7759 // TODO Session Id need to be acquired in this function
7760 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007761 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007762 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007763 pSmeRsp->messageType, pSmeRsp->messageType,
7764 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07007765 pSmeRsp->messageType = (pSmeRsp->messageType);
7766 pSmeRsp->length = (pSmeRsp->length);
7767 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007768 switch (pSmeRsp->messageType)
7769 {
7770
7771 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7772 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7773 {
7774 //We sent a JOIN_REQ
7775 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7776 }
7777 break;
7778
7779 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7780 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7781 {
7782 //We sent a AUTH_REQ
7783 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7784 }
7785 break;
7786
7787 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7788 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7789 {
7790 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7791 }
7792 break;
7793
7794 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7795 {
7796 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7797 }
7798 break;
7799
7800 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7801 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7802 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7803 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7804 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7805 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7806//HO
7807 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7808 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007809 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7811 }
7812 break;
7813
7814 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7815 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7816 {
7817 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7818 }
7819 break;
7820
7821 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7822 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7823 {
7824 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7825 }
7826 break;
7827
7828 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7829 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7830 {
7831 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7832 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007834 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7835 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7836 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007837 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Jeff Johnson295189b2012-06-20 16:38:30 -07007838 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7839 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7840 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7841 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7842 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7843 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7844 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7845 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7846 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007847 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007848 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007849 pSmeRsp->messageType, pSmeRsp->messageType,
7850 pMac->roam.curSubState[pSmeRsp->sessionId] );
7851
7852 //If we are connected, check the link status change
7853 if(!csrIsConnStateDisconnected(pMac, sessionId))
7854 {
7855 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7856 }
7857 break;
7858 }
7859}
7860
Jeff Johnson295189b2012-06-20 16:38:30 -07007861void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7862{
7863 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007864 switch (pSirMsg->messageType)
7865 {
7866 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007867 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007868 csrRoamStatsRspProcessor( pMac, pSirMsg );
7869 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007870 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7871 {
7872 tCsrRoamSession *pSession;
7873 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7874 tCsrRoamInfo roamInfo;
7875 tCsrRoamInfo *pRoamInfo = NULL;
7876 tANI_U32 sessionId;
7877 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007878 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Jeff Johnson295189b2012-06-20 16:38:30 -07007879 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7880 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007881 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7882 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7883 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007884
7885 if(!pSession)
7886 {
7887 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7888 return;
7889 }
7890
Jeff Johnson295189b2012-06-20 16:38:30 -07007891 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
7892 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07007893 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
7894 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
7895 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007896 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
7897 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007898 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
7899 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07007900 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07007901 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
7902 {
7903 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
7904 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
7905 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
7906 }
7907 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
7908 {
7909 vos_sleep( 100 );
7910 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
7911 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
7912 }
7913
Jeff Johnson295189b2012-06-20 16:38:30 -07007914 }
7915 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007916 default:
7917 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
7918 break;
7919 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007920}
7921
Jeff Johnson295189b2012-06-20 16:38:30 -07007922eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
7923 tSirBssDescription *pBssDescription,
7924 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
7925 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
7926 tANI_U8 keyId, tANI_U16 keyLength,
7927 tANI_U8 *pKey, tANI_U8 paeRole )
7928{
7929 eHalStatus status = eHAL_STATUS_SUCCESS;
7930 tAniEdType edType;
7931
7932 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
7933 {
7934 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
7935 }
7936
7937 edType = csrTranslateEncryptTypeToEdType( EncryptType );
7938
7939 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
7940 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
7941 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
7942 addKey )
7943 {
7944 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07007945 setKey.encType = EncryptType;
7946 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
7947 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
7948 setKey.paeRole = paeRole; //0 for supplicant
7949 setKey.keyId = keyId; // Kye index
7950 setKey.keyLength = keyLength;
7951 if( keyLength )
7952 {
7953 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
7954 }
7955 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
7956 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007957 return (status);
7958}
7959
Jeff Johnson295189b2012-06-20 16:38:30 -07007960static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7961 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7962{
7963 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7964 tSmeCmd *pCommand = NULL;
7965#ifdef FEATURE_WLAN_CCX
7966 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7967#endif /* FEATURE_WLAN_CCX */
7968
7969 do
7970 {
7971 pCommand = csrGetCommandBuffer(pMac);
7972 if(NULL == pCommand)
7973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007974 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007975 status = eHAL_STATUS_RESOURCES;
7976 break;
7977 }
7978 pCommand->command = eSmeCommandSetKey;
7979 pCommand->sessionId = (tANI_U8)sessionId;
7980 // validate the key length, Adjust if too long...
7981 // for static WEP the keys are not set thru' SetContextReq
7982 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
7983 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
7984 {
7985 //KeyLength maybe 0 for static WEP
7986 if( pSetKey->keyLength )
7987 {
7988 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
7989 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007990 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07007991 break;
7992 }
7993
7994 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
7995 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
7996 }
7997 }
7998 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
7999 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8000 {
8001 //KeyLength maybe 0 for static WEP
8002 if( pSetKey->keyLength )
8003 {
8004 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8005 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008006 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008007 break;
8008 }
8009
8010 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
8011 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
8012 }
8013 }
8014 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8015 {
8016 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8017 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008018 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008019 break;
8020 }
8021 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
8022 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
8023 }
8024 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8025 {
8026 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8027 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008028 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008029 break;
8030 }
8031 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
8032 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
8033 }
8034#ifdef FEATURE_WLAN_WAPI
8035 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8036 {
8037 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8038 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008039 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008040 break;
8041 }
8042 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
8043 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
8044 }
8045#endif /* FEATURE_WLAN_WAPI */
8046#ifdef FEATURE_WLAN_CCX
8047 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8048 {
8049 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8050 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008051 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008052 break;
8053 }
8054 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
8055 pSession->ccxCckmInfo.reassoc_req_num=1;
8056 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8057 status = eHAL_STATUS_SUCCESS;
8058 break;
8059 }
8060#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008061
Jeff Johnson295189b2012-06-20 16:38:30 -07008062#ifdef WLAN_FEATURE_11W
8063 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008064 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008065 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008066 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008067 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008068 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 break;
8070 }
8071 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Chet Lanctot186b5732013-03-18 10:26:30 -07008072 palCopyMemory(pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008073 }
8074#endif
8075 status = eHAL_STATUS_SUCCESS;
8076 pCommand->u.setKeyCmd.roamId = roamId;
8077 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8078 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
8079 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
8080 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8081 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
8082 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
8083 //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
8084
8085 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8086 if( !HAL_STATUS_SUCCESS( status ) )
8087 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008088 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 }
8090 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008091 // Free the command if there has been a failure, or it is a
8092 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008093 if ( ( NULL != pCommand ) &&
8094 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008095#ifdef FEATURE_WLAN_CCX
8096 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8097#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008098 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008099 {
8100 csrReleaseCommandSetKey( pMac, pCommand );
8101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008102 return( status );
8103}
8104
Jeff Johnson295189b2012-06-20 16:38:30 -07008105eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8106 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8107{
8108 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8109 tSmeCmd *pCommand = NULL;
8110 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008111 do
8112 {
8113 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8114 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008115 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008116 status = eHAL_STATUS_CSR_WRONG_STATE;
8117 break;
8118 }
8119 pCommand = csrGetCommandBuffer(pMac);
8120 if(NULL == pCommand)
8121 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008122 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008123 status = eHAL_STATUS_RESOURCES;
8124 break;
8125 }
8126 pCommand->command = eSmeCommandRemoveKey;
8127 pCommand->sessionId = (tANI_U8)sessionId;
8128 pCommand->u.removeKeyCmd.roamId = roamId;
8129 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
8130 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
8131 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8132 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8133 {
8134 //in this case, put it to the end of the Q incase there is a set key pending.
8135 fImediate = eANI_BOOLEAN_FALSE;
8136 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008137 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008138 pRemoveKey->encType, pRemoveKey->keyId,
8139 pCommand->u.removeKeyCmd.peerMac[0],
8140 pCommand->u.removeKeyCmd.peerMac[1],
8141 pCommand->u.removeKeyCmd.peerMac[2],
8142 pCommand->u.removeKeyCmd.peerMac[3],
8143 pCommand->u.removeKeyCmd.peerMac[4],
8144 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008145 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8146 if( !HAL_STATUS_SUCCESS( status ) )
8147 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008148 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008149 break;
8150 }
8151 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008152 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8153 {
8154 csrReleaseCommandRemoveKey( pMac, pCommand );
8155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008156 return (status );
8157}
8158
Jeff Johnson295189b2012-06-20 16:38:30 -07008159eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8160{
8161 eHalStatus status;
8162 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8163 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8164 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8165 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008166#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8167 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8168 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008169 if(eCSR_ENCRYPT_TYPE_NONE != edType)
8170 {
8171 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8172 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8173 {
8174 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8175 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8176 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8177 }
8178 else
8179 {
8180 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8181 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8182 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8183 }
8184 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8185 if(CSR_IS_ENC_TYPE_STATIC(edType))
8186 {
8187 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008188 //It has to be static WEP here
8189 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8190 {
8191 setKeyEvent.keyId = (v_U8_t)defKeyId;
8192 }
8193 }
8194 else
8195 {
8196 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8197 }
8198 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8199 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8200 }
8201#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008202 if( csrIsSetKeyAllowed(pMac, sessionId) )
8203 {
8204 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8205 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8206 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8207 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8208 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8209 pCommand->u.setKeyCmd.keyRsc);
8210 }
8211 else
8212 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008213 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008214 //Set this status so the error handling take care of the case.
8215 status = eHAL_STATUS_CSR_WRONG_STATE;
8216 }
8217 if( !HAL_STATUS_SUCCESS(status) )
8218 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008219 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008220 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008221#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8222 if(eCSR_ENCRYPT_TYPE_NONE != edType)
8223 {
8224 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8225 {
8226 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8227 }
8228 else
8229 {
8230 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8231 }
8232 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8233 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8234 }
8235#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008237 return ( status );
8238}
8239
Jeff Johnson295189b2012-06-20 16:38:30 -07008240eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8241{
8242 eHalStatus status;
8243 tpSirSmeRemoveKeyReq pMsg = NULL;
8244 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8245 tANI_U8 *p;
8246 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008247#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8248 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8249 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008250 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8251 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8252 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8253 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8254 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8255 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8256 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8257 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8258#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008259 if( csrIsSetKeyAllowed(pMac, sessionId) )
8260 {
8261 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
8262 }
8263 else
8264 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008265 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008266 //Set the error status so error handling kicks in below
8267 status = eHAL_STATUS_CSR_WRONG_STATE;
8268 }
8269 if( HAL_STATUS_SUCCESS( status ) )
8270 {
8271 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
8272 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8273 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008274 pMsg->sessionId = (tANI_U8)sessionId;
8275 pMsg->transactionId = 0;
8276 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8277 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8278 // bssId - copy from session Info
8279 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
8280 p += sizeof(tSirMacAddr);
8281 // peerMacAddr
8282 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
8283 p += sizeof(tSirMacAddr);
8284 // edType
8285 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8286 p++;
8287 // weptype
8288 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8289 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8290 {
8291 *p = (tANI_U8)eSIR_WEP_STATIC;
8292 }
8293 else
8294 {
8295 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8296 }
8297 p++;
8298 //keyid
8299 *p = pCommand->u.removeKeyCmd.keyId;
8300 p++;
8301 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008302 status = palSendMBMessage(pMac->hHdd, pMsg);
8303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008304 if( !HAL_STATUS_SUCCESS( status ) )
8305 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008306 smsLog( pMac, LOGE, FL(" error status "), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008307#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8308 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008309 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008310 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8311#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8313 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008314 return ( status );
8315}
8316
Jeff Johnson295189b2012-06-20 16:38:30 -07008317eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8318{
8319 eHalStatus status;
8320
8321 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8322 {
8323 status = eHAL_STATUS_CSR_WRONG_STATE;
8324 }
8325 else
8326 {
8327 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8328 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008329 return ( status );
8330}
8331
Jeff Johnson295189b2012-06-20 16:38:30 -07008332/*
8333 Prepare a filter base on a profile for parsing the scan results.
8334 Upon successful return, caller MUST call csrFreeScanFilter on
8335 pScanFilter when it is done with the filter.
8336*/
8337eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8338 tCsrScanResultFilter *pScanFilter)
8339{
8340 eHalStatus status = eHAL_STATUS_SUCCESS;
8341 tANI_U32 size = 0;
8342 tANI_U8 index = 0;
8343
8344 do
8345 {
8346 if(pProfile->BSSIDs.numOfBSSIDs)
8347 {
8348 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
8349 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
8350 if(!HAL_STATUS_SUCCESS(status))
8351 {
8352 break;
8353 }
8354 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
8355 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
8356 }
8357 if(pProfile->SSIDs.numOfSSIDs)
8358 {
8359 if( !CSR_IS_WDS_STA( pProfile ) )
8360 {
8361 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8362 }
8363 else
8364 {
8365 //For WDS station
8366 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8367 pScanFilter->SSIDs.numOfSSIDs = 1;
8368 }
8369 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8370 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8371 if(!HAL_STATUS_SUCCESS(status))
8372 {
8373 break;
8374 }
8375 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8376 }
8377 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8378 {
8379 pScanFilter->ChannelInfo.numOfChannels = 0;
8380 pScanFilter->ChannelInfo.ChannelList = NULL;
8381 }
8382 else if(pProfile->ChannelInfo.numOfChannels)
8383 {
8384 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8385 pScanFilter->ChannelInfo.numOfChannels = 0;
8386 if(HAL_STATUS_SUCCESS(status))
8387 {
8388 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8389 {
8390 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8391 {
8392 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8393 = pProfile->ChannelInfo.ChannelList[index];
8394 pScanFilter->ChannelInfo.numOfChannels++;
8395 }
8396 else
8397 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008398 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008400 }
8401 }
8402 else
8403 {
8404 break;
8405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008406 }
8407 else
8408 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008409 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008410 status = eHAL_STATUS_FAILURE;
8411 break;
8412 }
8413 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8414 pScanFilter->authType = pProfile->AuthType;
8415 pScanFilter->EncryptionType = pProfile->EncryptionType;
8416 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8417 pScanFilter->BSSType = pProfile->BSSType;
8418 pScanFilter->phyMode = pProfile->phyMode;
8419#ifdef FEATURE_WLAN_WAPI
8420 //check if user asked for WAPI with 11n or auto mode, in that case modify
8421 //the phymode to 11g
8422 if(csrIsProfileWapi(pProfile))
8423 {
8424 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8425 {
8426 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8427 }
8428 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8429 {
8430 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8431 }
8432 if(!pScanFilter->phyMode)
8433 {
8434 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8435 }
8436 }
8437#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 /*Save the WPS info*/
8439 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008440 if( pProfile->countryCode[0] )
8441 {
8442 //This causes the matching function to use countryCode as one of the criteria.
8443 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8444 WNI_CFG_COUNTRY_CODE_LEN );
8445 }
8446#ifdef WLAN_FEATURE_VOWIFI_11R
8447 if (pProfile->MDID.mdiePresent)
8448 {
8449 pScanFilter->MDID.mdiePresent = 1;
8450 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8451 }
8452#endif
8453
8454 }while(0);
8455
8456 if(!HAL_STATUS_SUCCESS(status))
8457 {
8458 csrFreeScanFilter(pMac, pScanFilter);
8459 }
8460
8461 return(status);
8462}
8463
Jeff Johnson295189b2012-06-20 16:38:30 -07008464tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8465 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8466{
8467 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8468 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008469 do
8470 {
8471 // Validate the type is ok...
8472 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8473 pCommand = csrGetCommandBuffer( pMac );
8474 if ( !pCommand )
8475 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008476 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008477 break;
8478 }
8479 //Change the substate in case it is waiting for key
8480 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8481 {
8482 csrRoamStopWaitForKeyTimer( pMac );
8483 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8484 }
8485 pCommand->command = eSmeCommandWmStatusChange;
8486 pCommand->sessionId = (tANI_U8)sessionId;
8487 pCommand->u.wmStatusChangeCmd.Type = Type;
8488 if ( eCsrDisassociated == Type )
8489 {
8490 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8491 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8492 }
8493 else
8494 {
8495 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8496 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8497 }
8498 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8499 {
8500 fCommandQueued = eANI_BOOLEAN_TRUE;
8501 }
8502 else
8503 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008504 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 csrReleaseCommandWmStatusChange( pMac, pCommand );
8506 }
8507
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8509 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008510 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 return( fCommandQueued );
8512}
8513
Jeff Johnson295189b2012-06-20 16:38:30 -07008514static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8515{
8516 v_S7_t rssi = 0;
8517 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8518 if(pGetRssiReq)
8519 {
8520 if(NULL != pGetRssiReq->pVosContext)
8521 {
8522 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8523 }
8524 else
8525 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008526 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008527 return;
8528 }
8529
8530 if(NULL != pGetRssiReq->rssiCallback)
8531 {
8532 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8533 }
8534 else
8535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008536 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 return;
8538 }
8539 }
8540 else
8541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008542 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008543 }
8544 return;
8545}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008546#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8547void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8548{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008549 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8550
Jeff Johnson36d483b2013-04-08 11:08:53 -07008551 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008552 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008553 /* Get roam Rssi request is backed up and passed back to the response,
8554 Extract the request message to fetch callback */
8555 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8556 v_S7_t rssi = pRoamRssiRsp->rssi;
8557
8558 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008559 {
8560 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8561 reqBkp->rssiCallback = NULL;
8562 vos_mem_free(reqBkp);
8563 }
8564 else
8565 {
8566 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8567 if (NULL != reqBkp)
8568 {
8569 vos_mem_free(reqBkp);
8570 }
8571 }
8572 }
8573 else
8574 {
8575 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8576 }
8577 return;
8578}
8579#endif
8580
Jeff Johnsone7245742012-09-05 17:12:55 -07008581static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8582{
8583 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8584 if(pTlRssiInd)
8585 {
8586 if(NULL != pTlRssiInd->tlCallback)
8587 {
8588 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08008589 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008590 }
8591 else
8592 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008593 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008594 }
8595 }
8596 else
8597 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008598 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008599 }
8600 return;
8601}
Jeff Johnson295189b2012-06-20 16:38:30 -07008602
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05308603eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
8604{
8605 tpSirResetAPCapsChange pMsg;
8606 tANI_U16 len;
8607 eHalStatus status = eHAL_STATUS_SUCCESS;
8608
8609 /* Create the message and send to lim */
8610 len = sizeof(tSirResetAPCapsChange);
8611 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
8612 if (HAL_STATUS_SUCCESS(status))
8613 {
8614 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirResetAPCapsChange) );
8615 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
8616 pMsg->length = len;
8617 palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr) );
8618 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= %02x-%02x-%02x-%02x-%02x-%02x"),
8619 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
8620 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ]);
8621 status = palSendMBMessage(pMac->hHdd, pMsg);
8622 }
8623 else
8624 {
8625 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
8626 }
8627 return status;
8628}
8629
Jeff Johnson295189b2012-06-20 16:38:30 -07008630void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8631{
8632 tSirSmeAssocInd *pAssocInd;
8633 tSirSmeDisassocInd *pDisassocInd;
8634 tSirSmeDeauthInd *pDeauthInd;
8635 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8636 tSirSmeNewBssInfo *pNewBss;
8637 tSmeIbssPeerInd *pIbssPeerInd;
8638 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8639 tSirSmeApNewCaps *pApNewCaps;
8640 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8641 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8642 tCsrRoamInfo *pRoamInfo = NULL;
8643 tCsrRoamInfo roamInfo;
8644 eHalStatus status;
8645 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8646 tCsrRoamSession *pSession = NULL;
8647 tpSirSmeSwitchChannelInd pSwitchChnInd;
8648 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008649 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008650 pSirMsg->messageType = (pSirMsg->messageType);
8651 pSirMsg->length = (pSirMsg->length);
8652 pSirMsg->statusCode = (pSirMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008653 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008654 switch( pSirMsg->messageType )
8655 {
8656 case eWNI_SME_ASSOC_IND:
8657 {
8658 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008659 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008660 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8661 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8662 if( HAL_STATUS_SUCCESS( status ) )
8663 {
8664 pSession = CSR_GET_SESSION(pMac, sessionId);
8665
Jeff Johnson32d95a32012-09-10 13:15:23 -07008666 if(!pSession)
8667 {
8668 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8669 return;
8670 }
8671
Jeff Johnson295189b2012-06-20 16:38:30 -07008672 pRoamInfo = &roamInfo;
8673
8674 // Required for indicating the frames to upper layer
8675 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8676 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8677
8678 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8679 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8680 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8681 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8682
8683 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8684 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8685 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8686
8687 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8688 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008689 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8690 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008691 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8692 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07008693 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07008694 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8695 {
8696 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8697 {
8698 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8699 pSession->pConnectBssDesc,
8700 &(pRoamInfo->peerMac),
8701 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8702 pRoamInfo->fAuthRequired = FALSE;
8703 }
8704 else
8705 {
8706 pRoamInfo->fAuthRequired = TRUE;
8707 }
8708 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8709 if (!HAL_STATUS_SUCCESS(status))
8710 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8711 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008712 /* Send Association completion message to PE */
8713 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8714
8715 /* send a message to CSR itself just to avoid the EAPOL frames going
8716 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008717 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8718 {
8719 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8720 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008721 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8722 {
8723 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8724 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8725 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8726 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008727 }
8728 }
8729 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008730 case eWNI_SME_DISASSOC_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008731 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008732 // Check if AP dis-associated us because of MIC failure. If so,
8733 // then we need to take action immediately and not wait till the
8734 // the WmStatusChange requests is pushed and processed
8735 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8736 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8737 if( HAL_STATUS_SUCCESS( status ) )
8738 {
8739 // If we are in neighbor preauth done state then on receiving
8740 // disassoc or deauth we dont roam instead we just disassoc
8741 // from current ap and then go to disconnected state
8742 // This happens for CCX and 11r FT connections ONLY.
8743#ifdef WLAN_FEATURE_VOWIFI_11R
8744 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8745 {
8746 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8747 }
8748#endif
8749#ifdef FEATURE_WLAN_CCX
8750 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8751 {
8752 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8753 }
8754#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008755#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308756 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008757 {
8758 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8759 }
8760#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008761 pSession = CSR_GET_SESSION( pMac, sessionId );
8762
Jeff Johnson32d95a32012-09-10 13:15:23 -07008763 if(!pSession)
8764 {
8765 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8766 return;
8767 }
8768
Jeff Johnson295189b2012-06-20 16:38:30 -07008769 if ( csrIsConnStateInfra( pMac, sessionId ) )
8770 {
8771 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8772 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008773#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8774 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8775#endif
8776 csrRoamLinkDown(pMac, sessionId);
8777 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008778 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8779 {
8780
8781 pRoamInfo = &roamInfo;
8782
8783 pRoamInfo->statusCode = pDisassocInd->statusCode;
8784 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8785
8786 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8787
8788 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8789 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8790
8791 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008792
8793 /*
8794 * STA/P2P client got disassociated so remove any pending deauth
8795 * commands in sme pending list
8796 */
8797 pCommand.command = eSmeCommandRoam;
8798 pCommand.sessionId = (tANI_U8)sessionId;
8799 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8800 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8801 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008803 }
8804 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008805 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008806 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008807 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8808 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8809 if( HAL_STATUS_SUCCESS( status ) )
8810 {
8811 // If we are in neighbor preauth done state then on receiving
8812 // disassoc or deauth we dont roam instead we just disassoc
8813 // from current ap and then go to disconnected state
8814 // This happens for CCX and 11r FT connections ONLY.
8815#ifdef WLAN_FEATURE_VOWIFI_11R
8816 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8817 {
8818 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8819 }
8820#endif
8821#ifdef FEATURE_WLAN_CCX
8822 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8823 {
8824 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8825 }
8826#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008827#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308828 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008829 {
8830 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8831 }
8832#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008833 pSession = CSR_GET_SESSION( pMac, sessionId );
8834
Jeff Johnson32d95a32012-09-10 13:15:23 -07008835 if(!pSession)
8836 {
8837 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8838 return;
8839 }
8840
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 if ( csrIsConnStateInfra( pMac, sessionId ) )
8842 {
8843 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008845#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8846 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8847#endif
8848 csrRoamLinkDown(pMac, sessionId);
8849 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008850 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8851 {
8852
8853 pRoamInfo = &roamInfo;
8854
8855 pRoamInfo->statusCode = pDeauthInd->statusCode;
8856 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8857
8858 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8859
8860 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8861 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8862
8863 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8864 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008865 }
8866 break;
8867
8868 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 -08008869 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008870 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8871 //Update with the new channel id.
8872 //The channel id is hidden in the statusCode.
8873 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8874 if( HAL_STATUS_SUCCESS( status ) )
8875 {
8876 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008877 if(!pSession)
8878 {
8879 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8880 return;
8881 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008882 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8883 if(pSession->pConnectBssDesc)
8884 {
8885 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8886 }
8887 }
8888 break;
8889
8890 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008891 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008892 {
8893 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8894 sessionId = pDeauthRsp->sessionId;
8895 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8896 {
8897 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008898 if(!pSession)
8899 {
8900 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8901 return;
8902 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008903 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8904 {
8905 pRoamInfo = &roamInfo;
8906 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8907 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8908 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8909 pRoamInfo->statusCode = pDeauthRsp->statusCode;
8910 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8911 }
8912 }
8913 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008914 break;
8915
8916 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07008917 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008918 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 {
8920 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8921 sessionId = pDisassocRsp->sessionId;
8922 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8923 {
8924 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008925 if(!pSession)
8926 {
8927 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8928 return;
8929 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8931 {
8932 pRoamInfo = &roamInfo;
8933 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8934 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
8935 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8936 pRoamInfo->statusCode = pDisassocRsp->statusCode;
8937 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8938 }
8939 }
8940 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008941 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008942 case eWNI_SME_MIC_FAILURE_IND:
8943 {
8944 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
8945 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8946 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Jeff Johnson295189b2012-06-20 16:38:30 -07008947#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8948 {
8949 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008950 if(!pSession)
8951 {
8952 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8953 return;
8954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008955 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
8956 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
8957 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
8958 secEvent.encryptionModeMulticast =
8959 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8960 secEvent.encryptionModeUnicast =
8961 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8962 secEvent.authMode =
8963 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8964 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
8965 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
8966 }
8967#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008968 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
8969 if( HAL_STATUS_SUCCESS( status ) )
8970 {
8971 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8972 roamInfo.u.pMICFailureInfo = &pMicInd->info;
8973 pRoamInfo = &roamInfo;
8974 if(pMicInd->info.multicast)
8975 {
8976 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
8977 }
8978 else
8979 {
8980 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
8981 }
8982 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
8983 }
8984 }
8985 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008986 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
8987 {
8988 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
8989 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008990 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008991
8992 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
8993 if( HAL_STATUS_SUCCESS( status ) )
8994 {
8995 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8996 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
8997 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
8998 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
8999 }
9000 }
9001 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009002
Jeff Johnson295189b2012-06-20 16:38:30 -07009003 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9004 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9005 switch( pStatusChangeMsg->statusChangeCode )
9006 {
9007 case eSIR_SME_IBSS_ACTIVE:
9008 sessionId = csrFindIbssSession( pMac );
9009 if( CSR_SESSION_ID_INVALID != sessionId )
9010 {
9011 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009012 if(!pSession)
9013 {
9014 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9015 return;
9016 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009017 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9018 if(pSession->pConnectBssDesc)
9019 {
9020 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9021 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9022 pRoamInfo = &roamInfo;
9023 }
9024 else
9025 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009026 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009027 }
9028 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9029 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9030 }
9031 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009032 case eSIR_SME_IBSS_INACTIVE:
9033 sessionId = csrFindIbssSession( pMac );
9034 if( CSR_SESSION_ID_INVALID != sessionId )
9035 {
9036 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009037 if(!pSession)
9038 {
9039 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9040 return;
9041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009042 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9043 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9044 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9045 }
9046 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009047 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9048 sessionId = csrFindIbssSession( pMac );
9049 if( CSR_SESSION_ID_INVALID != sessionId )
9050 {
9051 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009052 if(!pSession)
9053 {
9054 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9055 return;
9056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009057 // update the connection state information
9058 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009059#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9060 {
9061 vos_log_ibss_pkt_type *pIbssLog;
9062 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009063 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9064 if(pIbssLog)
9065 {
9066 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9067 if(pNewBss)
9068 {
9069 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
9070 if(pNewBss->ssId.length)
9071 {
9072 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
9073 }
9074 pIbssLog->operatingChannel = pNewBss->channelNumber;
9075 }
9076 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9077 {
9078 //***U8 is not enough for beacon interval
9079 pIbssLog->beaconInterval = (v_U8_t)bi;
9080 }
9081 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9082 }
9083 }
9084#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009085 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009086
9087 if ((eCSR_ENCRYPT_TYPE_NONE ==
9088 pSession->connectedProfile.EncryptionType ))
9089 {
9090 csrRoamIssueSetContextReq( pMac, sessionId,
9091 pSession->connectedProfile.EncryptionType,
9092 pSession->pConnectBssDesc,
9093 &Broadcastaddr,
9094 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9095 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009096 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9097 roamStatus = eCSR_ROAM_IBSS_IND;
9098 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
9099 pRoamInfo = &roamInfo;
9100 //This BSSID is th ereal BSSID, let's save it
9101 if(pSession->pConnectBssDesc)
9102 {
9103 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
9104 }
9105 // Stop the join IBSS timer in case of join, for
9106 // genuine merge do nothing
9107 if(pSession->ibss_join_pending)
9108 {
9109 pSession->ibss_join_pending = FALSE;
9110 csrRoamStopIbssJoinTimer(pMac, sessionId);
9111 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
9112 }
9113 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009114 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009115 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009116 // detection by LIM that the capabilities of the associated AP have changed.
9117 case eSIR_SME_AP_CAPS_CHANGED:
9118 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009119 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009120 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9121 if( HAL_STATUS_SUCCESS( status ) )
9122 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009123 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9124 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309125 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009126 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9127 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9128 )
9129 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309130 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9131 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009132 }
9133 else
9134 {
9135 smsLog(pMac, LOGW,
9136 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009137 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009138 pMac->roam.curState[sessionId],
9139 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309140 /* We ignore the caps change event if CSR is not in full connected state.
9141 * Send one event to PE to reset limSentCapsChangeNtf
9142 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9143 * otherwise lim cannot send any CAPS change events to SME */
9144 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009146 }
9147 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309148
Jeff Johnson295189b2012-06-20 16:38:30 -07009149 default:
9150 roamStatus = eCSR_ROAM_FAILED;
9151 result = eCSR_ROAM_RESULT_NONE;
9152 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009153 } // end switch on statusChangeCode
9154 if(eCSR_ROAM_RESULT_NONE != result)
9155 {
9156 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9157 }
9158 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009159 case eWNI_SME_IBSS_NEW_PEER_IND:
9160 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009161#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9162 {
9163 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009164 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9165 if(pIbssLog)
9166 {
9167 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
9168 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9169 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9170 }
9171 }
9172#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009173 sessionId = csrFindIbssSession( pMac );
9174 if( CSR_SESSION_ID_INVALID != sessionId )
9175 {
9176 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009177
9178 if(!pSession)
9179 {
9180 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9181 return;
9182 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009183 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9184 if(pSession->pConnectBssDesc)
9185 {
9186 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9187 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9188 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9189 {
9190 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
9191 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
9192 if(HAL_STATUS_SUCCESS(status))
9193 {
9194 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
9195 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9196 roamInfo.nBeaconLength);
9197 }
9198 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9199 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9200 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9201 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
9202 pSession->pConnectBssDesc->length);
9203 if(HAL_STATUS_SUCCESS(status))
9204 {
9205 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
9206 pSession->pConnectBssDesc->length);
9207 }
9208 if(HAL_STATUS_SUCCESS(status))
9209 {
9210 pRoamInfo = &roamInfo;
9211 }
9212 else
9213 {
9214 if(roamInfo.pbFrames)
9215 {
9216 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9217 }
9218 if(roamInfo.pBssDesc)
9219 {
9220 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9221 }
9222 }
9223 }
9224 else
9225 {
9226 pRoamInfo = &roamInfo;
9227 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009228 if ((eCSR_ENCRYPT_TYPE_NONE ==
9229 pSession->connectedProfile.EncryptionType ))
9230 {
9231 csrRoamIssueSetContextReq( pMac, sessionId,
9232 pSession->connectedProfile.EncryptionType,
9233 pSession->pConnectBssDesc,
9234 &(pIbssPeerInd->peerAddr),
9235 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009237 }
9238 else
9239 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009240 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009241 }
9242 //send up the sec type for the new peer
9243 if (pRoamInfo)
9244 {
9245 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9246 }
9247 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9248 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9249 if(pRoamInfo)
9250 {
9251 if(roamInfo.pbFrames)
9252 {
9253 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9254 }
9255 if(roamInfo.pBssDesc)
9256 {
9257 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9258 }
9259 }
9260 }
9261 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009262 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9263 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9264 sessionId = csrFindIbssSession( pMac );
9265 if( CSR_SESSION_ID_INVALID != sessionId )
9266 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009267#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9268 {
9269 vos_log_ibss_pkt_type *pIbssLog;
9270
9271 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9272 if(pIbssLog)
9273 {
9274 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9275 if(pIbssPeerInd)
9276 {
9277 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9278 }
9279 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9280 }
9281 }
9282#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009283 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009284 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9285 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9286 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9287 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9288 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9289 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9290 }
9291 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009292 case eWNI_SME_SETCONTEXT_RSP:
9293 {
9294 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9295 tListElem *pEntry;
9296 tSmeCmd *pCommand;
9297
9298 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9299 if ( pEntry )
9300 {
9301 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9302 if ( eSmeCommandSetKey == pCommand->command )
9303 {
9304 sessionId = pCommand->sessionId;
9305 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009306
9307 if(!pSession)
9308 {
9309 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9310 return;
9311 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009312
9313#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9314 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9315 {
9316 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
9317 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9318 if( pRsp->peerMacAddr[0] & 0x01 )
9319 {
9320 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9321 }
9322 else
9323 {
9324 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9325 }
9326 setKeyEvent.encryptionModeMulticast =
9327 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9328 setKeyEvent.encryptionModeUnicast =
9329 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9330 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9331 setKeyEvent.authMode =
9332 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9333 if( eSIR_SUCCESS != pRsp->statusCode )
9334 {
9335 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9336 }
9337 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9338 }
9339#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9340 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9341 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009342 csrRoamStopWaitForKeyTimer( pMac );
9343
Jeff Johnson295189b2012-06-20 16:38:30 -07009344 //We are done with authentication, whethere succeed or not
9345 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009346 //We do it here because this linkup function is not called after association
9347 //when a key needs to be set.
9348 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9349 {
9350 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9351 }
9352 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009353 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 {
9355 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07009356 //Make sure we install the GTK before indicating to HDD as authenticated
9357 //This is to prevent broadcast packets go out after PTK and before GTK.
9358 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
9359 sizeof(tSirMacAddr) ) )
9360 {
Yathish9f22e662012-12-10 14:21:35 -08009361#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9362 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9363 {
9364 tpSirSetActiveModeSetBncFilterReq pMsg;
9365 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
9366 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9367 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9368 pMsg->seesionId = sessionId;
9369 status = palSendMBMessage(pMac->hHdd, pMsg );
9370 }
9371#endif
9372 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009373 }
9374 else
9375 {
9376 result = eCSR_ROAM_RESULT_NONE;
9377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009378 pRoamInfo = &roamInfo;
9379 }
9380 else
9381 {
9382 result = eCSR_ROAM_RESULT_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009383 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...",
Jeff Johnson295189b2012-06-20 16:38:30 -07009384 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9385 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9386 }
9387 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9388 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009389 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9390 // can go ahead and initiate the TSPEC if any are pending
9391 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009392#ifdef FEATURE_WLAN_CCX
9393 //Send Adjacent AP repot to new AP.
9394 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9395 pSession->isPrevApInfoValid &&
9396 pSession->connectedProfile.isCCXAssoc)
9397 {
9398#ifdef WLAN_FEATURE_VOWIFI
9399 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9400#endif
9401 pSession->isPrevApInfoValid = FALSE;
9402 }
9403#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009404 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9405 {
9406 csrReleaseCommandSetKey( pMac, pCommand );
9407 }
9408 }
9409 else
9410 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009411 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009412 }
9413 }
9414 else
9415 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009416 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009418 smeProcessPendingQueue( pMac );
9419 }
9420 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009421 case eWNI_SME_REMOVEKEY_RSP:
9422 {
9423 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9424 tListElem *pEntry;
9425 tSmeCmd *pCommand;
9426
9427 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9428 if ( pEntry )
9429 {
9430 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9431 if ( eSmeCommandRemoveKey == pCommand->command )
9432 {
9433 sessionId = pCommand->sessionId;
9434 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009435
9436 if(!pSession)
9437 {
9438 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9439 return;
9440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009441#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9442 {
9443 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9444 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9445 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9446 removeKeyEvent.encryptionModeMulticast =
9447 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9448 removeKeyEvent.encryptionModeUnicast =
9449 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9450 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9451 removeKeyEvent.authMode =
9452 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9453 if( eSIR_SUCCESS != pRsp->statusCode )
9454 {
9455 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9456 }
9457 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9458 }
9459#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009460 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009461 {
9462 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9463 result = eCSR_ROAM_RESULT_NONE;
9464 pRoamInfo = &roamInfo;
9465 }
9466 else
9467 {
9468 result = eCSR_ROAM_RESULT_FAILURE;
9469 }
9470 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9471 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9472 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9473 {
9474 csrReleaseCommandRemoveKey( pMac, pCommand );
9475 }
9476 }
9477 else
9478 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009479 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009480 }
9481 }
9482 else
9483 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009484 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009486 smeProcessPendingQueue( pMac );
9487 }
9488 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009489 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009490 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009491 csrRoamStatsRspProcessor( pMac, pSirMsg );
9492 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009493#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9494 case eWNI_SME_GET_ROAM_RSSI_RSP:
9495 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9496 csrRoamRssiRspProcessor( pMac, pSirMsg );
9497 break;
9498#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009499 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009500 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009501 csrUpdateRssi( pMac, pSirMsg );
9502 break;
9503
Jeff Johnson295189b2012-06-20 16:38:30 -07009504#ifdef WLAN_FEATURE_VOWIFI_11R
9505 case eWNI_SME_FT_PRE_AUTH_RSP:
9506 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9507 break;
9508#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009509 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9510 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009511 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 -07009512 sessionId = pSmeMaxAssocInd->sessionId;
9513 roamInfo.sessionId = sessionId;
9514 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9515 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9516 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9517 break;
9518
9519 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009520 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009521 btampEstablishLogLinkHdlr( pSirMsg );
9522 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009523 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009524 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009525 csrRoamRssiIndHdlr( pMac, pSirMsg );
9526 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009527#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9528 case eWNI_SME_CANDIDATE_FOUND_IND:
9529 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
9530 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
9531 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07009532 case eWNI_SME_HANDOFF_REQ:
9533 smsLog( pMac, LOG2, FL("Handoff Req from self"));
9534 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
9535 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009536#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009537
9538 default:
9539 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009540 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009541}
9542
Jeff Johnson295189b2012-06-20 16:38:30 -07009543void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9544 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9545{
9546 if(pSession)
9547 {
9548 if(pSession->bRefAssocStartCnt)
9549 {
9550 pSession->bRefAssocStartCnt--;
9551 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9552 //Need to call association_completion because there is an assoc_start pending.
9553 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9554 eCSR_ROAM_ASSOCIATION_COMPLETION,
9555 eCSR_ROAM_RESULT_FAILURE);
9556 }
9557 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9558 }
9559 else
9560 {
9561 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9562 }
9563}
9564
9565
9566eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9567{
9568 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009569 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9570 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9571 {
9572 status = csrScanRequestLostLink1( pMac, sessionId );
9573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009574 return(status);
9575}
9576
Jeff Johnson295189b2012-06-20 16:38:30 -07009577//return a boolean to indicate whether roaming completed or continue.
9578tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9579 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9580{
9581 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9582 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9583 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9584 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009585 if(!pSession)
9586 {
9587 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9588 return eANI_BOOLEAN_FALSE;
9589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009590 //Check whether time is up
9591 if(pSession->fCancelRoaming || fForce ||
9592 ((curTime - pSession->roamingStartTime) > roamTime) ||
9593 eCsrReassocRoaming == pSession->roamingReason ||
9594 eCsrDynamicRoaming == pSession->roamingReason)
9595 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009596 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9598 {
9599 //roaming is cancelled, tell HDD to indicate disconnect
9600 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9601 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9602 //to be eSIR_BEACON_MISSED
9603 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9604 {
9605 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9606 }
9607 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9608 {
9609 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9610 }
9611 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9612 {
9613 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9614 }
9615 else
9616 {
9617 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9618 }
9619 }
9620 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9621 pSession->roamingReason = eCsrNotRoaming;
9622 }
9623 else
9624 {
9625 pSession->roamResult = roamResult;
9626 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9627 {
9628 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9629 pSession->roamingReason = eCsrNotRoaming;
9630 }
9631 else
9632 {
9633 fCompleted = eANI_BOOLEAN_FALSE;
9634 }
9635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 return(fCompleted);
9637}
9638
Jeff Johnson295189b2012-06-20 16:38:30 -07009639void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9640{
9641 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009642
9643 if(!pSession)
9644 {
9645 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9646 return;
9647 }
9648
Jeff Johnson295189b2012-06-20 16:38:30 -07009649 if(CSR_IS_ROAMING(pSession))
9650 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009651 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -07009652 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9653 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9654 {
9655 //No need to do anything in here because the handler takes care of it
9656 }
9657 else
9658 {
9659 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9660 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9661 //Roaming is stopped after here
9662 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9663 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
9664 csrScanAbortMacScan(pMac);
9665 csrRoamStopRoamingTimer(pMac, sessionId);
9666 }
9667 }
9668}
9669
Jeff Johnson295189b2012-06-20 16:38:30 -07009670void csrRoamRoamingTimerHandler(void *pv)
9671{
9672 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9673 tpAniSirGlobal pMac = pInfo->pMac;
9674 tANI_U32 sessionId = pInfo->sessionId;
9675 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009676
9677 if(!pSession)
9678 {
9679 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9680 return;
9681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009682
9683 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9684 {
9685 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9686 {
9687 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9688 pSession->roamingReason = eCsrNotRoaming;
9689 }
9690 }
9691}
9692
Jeff Johnson295189b2012-06-20 16:38:30 -07009693eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9694{
9695 eHalStatus status;
9696 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009697
9698 if(!pSession)
9699 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009700 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009701 return eHAL_STATUS_FAILURE;
9702 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009703
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009704 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009705 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
9706 status = palTimerStart(pMac->hHdd, pSession->hTimerRoaming, interval, eANI_BOOLEAN_FALSE);
9707
9708 return (status);
9709}
9710
Jeff Johnson295189b2012-06-20 16:38:30 -07009711eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9712{
9713 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerRoaming));
9714}
9715
Jeff Johnson295189b2012-06-20 16:38:30 -07009716void csrRoamWaitForKeyTimeOutHandler(void *pv)
9717{
9718 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9719 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009720 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9721
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009722 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009723 pMac->roam.neighborRoamInfo.neighborRoamState,
9724 pMac->roam.curSubState[pInfo->sessionId]);
9725
Jeff Johnson295189b2012-06-20 16:38:30 -07009726 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9727 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009728#ifdef FEATURE_WLAN_LFR
9729 if (csrNeighborRoamIsHandoffInProgress(pMac))
9730 {
9731 /*
9732 * Enable heartbeat timer when hand-off is in progress
9733 * and Key Wait timer expired.
9734 */
9735 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009736 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009737 pMac->roam.configParam.HeartbeatThresh24);
9738 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9739 pMac->roam.configParam.HeartbeatThresh24,
9740 NULL, eANI_BOOLEAN_FALSE);
9741 }
9742#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009743 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Jeff Johnson295189b2012-06-20 16:38:30 -07009744 //Change the substate so command queue is unblocked.
9745 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009746 if (pSession)
9747 {
9748 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9749 {
9750 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9751 smeProcessPendingQueue(pMac);
9752 }
9753 else
9754 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009755 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009756 __func__);
9757 }
9758 }
9759 else
9760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009761 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009763 }
9764
9765}
9766
Jeff Johnson295189b2012-06-20 16:38:30 -07009767eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9768{
9769 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009770#ifdef FEATURE_WLAN_LFR
9771 if (csrNeighborRoamIsHandoffInProgress(pMac))
9772 {
9773 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009774 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009775 __func__,
9776 pMac->roam.neighborRoamInfo.neighborRoamState,
9777 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9778 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9779 }
9780#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009781 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009782 status = palTimerStart(pMac->hHdd, pMac->roam.hTimerWaitForKey, interval, eANI_BOOLEAN_FALSE);
9783
9784 return (status);
9785}
9786
Jeff Johnson295189b2012-06-20 16:38:30 -07009787eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9788{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009789 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009790 pMac->roam.neighborRoamInfo.neighborRoamState,
9791 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9792#ifdef FEATURE_WLAN_LFR
9793 if (csrNeighborRoamIsHandoffInProgress(pMac))
9794 {
9795 /*
9796 * Enable heartbeat timer when hand-off is in progress
9797 * and Key Wait timer got stopped for some reason
9798 */
9799 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009800 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009801 pMac->roam.configParam.HeartbeatThresh24);
9802 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9803 pMac->roam.configParam.HeartbeatThresh24,
9804 NULL, eANI_BOOLEAN_FALSE);
9805 }
9806#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009807 return (palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey));
9808}
9809
Jeff Johnson295189b2012-06-20 16:38:30 -07009810void csrRoamIbssJoinTimerHandler(void *pv)
9811{
9812 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9813 tpAniSirGlobal pMac = pInfo->pMac;
9814 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9815 tANI_U32 sessionId = pInfo->sessionId;
9816 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009817
9818 if(!pSession)
9819 {
9820 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9821 return;
9822 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009823
9824 pSession->ibss_join_pending = FALSE;
9825 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9826 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9827 // Send an IBSS stop request to PE
9828 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009829}
Jeff Johnson295189b2012-06-20 16:38:30 -07009830eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9831{
9832 eHalStatus status;
9833 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009834
9835 if(!pSession)
9836 {
9837 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9838 return eHAL_STATUS_FAILURE;
9839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009840
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009841 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009842 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
9843 status = palTimerStart(pMac->hHdd, pSession->hTimerIbssJoining, interval, eANI_BOOLEAN_FALSE);
9844
9845 return (status);
9846}
Jeff Johnson295189b2012-06-20 16:38:30 -07009847eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9848{
9849 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerIbssJoining));
9850}
Jeff Johnson295189b2012-06-20 16:38:30 -07009851void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9852 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9853{
9854 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9855 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009856 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9857 /* To silence the KW tool Null chaeck is added */
9858 if(!pSession)
9859 {
9860 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9861 return;
9862 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009863
9864 if(pCommand)
9865 {
9866 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009867 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009868 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009869 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9870 {
9871 //if success, force roaming completion
9872 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9873 }
9874 else
9875 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009876 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009877 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07009878 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9879 }
9880}
9881
Jeff Johnson295189b2012-06-20 16:38:30 -07009882eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9883{
9884 eHalStatus status = eHAL_STATUS_SUCCESS;
9885 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9886 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9887 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9888 tCsrRoamInfo *pRoamInfo = NULL;
9889 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009890 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07009891 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009892 /* To silence the KW tool Null chaeck is added */
9893 if(!pSession)
9894 {
9895 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9896 return eHAL_STATUS_FAILURE;
9897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009898 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009899 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07009900 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9901 if ( eWNI_SME_DISASSOC_IND == type )
9902 {
9903 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9904 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9905 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009906 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009907 }
9908 else if ( eWNI_SME_DEAUTH_IND == type )
9909 {
9910 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9911 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9912 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -08009913 /* Convert into proper reason code */
9914 pSession->joinFailStatusCode.reasonCode =
9915 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +05309916 0 : pDeauthIndMsg->reasonCode;
9917 /* cfg layer expects 0 as reason code if
9918 the driver dosent know the reason code
9919 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -07009920 }
9921 else
9922 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009923 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009924 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009925 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009926 }
9927
9928 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -07009929 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009930 {
9931 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
9932 }
9933
9934 if ( eWNI_SME_DISASSOC_IND == type )
9935 {
9936 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
9937 }
9938 else if ( eWNI_SME_DEAUTH_IND == type )
9939 {
9940 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
9941 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009942 if(!HAL_STATUS_SUCCESS(status))
9943 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009944 //If fail to send confirmation to PE, not to trigger roaming
9945 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009946 }
9947
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009948 //prepare to tell HDD to disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -07009949 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9950 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9951 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009952 if( eWNI_SME_DISASSOC_IND == type)
9953 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009954 //staMacAddr
9955 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9956 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9957 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009958 else if( eWNI_SME_DEAUTH_IND == type )
9959 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009960 //staMacAddr
9961 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9962 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9963 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009964 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009965
9966 /* See if we can possibly roam. If so, start the roaming process and notify HDD
9967 that we are roaming. But if we cannot possibly roam, or if we are unable to
9968 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -07009969 if(fToRoam)
9970 {
9971 //Only remove the connected BSS in infrastructure mode
9972 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9973 //Not to do anying for lostlink with WDS
9974 if( pMac->roam.configParam.nRoamingTime )
9975 {
9976 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
9977 ( eWNI_SME_DEAUTH_IND == type ) ?
9978 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
9979 {
9980 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9981 //For IBSS, we need to give some more info to HDD
9982 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
9983 {
9984 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9985 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9986 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
9987 }
9988 else
9989 {
9990 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
9991 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009992 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009993 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
9994 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
9995 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9996 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
9997 }
9998 else
9999 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010000 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010001 fToRoam = eANI_BOOLEAN_FALSE;
10002 }
10003 }
10004 else
10005 {
10006 //We are told not to roam, indicate lostlink
10007 fToRoam = eANI_BOOLEAN_FALSE;
10008 }
10009 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010010 if(!fToRoam)
10011 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010012 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010013 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010014 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010015 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10016 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10017 * csrRoamCheckForLinkStatusChange API.
10018 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010019 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10020 }
10021
10022 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010023 Still enable idle scan for polling in case concurrent sessions are running */
10024 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10025 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010026 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010027 }
10028 }
10029
10030 return (status);
10031}
10032
Jeff Johnson295189b2012-06-20 16:38:30 -070010033eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10034{
10035 eHalStatus status = eHAL_STATUS_SUCCESS;
10036 tListElem *pEntry = NULL;
10037 tSmeCmd *pCommand = NULL;
10038 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010039
10040 if(!pSession)
10041 {
10042 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10043 return eHAL_STATUS_FAILURE;
10044 }
10045
Jeff Johnson295189b2012-06-20 16:38:30 -070010046 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010047 //Only remove the connected BSS in infrastructure mode
10048 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10049 if(pMac->roam.configParam.nRoamingTime)
10050 {
10051 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10052 {
10053 //before starting the lost link logic release the roam command for handoff
10054 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10055 if(pEntry)
10056 {
10057 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10058 }
10059 if(pCommand)
10060 {
10061 if (( eSmeCommandRoam == pCommand->command ) &&
10062 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10063 {
10064 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10065 {
10066 csrReleaseCommandRoam( pMac, pCommand );
10067 }
10068 }
10069 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010070 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010071 }
10072 }
10073 else
10074 {
10075 //We are told not to roam, indicate lostlink
10076 status = eHAL_STATUS_FAILURE;
10077 }
10078
10079 return (status);
10080}
Jeff Johnson295189b2012-06-20 16:38:30 -070010081void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10082{
10083 tListElem *pEntry;
10084 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010085 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10086 if ( pEntry )
10087 {
10088 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10089 if ( eSmeCommandWmStatusChange == pCommand->command )
10090 {
10091 // Nothing to process in a Lost Link completion.... It just kicks off a
10092 // roaming sequence.
10093 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10094 {
10095 csrReleaseCommandWmStatusChange( pMac, pCommand );
10096 }
10097 else
10098 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010099 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010100 }
10101
10102 }
10103 else
10104 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010105 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010106 }
10107 }
10108 else
10109 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010110 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010111 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010112 smeProcessPendingQueue( pMac );
10113}
10114
Jeff Johnson295189b2012-06-20 16:38:30 -070010115void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10116{
10117 eHalStatus status = eHAL_STATUS_FAILURE;
10118 tSirSmeRsp *pSirSmeMsg;
10119 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010120
10121 if(!pSession)
10122 {
10123 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10124 return;
10125 }
10126
Jeff Johnson295189b2012-06-20 16:38:30 -070010127 switch ( pCommand->u.wmStatusChangeCmd.Type )
10128 {
10129 case eCsrDisassociated:
10130 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10131 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10132 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010133 case eCsrDeauthenticated:
10134 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10135 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10136 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010137 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010138 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010139 break;
10140 }
10141 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10142 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10143 {
10144 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10145 {
10146 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010147 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010148 }
10149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010150 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10151 // command here since there is nothing else to do.
10152 csrRoamWmStatusChangeComplete( pMac );
10153}
10154
Jeff Johnson295189b2012-06-20 16:38:30 -070010155//This function returns band and mode information.
10156//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10157//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010158static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10159 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010160{
Jeff Johnson295189b2012-06-20 16:38:30 -070010161 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10162 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10163 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010164 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010165
Jeff Johnson295189b2012-06-20 16:38:30 -070010166 //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 -070010167 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10168 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10169 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10170 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010171 {
10172 switch( pMac->roam.configParam.uCfgDot11Mode )
10173 {
10174 case eCSR_CFG_DOT11_MODE_11A:
10175 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10176 eBand = eCSR_BAND_5G;
10177 break;
10178 case eCSR_CFG_DOT11_MODE_11B:
10179 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10180 eBand = eCSR_BAND_24;
10181 break;
10182 case eCSR_CFG_DOT11_MODE_11G:
10183 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10184 eBand = eCSR_BAND_24;
10185 break;
10186 case eCSR_CFG_DOT11_MODE_11N:
10187 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010188 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10189 break;
10190#ifdef WLAN_FEATURE_11AC
10191 case eCSR_CFG_DOT11_MODE_11AC:
10192 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10193 {
10194 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10195 eBand = eCSR_BAND_5G;
10196 }
10197 else
10198 {
10199 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10200 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10201 }
10202 break;
10203 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10204 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10205 {
10206 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10207 eBand = eCSR_BAND_5G;
10208 }
10209 else
10210 {
10211 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10212 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10213 }
10214 break;
10215#endif
10216 case eCSR_CFG_DOT11_MODE_AUTO:
10217 eBand = pMac->roam.configParam.eBand;
10218 if (eCSR_BAND_24 == eBand)
10219 {
10220 // WiFi tests require IBSS networks to start in 11b mode
10221 // without any change to the default parameter settings
10222 // on the adapter. We use ACU to start an IBSS through
10223 // creation of a startIBSS profile. This startIBSS profile
10224 // has Auto MACProtocol and the adapter property setting
10225 // for dot11Mode is also AUTO. So in this case, let's
10226 // start the IBSS network in 11b mode instead of 11g mode.
10227 // So this is for Auto=profile->MacProtocol && Auto=Global.
10228 // dot11Mode && profile->channel is < 14, then start the IBSS
10229 // in b mode.
10230 //
10231 // Note: we used to have this start as an 11g IBSS for best
10232 // performance... now to specify that the user will have to
10233 // set the do11Mode in the property page to 11g to force it.
10234 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10235 }
10236 else
10237 {
10238#ifdef WLAN_FEATURE_11AC
10239 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10240 {
10241 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10242 eBand = eCSR_BAND_5G;
10243 }
10244 else
10245 {
10246 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10247 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10248 }
10249#else
10250 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10251 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10252#endif
10253 }
10254 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010255 default:
10256 // Global dot11 Mode setting is 11a/b/g.
10257 // use the channel number to determine the Mode setting.
10258 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10259 {
10260 eBand = pMac->roam.configParam.eBand;
10261 if(eCSR_BAND_24 == eBand)
10262 {
10263 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10264 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10265 }
10266 else
10267 {
10268 //prefer 5GHz
10269 eBand = eCSR_BAND_5G;
10270 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10271 }
10272 }
10273 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10274 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010275 // WiFi tests require IBSS networks to start in 11b mode
10276 // without any change to the default parameter settings
10277 // on the adapter. We use ACU to start an IBSS through
10278 // creation of a startIBSS profile. This startIBSS profile
10279 // has Auto MACProtocol and the adapter property setting
10280 // for dot11Mode is also AUTO. So in this case, let's
10281 // start the IBSS network in 11b mode instead of 11g mode.
10282 // So this is for Auto=profile->MacProtocol && Auto=Global.
10283 // dot11Mode && profile->channel is < 14, then start the IBSS
10284 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010285 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010286 // Note: we used to have this start as an 11g IBSS for best
10287 // performance... now to specify that the user will have to
10288 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010289 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10290 eBand = eCSR_BAND_24;
10291 }
10292 else
10293 {
10294 // else, it's a 5.0GHz channel. Set mode to 11a.
10295 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10296 eBand = eCSR_BAND_5G;
10297 }
10298 break;
10299 }//switch
10300 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10301 else
10302 {
10303 //dot11 mode is set, lets pick the band
10304 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10305 {
10306 // channel is Auto also.
10307 eBand = pMac->roam.configParam.eBand;
10308 if(eCSR_BAND_ALL == eBand)
10309 {
10310 //prefer 5GHz
10311 eBand = eCSR_BAND_5G;
10312 }
10313 }
10314 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10315 {
10316 eBand = eCSR_BAND_24;
10317 }
10318 else
10319 {
10320 eBand = eCSR_BAND_5G;
10321 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010322 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010323 if(pBand)
10324 {
10325 *pBand = eBand;
10326 }
10327
10328 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010329 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010330 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10331 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010332
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010333 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10334 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 -070010335 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010336#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010337 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010338#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010339 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10340 {
10341 //We cannot do 11n here
10342 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10343 {
10344 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10345 }
10346 else
10347 {
10348 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10349 }
10350 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010351 return( cfgDot11Mode );
10352}
10353
Jeff Johnson295189b2012-06-20 16:38:30 -070010354eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10355{
10356 eHalStatus status;
10357 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010358
10359 if(!pSession)
10360 {
10361 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10362 return eHAL_STATUS_FAILURE;
10363 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010364
10365#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10366 {
10367 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010368 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10369 if(pIbssLog)
10370 {
10371 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10372 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10373 }
10374 }
10375#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010376 pSession->ibss_join_pending = FALSE;
10377 csrRoamStopIbssJoinTimer(pMac, sessionId );
10378 // Set the roaming substate to 'stop Bss request'...
10379 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10380
10381 // attempt to stop the Bss (reason code is ignored...)
10382 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010383 if(!HAL_STATUS_SUCCESS(status))
10384 {
10385 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10386 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010387 return (status);
10388}
10389
Jeff Johnson295189b2012-06-20 16:38:30 -070010390//pNumChan is a caller allocated space with the sizeof pChannels
10391eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10392{
10393
10394 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10395 (tANI_U8 *)pChannels,
10396 pNumChan));
10397}
10398
Kiran4a17ebe2013-01-31 10:43:43 -080010399tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10400{
10401 tANI_U32 cfgLength = 0;
10402 tANI_U16 cfgId = 0;
10403 tPowerdBm maxTxPwr = 0;
10404 tANI_U8 *pCountryInfo = NULL;
10405 eHalStatus status;
10406 tANI_U8 count = 0;
10407 tANI_U8 firstChannel;
10408 tANI_U8 maxChannels;
10409
10410 if (CSR_IS_CHANNEL_5GHZ(channel))
10411 {
10412 cfgId = WNI_CFG_MAX_TX_POWER_5;
10413 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10414 }
10415 else if (CSR_IS_CHANNEL_24GHZ(channel))
10416 {
10417 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10418 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10419 }
10420 else
10421 return maxTxPwr;
10422
10423 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10424 if (status != eHAL_STATUS_SUCCESS)
10425 {
10426 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10427 FL("%s: palAllocateMemory() failed, status = %d"),
10428 __FUNCTION__, status);
10429 goto error;
10430 }
10431 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10432 if (status != eHAL_STATUS_SUCCESS)
10433 {
10434 goto error;
10435 }
10436 /* Identify the channel and maxtxpower */
10437 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10438 {
10439 firstChannel = pCountryInfo[count++];
10440 maxChannels = pCountryInfo[count++];
10441 maxTxPwr = pCountryInfo[count++];
10442
10443 if ((channel >= firstChannel) &&
10444 (channel < (firstChannel + maxChannels)))
10445 {
10446 break;
10447 }
10448 }
10449
10450error:
10451 if (NULL != pCountryInfo)
10452 palFreeMemory(pMac->hHdd, pCountryInfo);
10453
10454 return maxTxPwr;
10455}
10456
10457
Jeff Johnson295189b2012-06-20 16:38:30 -070010458tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10459{
10460 tANI_BOOLEAN fValid = FALSE;
10461 tANI_U32 idxValidChannels;
10462 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10463
10464 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10465 {
10466 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10467 {
10468 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10469 {
10470 fValid = TRUE;
10471 break;
10472 }
10473 }
10474 }
10475 pMac->roam.numValidChannels = len;
10476 return fValid;
10477}
10478
Jeff Johnson295189b2012-06-20 16:38:30 -070010479tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10480{
10481 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10482 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010483 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10484 {
10485 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10486 {
10487 fValid = eANI_BOOLEAN_TRUE;
10488 break;
10489 }
10490 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010491 return (fValid);
10492}
10493
Jeff Johnson295189b2012-06-20 16:38:30 -070010494//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010495 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010496{
Jeff Johnsone7245742012-09-05 17:12:55 -070010497 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010498 tANI_U8 centerChn;
10499 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010500 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10501 {
10502 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10503 }
10504 else
10505 {
10506 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10507 }
10508 //Figure what the other side's CB mode
10509 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10510 {
10511 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10512 {
10513 if(pIes->HTInfo.present)
10514 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010515 /* This is called during INFRA STA/CLIENT and should use the merged value of
10516 * supported channel width and recommended tx width as per standard
10517 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010518 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010519 pIes->HTCaps.supportedChannelWidthSet,
10520 pIes->HTInfo.recommendedTxWidthSet,
10521 pIes->HTInfo.secondaryChannelOffset);
10522
10523 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10524 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010525 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010526 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10527 switch (eRet) {
10528 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10529 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10530 break;
10531 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10532 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10533 break;
10534 case PHY_SINGLE_CHANNEL_CENTERED:
10535 default:
10536 centerChn = primaryChn;
10537 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010538 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010539 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010540 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010541 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070010542 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010543 }
10544 }
10545 }
10546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010547 return eRet;
10548}
Jeff Johnson295189b2012-06-20 16:38:30 -070010549tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10550{
10551 tANI_BOOLEAN fFound = FALSE;
10552 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010553 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10554 {
10555 if( pCipherList->encryptionType[idx] == encryptionType )
10556 {
10557 fFound = TRUE;
10558 break;
10559 }
10560 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010561 return fFound;
10562}
Jeff Johnson295189b2012-06-20 16:38:30 -070010563tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10564{
10565 tANI_BOOLEAN fFound = FALSE;
10566 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010567 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10568 {
10569 if( pAuthList->authType[idx] == authType )
10570 {
10571 fFound = TRUE;
10572 break;
10573 }
10574 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010575 return fFound;
10576}
Jeff Johnson295189b2012-06-20 16:38:30 -070010577tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10578{
10579 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10580 tCsrScanResultFilter *pScanFilter = NULL;
10581 eHalStatus status = eHAL_STATUS_SUCCESS;
10582
10583 if(pProfile1 && pProfile2)
10584 {
10585 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10586 if(HAL_STATUS_SUCCESS(status))
10587 {
10588 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10589 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10590 if(HAL_STATUS_SUCCESS(status))
10591 {
10592 fCheck = eANI_BOOLEAN_FALSE;
10593 do
10594 {
10595 tANI_U32 i;
10596 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10597 {
10598 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10599 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10600 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10601 if ( fCheck ) break;
10602 }
10603 if(!fCheck)
10604 {
10605 break;
10606 }
10607 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10608 || pProfile2->BSSType != pProfile1->BSSType
10609 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10610 )
10611 {
10612 fCheck = eANI_BOOLEAN_FALSE;
10613 break;
10614 }
10615#ifdef WLAN_FEATURE_VOWIFI_11R
10616 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10617 {
10618 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10619 {
10620 fCheck = eANI_BOOLEAN_FALSE;
10621 break;
10622 }
10623 }
10624#endif
10625 //Match found
10626 fCheck = eANI_BOOLEAN_TRUE;
10627 }while(0);
10628 csrFreeScanFilter(pMac, pScanFilter);
10629 }
10630 palFreeMemory(pMac->hHdd, pScanFilter);
10631 }
10632 }
10633
10634 return (fCheck);
10635}
10636
Jeff Johnson295189b2012-06-20 16:38:30 -070010637tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10638{
10639 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10640 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010641 do
10642 {
10643 //Only check for static WEP
10644 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10645 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10646 {
10647 fCheck = eANI_BOOLEAN_TRUE;
10648 break;
10649 }
10650 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10651 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10652 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10653 {
10654 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10655 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10656 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10657 {
10658 break;
10659 }
10660 }
10661 if( i == CSR_MAX_NUM_KEY)
10662 {
10663 fCheck = eANI_BOOLEAN_TRUE;
10664 }
10665 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010666 return (fCheck);
10667}
10668
Jeff Johnson295189b2012-06-20 16:38:30 -070010669//IBSS
10670
Jeff Johnson295189b2012-06-20 16:38:30 -070010671tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10672{
10673 tANI_U8 channel = 0;
10674 tANI_U32 idx;
10675 tANI_U32 idxValidChannels;
10676 tANI_BOOLEAN fFound = FALSE;
10677 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10678
10679 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10680 {
10681 channel = pMac->roam.configParam.AdHocChannel5G;
10682 if(!csrRoamIsChannelValid(pMac, channel))
10683 {
10684 channel = 0;
10685 }
10686 }
10687 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10688 {
10689 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10690 {
10691 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10692 {
10693 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10694 {
10695 fFound = TRUE;
10696 channel = csrStartIbssChannels50[ idx ];
10697 }
10698 }
10699 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010700 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10701 if (!fFound)
10702 {
10703 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10704 {
10705 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10706 {
10707 channel = csrStartIbssChannels50[ idx ];
10708 break;
10709 }
10710 }
10711 }
10712 }//if
10713
10714 return( channel );
10715}
10716
Jeff Johnson295189b2012-06-20 16:38:30 -070010717tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10718{
10719 tANI_U8 channel = 1;
10720 tANI_U32 idx;
10721 tANI_U32 idxValidChannels;
10722 tANI_BOOLEAN fFound = FALSE;
10723 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10724
10725 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10726 {
10727 channel = pMac->roam.configParam.AdHocChannel24;
10728 if(!csrRoamIsChannelValid(pMac, channel))
10729 {
10730 channel = 0;
10731 }
10732 }
10733
10734 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10735 {
10736 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10737 {
10738 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10739 {
10740 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10741 {
10742 fFound = TRUE;
10743 channel = csrStartIbssChannels24[ idx ];
10744 }
10745 }
10746 }
10747 }
10748
10749 return( channel );
10750}
10751
Jeff Johnson295189b2012-06-20 16:38:30 -070010752static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10753 tCsrRoamStartBssParams *pParam )
10754{
10755 eCsrCfgDot11Mode cfgDot11Mode;
10756 eCsrBand eBand;
10757 tANI_U8 channel = 0;
10758 tSirNwType nwType;
10759 tANI_U8 operationChannel = 0;
10760
10761 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10762 {
10763 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10764 }
10765
Jeff Johnson295189b2012-06-20 16:38:30 -070010766 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010767
Jeff Johnson295189b2012-06-20 16:38:30 -070010768 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10769 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10770 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10771 )
10772 {
10773 /* This should never happen */
10774 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010775 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010776 pProfile->csrPersona);
10777 VOS_ASSERT(0);
10778 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010779 switch( cfgDot11Mode )
10780 {
10781 case eCSR_CFG_DOT11_MODE_11G:
10782 nwType = eSIR_11G_NW_TYPE;
10783 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010784 case eCSR_CFG_DOT11_MODE_11B:
10785 nwType = eSIR_11B_NW_TYPE;
10786 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010787 case eCSR_CFG_DOT11_MODE_11A:
10788 nwType = eSIR_11A_NW_TYPE;
10789 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010790 default:
10791 case eCSR_CFG_DOT11_MODE_11N:
10792 case eCSR_CFG_DOT11_MODE_TAURUS:
10793 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10794 if(eCSR_BAND_24 == eBand)
10795 {
10796 nwType = eSIR_11G_NW_TYPE;
10797 }
10798 else
10799 {
10800 nwType = eSIR_11A_NW_TYPE;
10801 }
10802 break;
10803 }
10804
10805 pParam->extendedRateSet.numRates = 0;
10806
10807 switch ( nwType )
10808 {
10809 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010810 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070010811 case eSIR_11A_NW_TYPE:
10812
10813 pParam->operationalRateSet.numRates = 8;
10814
10815 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10816 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10817 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10818 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10819 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10820 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10821 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10822 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10823
10824 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10825 {
10826 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10827 if( 0 == channel &&
10828 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10829 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10830 )
10831 {
10832 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10833 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10834 nwType = eSIR_11B_NW_TYPE;
10835 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10836 pParam->operationalRateSet.numRates = 4;
10837 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10838 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10839 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10840 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10841 }
10842 }
10843 else
10844 {
10845 channel = operationChannel;
10846 }
10847 break;
10848
10849 case eSIR_11B_NW_TYPE:
10850 pParam->operationalRateSet.numRates = 4;
10851 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10852 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10853 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10854 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010855 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10856 {
10857 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10858 }
10859 else
10860 {
10861 channel = operationChannel;
10862 }
10863
10864 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010865 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070010866 /* For P2P Client and P2P GO, disable 11b rates */
10867 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10868 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10869 )
10870 {
10871 pParam->operationalRateSet.numRates = 8;
10872
10873 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10874 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10875 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10876 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10877 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10878 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10879 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10880 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10881 }
10882 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010883 {
10884 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010885 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10886 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10887 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10888 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10889
10890 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010891 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10892 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10893 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10894 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10895 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10896 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10897 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10898 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10899 }
10900
10901 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10902 {
10903 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10904 }
10905 else
10906 {
10907 channel = operationChannel;
10908 }
10909
10910 break;
10911 }
10912 pParam->operationChn = channel;
10913 pParam->sirNwType = nwType;
10914}
10915
Jeff Johnson295189b2012-06-20 16:38:30 -070010916static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10917 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10918{
10919
10920 if( pParam )
10921 {
10922 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070010923 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010924 pParam->operationChn = pBssDesc->channelId;
10925 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
10926
10927 if( pIes )
10928 {
10929 if(pIes->SuppRates.present)
10930 {
10931 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
10932 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
10933 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010934 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 -070010935 pIes->SuppRates.num_rates);
10936 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
10937 }
10938 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
10939 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
10940 }
10941 if( pIes->SSID.present )
10942 {
10943 pParam->ssId.length = pIes->SSID.num_ssid;
10944 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
10945 }
10946 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070010947 }
10948 else
10949 {
10950 pParam->ssId.length = 0;
10951 pParam->operationalRateSet.numRates = 0;
10952 }
10953 }
10954}
10955
Jeff Johnson295189b2012-06-20 16:38:30 -070010956static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
10957{
10958 tANI_U8 MaxRate = 0;
10959 tANI_U32 i;
10960 tANI_U8 *pRate;
10961
10962 pRate = pSirRateSet->rate;
10963 for ( i = 0; i < pSirRateSet->numRates; i++ )
10964 {
10965 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
10966 }
10967
10968 // Save the max rate in the connected state information...
10969
10970 // modify LastRates variable as well
10971
10972 return;
10973}
10974
Jeff Johnson295189b2012-06-20 16:38:30 -070010975eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
10976 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
10977{
10978 eHalStatus status = eHAL_STATUS_SUCCESS;
10979 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010980 // Set the roaming substate to 'Start BSS attempt'...
10981 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010982#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10983 //Need to figure out whether we need to log WDS???
10984 if( CSR_IS_IBSS( pProfile ) )
10985 {
10986 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010987 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10988 if(pIbssLog)
10989 {
10990 if(pBssDesc)
10991 {
10992 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
10993 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
10994 }
10995 else
10996 {
10997 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
10998 }
10999 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
11000 pParam->ssId.length);
11001 if(pProfile->ChannelInfo.numOfChannels == 0)
11002 {
11003 pIbssLog->channelSetting = AUTO_PICK;
11004 }
11005 else
11006 {
11007 pIbssLog->channelSetting = SPECIFIED;
11008 }
11009 pIbssLog->operatingChannel = pParam->operationChn;
11010 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11011 }
11012 }
11013#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11014 //Put RSN information in for Starting BSS
11015 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11016 pParam->pRSNIE = pProfile->pRSNReqIE;
11017
Jeff Johnson295189b2012-06-20 16:38:30 -070011018 pParam->privacy = pProfile->privacy;
11019 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11020 pParam->authType = pProfile->csr80211AuthType;
11021 pParam->beaconInterval = pProfile->beaconInterval;
11022 pParam->dtimPeriod = pProfile->dtimPeriod;
11023 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11024 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11025 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11026 {
11027 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11028 {
11029 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11030 }
11031 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011032 pParam->protEnabled = pProfile->protEnabled;
11033 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11034 pParam->ht_protection = pProfile->cfg_protection;
11035 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011036
Jeff Johnson295189b2012-06-20 16:38:30 -070011037 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11038 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011039 pParam->bssPersona = pProfile->csrPersona;
11040 // When starting an IBSS, start on the channel from the Profile.
11041 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011042 return (status);
11043}
11044
Jeff Johnson295189b2012-06-20 16:38:30 -070011045static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011046 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011047{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011048 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011049 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011050 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011051
11052 if(!pSession)
11053 {
11054 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11055 return;
11056 }
11057
Jeff Johnson295189b2012-06-20 16:38:30 -070011058 if( pBssDesc )
11059 {
11060 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11061 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11062 //The following code has to be do after that.
11063 //For WDS station, use selfMac as the self BSSID
11064 if( CSR_IS_WDS_STA( pProfile ) )
11065 {
11066 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11067 }
11068 }
11069 else
11070 {
11071 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011072 //Use the first SSID
11073 if(pProfile->SSIDs.numOfSSIDs)
11074 {
11075 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
11076 }
11077 //For WDS station, use selfMac as the self BSSID
11078 if( CSR_IS_WDS_STA( pProfile ) )
11079 {
11080 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11081 }
11082 //Use the first BSSID
11083 else if( pProfile->BSSIDs.numOfBSSIDs )
11084 {
11085 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
11086 }
11087 else
11088 {
11089 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
11090 }
11091 }
11092 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011093 //Set operating channel in pProfile which will be used
11094 //in csrRoamSetBssConfigCfg() to determine channel bonding
11095 //mode and will be configured in CFG later
11096 pProfile->operationChannel = Channel;
11097
11098 if(Channel == 0)
11099 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011100 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011101 }
11102 else
11103 {
11104
11105 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011106 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011107 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011108 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011109 {
11110 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11111 }
11112 else
11113 {
11114 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11115 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011116 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011117 pBssConfig->cbMode = cbMode;
11118 pSession->bssParams.cbMode = cbMode;
11119 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011120 }
11121}
11122
Jeff Johnson295189b2012-06-20 16:38:30 -070011123static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11124 tANI_BOOLEAN *pfSameIbss )
11125{
11126 eHalStatus status = eHAL_STATUS_SUCCESS;
11127 tANI_BOOLEAN fSameIbss = FALSE;
11128
11129 if ( csrIsConnStateIbss( pMac, sessionId ) )
11130 {
11131 // Check if any profile parameter has changed ? If any profile parameter
11132 // has changed then stop old BSS and start a new one with new parameters
11133 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11134 {
11135 fSameIbss = TRUE;
11136 }
11137 else
11138 {
11139 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11140 }
11141 }
11142 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11143 {
11144 // Disassociate from the connected Infrastructure network...
11145 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11146 }
11147 else
11148 {
11149 tBssConfigParam *pBssConfig;
11150
11151 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
11152 if(HAL_STATUS_SUCCESS(status))
11153 {
11154 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
11155 // there is no Bss description before we start an IBSS so we need to adopt
11156 // all Bss configuration parameters from the Profile.
11157 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11158 if(HAL_STATUS_SUCCESS(status))
11159 {
11160 //save dotMode
11161 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11162 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011163 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011164 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
11165 }
11166
11167 palFreeMemory(pMac->hHdd, pBssConfig);
11168 }//Allocate memory
11169 }
11170
11171 if(pfSameIbss)
11172 {
11173 *pfSameIbss = fSameIbss;
11174 }
11175 return( status );
11176}
11177
Jeff Johnson295189b2012-06-20 16:38:30 -070011178static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11179 tSirSmeNewBssInfo *pNewBss )
11180{
11181 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011182
11183 if(!pSession)
11184 {
11185 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11186 return;
11187 }
11188
Jeff Johnson295189b2012-06-20 16:38:30 -070011189 if( pNewBss )
11190 {
11191 // Set the operating channel.
11192 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11193 // move the BSSId from the BSS description into the connected state information.
11194 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
11195 &(pNewBss->bssId), sizeof( tCsrBssid ) );
11196 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011197 return;
11198}
11199
Jeff Johnson295189b2012-06-20 16:38:30 -070011200#ifdef FEATURE_WLAN_WAPI
11201eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11202 tANI_U32 numItems )
11203{
11204 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11205 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011206 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11207 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011208 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011209 return status;
11210 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011211 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011212 pSession = CSR_GET_SESSION( pMac, sessionId );
11213 if(numItems <= CSR_MAX_BKID_ALLOWED)
11214 {
11215 status = eHAL_STATUS_SUCCESS;
11216 //numItems may be 0 to clear the cache
11217 pSession->NumBkidCache = (tANI_U16)numItems;
11218 if(numItems && pBKIDCache)
11219 {
11220 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
11221 sizeof(tBkidCacheInfo) * numItems );
11222 }
11223 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011224 return (status);
11225}
Jeff Johnson295189b2012-06-20 16:38:30 -070011226eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11227 tBkidCacheInfo *pBkidCache)
11228{
11229 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11230 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011231 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11232 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011233 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011234 return status;
11235 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011236 pSession = CSR_GET_SESSION( pMac, sessionId );
11237 if(pNum && pBkidCache)
11238 {
11239 if(pSession->NumBkidCache == 0)
11240 {
11241 *pNum = 0;
11242 status = eHAL_STATUS_SUCCESS;
11243 }
11244 else if(*pNum >= pSession->NumBkidCache)
11245 {
11246 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11247 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011248 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 -070011249 pSession->NumBkidCache);
11250 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11251 }
11252 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
11253 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
11254 *pNum = pSession->NumBkidCache;
11255 status = eHAL_STATUS_SUCCESS;
11256 }
11257 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011258 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011259}
Jeff Johnson295189b2012-06-20 16:38:30 -070011260tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11261{
11262 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011263}
11264#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011265eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11266 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11267{
11268 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11269 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011270
11271 if(!pSession)
11272 {
11273 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11274 return eHAL_STATUS_FAILURE;
11275 }
11276
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011277 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011278 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11279 {
11280#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11281 {
11282 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11283 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11284 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11285 secEvent.encryptionModeMulticast =
11286 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11287 secEvent.encryptionModeUnicast =
11288 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11289 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11290 secEvent.authMode =
11291 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11292 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11293 }
11294#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011295 status = eHAL_STATUS_SUCCESS;
11296 //numItems may be 0 to clear the cache
11297 pSession->NumPmkidCache = (tANI_U16)numItems;
11298 if(numItems && pPMKIDCache)
11299 {
11300 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11301 sizeof(tPmkidCacheInfo) * numItems );
11302 }
11303 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011304 return (status);
11305}
11306
Jeff Johnson295189b2012-06-20 16:38:30 -070011307tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11308{
11309 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11310}
11311
Jeff Johnson295189b2012-06-20 16:38:30 -070011312eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11313{
11314 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11315 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011316
11317 if(!pSession)
11318 {
11319 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11320 return eHAL_STATUS_FAILURE;
11321 }
11322
Jeff Johnson295189b2012-06-20 16:38:30 -070011323 if(pNum && pPmkidCache)
11324 {
11325 if(pSession->NumPmkidCache == 0)
11326 {
11327 *pNum = 0;
11328 status = eHAL_STATUS_SUCCESS;
11329 }
11330 else if(*pNum >= pSession->NumPmkidCache)
11331 {
11332 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11333 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011334 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 -070011335 pSession->NumPmkidCache);
11336 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11337 }
11338 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11339 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11340 *pNum = pSession->NumPmkidCache;
11341 status = eHAL_STATUS_SUCCESS;
11342 }
11343 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011344 return (status);
11345}
11346
Jeff Johnson295189b2012-06-20 16:38:30 -070011347eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11348{
11349 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11350 tANI_U32 len;
11351 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011352
11353 if(!pSession)
11354 {
11355 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11356 return eHAL_STATUS_FAILURE;
11357 }
11358
Jeff Johnson295189b2012-06-20 16:38:30 -070011359 if(pLen)
11360 {
11361 len = *pLen;
11362 *pLen = pSession->nWpaRsnReqIeLength;
11363 if(pBuf)
11364 {
11365 if(len >= pSession->nWpaRsnReqIeLength)
11366 {
11367 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11368 }
11369 }
11370 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011371 return (status);
11372}
11373
Jeff Johnson295189b2012-06-20 16:38:30 -070011374eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11375{
11376 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11377 tANI_U32 len;
11378 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011379
11380 if(!pSession)
11381 {
11382 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11383 return eHAL_STATUS_FAILURE;
11384 }
11385
Jeff Johnson295189b2012-06-20 16:38:30 -070011386 if(pLen)
11387 {
11388 len = *pLen;
11389 *pLen = pSession->nWpaRsnRspIeLength;
11390 if(pBuf)
11391 {
11392 if(len >= pSession->nWpaRsnRspIeLength)
11393 {
11394 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11395 }
11396 }
11397 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011398 return (status);
11399}
Jeff Johnson295189b2012-06-20 16:38:30 -070011400#ifdef FEATURE_WLAN_WAPI
11401eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11402{
11403 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11404 tANI_U32 len;
11405 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011406
11407 if(!pSession)
11408 {
11409 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11410 return eHAL_STATUS_FAILURE;
11411 }
11412
Jeff Johnson295189b2012-06-20 16:38:30 -070011413 if(pLen)
11414 {
11415 len = *pLen;
11416 *pLen = pSession->nWapiReqIeLength;
11417 if(pBuf)
11418 {
11419 if(len >= pSession->nWapiReqIeLength)
11420 {
11421 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11422 }
11423 }
11424 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011425 return (status);
11426}
Jeff Johnson295189b2012-06-20 16:38:30 -070011427eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11428{
11429 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11430 tANI_U32 len;
11431 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011432
11433 if(!pSession)
11434 {
11435 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11436 return eHAL_STATUS_FAILURE;
11437 }
11438
Jeff Johnson295189b2012-06-20 16:38:30 -070011439 if(pLen)
11440 {
11441 len = *pLen;
11442 *pLen = pSession->nWapiRspIeLength;
11443 if(pBuf)
11444 {
11445 if(len >= pSession->nWapiRspIeLength)
11446 {
11447 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11448 }
11449 }
11450 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011451 return (status);
11452}
11453#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011454eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11455{
11456 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11457 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011458
11459 if(!pSession)
11460 {
11461 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11462 return (retStatus);
11463 }
11464
Jeff Johnson295189b2012-06-20 16:38:30 -070011465 if(CSR_IS_ROAMING(pSession))
11466 {
11467 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11468 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11469 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011470 return (retStatus);
11471}
11472
Jeff Johnson295189b2012-06-20 16:38:30 -070011473//This function remove the connected BSS from te cached scan result
11474eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11475 tCsrRoamConnectedProfile *pConnProfile)
11476{
11477 eHalStatus status = eHAL_STATUS_FAILURE;
11478 tCsrScanResultFilter *pScanFilter = NULL;
11479 tListElem *pEntry;
11480 tCsrScanResult *pResult;
11481 tDot11fBeaconIEs *pIes;
11482 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011483 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11484 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11485 {
11486 do
11487 {
11488 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11489 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11490 if(!HAL_STATUS_SUCCESS(status)) break;
11491 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11492 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11493 if(!HAL_STATUS_SUCCESS(status)) break;
11494 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11495 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11496 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11497 {
11498 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11499 if(!HAL_STATUS_SUCCESS(status)) break;
11500 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11501 }
11502 pScanFilter->authType.numEntries = 1;
11503 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11504 pScanFilter->BSSType = pConnProfile->BSSType;
11505 pScanFilter->EncryptionType.numEntries = 1;
11506 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11507 pScanFilter->mcEncryptionType.numEntries = 1;
11508 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11509 //We ignore the channel for now, BSSID should be enough
11510 pScanFilter->ChannelInfo.numOfChannels = 0;
11511 //Also ignore the following fields
11512 pScanFilter->uapsd_mask = 0;
11513 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11514 pScanFilter->countryCode[0] = 0;
11515 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011516 csrLLLock(&pMac->scan.scanResultList);
11517 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11518 while( pEntry )
11519 {
11520 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11521 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11522 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11523 pScanFilter, NULL, NULL, NULL, &pIes);
11524 //Release the IEs allocated by csrMatchBSS is needed
11525 if( !pResult->Result.pvIes )
11526 {
11527 //need to free the IEs since it is allocated by csrMatchBSS
11528 palFreeMemory(pMac->hHdd, pIes);
11529 }
11530 if(fMatch)
11531 {
11532 //We found the one
11533 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11534 {
11535 //Free the memory
11536 csrFreeScanResultEntry( pMac, pResult );
11537 }
11538 break;
11539 }
11540 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11541 }//while
11542 csrLLUnlock(&pMac->scan.scanResultList);
11543 }while(0);
11544 if(pScanFilter)
11545 {
11546 csrFreeScanFilter(pMac, pScanFilter);
11547 palFreeMemory(pMac->hHdd, pScanFilter);
11548 }
11549 }
11550 return (status);
11551}
11552
Jeff Johnson295189b2012-06-20 16:38:30 -070011553//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011554eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11555{
11556 eHalStatus status = eHAL_STATUS_SUCCESS;
11557 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011558 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11559 {
11560 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11561 {
11562 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11563 {
11564 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011565 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011566 status = eHAL_STATUS_CSR_WRONG_STATE;
11567 break;
11568 }
11569 if( csrIsConnStateInfra( pMac, sessionId ) )
11570 {
11571 if( chnId &&
11572 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11573 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011574 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011575 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11576 status = eHAL_STATUS_CSR_WRONG_STATE;
11577 break;
11578 }
11579 }
11580 }
11581 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011582 return ( status );
11583}
11584
Jeff Johnson295189b2012-06-20 16:38:30 -070011585static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11586{
11587 eHalStatus status = eHAL_STATUS_SUCCESS;
11588 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11589 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011590
11591 if(!pSession)
11592 {
11593 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11594 return eHAL_STATUS_FAILURE;
11595 }
11596
Jeff Johnson295189b2012-06-20 16:38:30 -070011597 if ( csrIsConnStateIbss( pMac, sessionId ) )
11598 {
11599 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11600 }
11601 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11602 {
11603 // Disassociate from the connected Infrastructure network...
11604 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11605 }
11606 else
11607 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011608 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11609 //Otherwise we need to add code to handle the
11610 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11611 //send stop_bss to PE, before we can continue.
11612 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011613 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11614 /* Assume HDD provide bssid in profile */
11615 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11616 // there is no Bss description before we start an WDS so we need
11617 // to adopt all Bss configuration parameters from the Profile.
11618 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11619 if(HAL_STATUS_SUCCESS(status))
11620 {
11621 //Save profile for late use
11622 csrFreeRoamProfile( pMac, sessionId );
11623 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
11624 (void **)&pSession->pCurRoamProfile,
11625 sizeof(tCsrRoamProfile))))
11626 {
11627 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11628 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11629 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011630 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011631 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011632 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
11633 }
11634 }
11635
11636 return( status );
11637}
11638
Jeff Johnson295189b2012-06-20 16:38:30 -070011639////////////////////Mail box
11640
Jeff Johnson295189b2012-06-20 16:38:30 -070011641//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11642//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11643static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11644 tSirBssDescription *pBssDescription,
11645 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11646{
11647 tCsrChannelSet channelGroup;
11648 tSirMacCapabilityInfo *pAP_capabilityInfo;
11649 tAniBool fTmp;
11650 tANI_BOOLEAN found = FALSE;
11651 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011652 tANI_S8 pwrLimit = 0;
11653 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011654 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11655 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11656 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11657 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011658 // 802.11h
11659 //We can do this because it is in HOST CPU order for now.
11660 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080011661 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11662 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11663 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011664 fTmp = (tAniBool)pal_cpu_to_be32(1);
11665 }
11666 else
11667 fTmp = (tAniBool)0;
11668
11669 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11670 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11671 pBuf += sizeof(tAniBool);
11672 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011673 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011674 // This is required for 11k test VoWiFi Ent: Test 2.
11675 // We need the power capabilities for Assoc Req.
11676 // This macro is provided by the halPhyCfg.h. We pick our
11677 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080011678 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11679 if (0 != pwrLimit)
11680 {
11681 *pBuf++ = pwrLimit;
11682 }
11683 else
11684 {
11685 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11686 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011687 size = sizeof(pMac->roam.validChannelList);
11688 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11689 {
11690 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11691 for ( i = 0; i < size; i++)
11692 {
11693 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11694
11695 }
11696 }
11697 else
11698 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011699 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011700 *pBuf++ = 0; //tSirSupChnl->numChnl
11701 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011702 //Check whether it is ok to enter UAPSD
11703#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11704 if( btcIsReadyForUapsd(pMac) )
11705#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11706 {
11707 *pBuf++ = uapsdMask;
11708 }
11709#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11710 else
11711 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011712 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070011713 *pBuf++ = 0;
11714 }
11715#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11716
Jeff Johnson295189b2012-06-20 16:38:30 -070011717 // move the entire BssDescription into the join request.
11718 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11719 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011720 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11721}
11722
Jeff Johnson295189b2012-06-20 16:38:30 -070011723/*
11724 * The communication between HDD and LIM is thru mailbox (MB).
11725 * Both sides will access the data structure "tSirSmeJoinReq".
11726 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11727 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11728 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11729 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11730 */
11731eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011732 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011733{
11734 eHalStatus status = eHAL_STATUS_SUCCESS;
11735 tSirSmeJoinReq *pMsg;
11736 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011737 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011738 tANI_U16 msgLen, wTmp, ieLen;
11739 tSirMacRateSet OpRateSet;
11740 tSirMacRateSet ExRateSet;
11741 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11742 tANI_U32 dwTmp;
11743 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011744 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011745
11746 if(!pSession)
11747 {
11748 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11749 return eHAL_STATUS_FAILURE;
11750 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011751 /* To satisfy klockworks */
11752 if (NULL == pBssDescription)
11753 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011754 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011755 return eHAL_STATUS_FAILURE;
11756 }
11757
Jeff Johnson295189b2012-06-20 16:38:30 -070011758 do {
11759 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11760 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070011761 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070011762 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11763 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11764 // IE fields, but the length field in the bssDescription needs to be interpreted to
11765 // determine length of the IE fields.
11766 //
11767 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11768 // add in the length from the bssDescription (then add the size of the 'length' field
11769 // itself because that is NOT included in the length field).
11770 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11771 pBssDescription->length + sizeof( pBssDescription->length ) +
11772 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 -070011773 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11774 if ( !HAL_STATUS_SUCCESS(status) ) break;
11775 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011776 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011777 pMsg->length = pal_cpu_to_be16(msgLen);
11778 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011779 // sessionId
11780 *pBuf = (tANI_U8)sessionId;
11781 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011782 // transactionId
11783 *pBuf = 0;
11784 *( pBuf + 1 ) = 0;
11785 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011786 // ssId
11787 if( pIes->SSID.present && pIes->SSID.num_ssid )
11788 {
11789 // ssId len
11790 *pBuf = pIes->SSID.num_ssid;
11791 pBuf++;
11792 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11793 pBuf += pIes->SSID.num_ssid;
11794 }
11795 else
11796 {
11797 *pBuf = 0;
11798 pBuf++;
11799 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011800 // selfMacAddr
11801 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11802 pBuf += sizeof(tSirMacAddr);
11803 // bsstype
11804 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11805 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11806 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11807 pBuf += sizeof(tSirBssType);
11808 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011809 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11810 if (pBssDescription->channelId <= 14 &&
11811 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
11812 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
11813 {
11814 //Need to disable VHT operation in 2.4 GHz band
11815 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
11816 }
11817 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011818 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011819 //Persona
11820 *pBuf = (tANI_U8)pProfile->csrPersona;
11821 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011822 //CBMode
11823 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11824 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011825
11826 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011827 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11828
Jeff Johnson295189b2012-06-20 16:38:30 -070011829 // uapsdPerAcBitmask
11830 *pBuf = pProfile->uapsd_mask;
11831 pBuf++;
11832
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011833
11834
Jeff Johnson295189b2012-06-20 16:38:30 -070011835 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011836 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011837 {
11838 // OperationalRateSet
11839 if (OpRateSet.numRates) {
11840 *pBuf++ = OpRateSet.numRates;
11841 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11842 pBuf += OpRateSet.numRates;
11843 } else *pBuf++ = 0;
11844 // ExtendedRateSet
11845 if (ExRateSet.numRates) {
11846 *pBuf++ = ExRateSet.numRates;
11847 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11848 pBuf += ExRateSet.numRates;
11849 } else *pBuf++ = 0;
11850 }
11851 else
11852 {
11853 *pBuf++ = 0;
11854 *pBuf++ = 0;
11855 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011856 // rsnIE
11857 if ( csrIsProfileWpa( pProfile ) )
11858 {
11859 // Insert the Wpa IE into the join request
11860 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11861 (tCsrWpaIe *)( wpaRsnIE ) );
11862 }
11863 else if( csrIsProfileRSN( pProfile ) )
11864 {
11865 // Insert the RSN IE into the join request
11866 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11867 (tCsrRSNIe *)( wpaRsnIE ) );
11868 }
11869#ifdef FEATURE_WLAN_WAPI
11870 else if( csrIsProfileWapi( pProfile ) )
11871 {
11872 // Insert the WAPI IE into the join request
11873 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11874 (tCsrWapiIe *)( wpaRsnIE ) );
11875 }
11876#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011877 else
11878 {
11879 ieLen = 0;
11880 }
11881 //remember the IE for future use
11882 if( ieLen )
11883 {
11884 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11885 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011886 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 -070011887 ieLen = DOT11F_IE_RSN_MAX_LEN;
11888 }
11889#ifdef FEATURE_WLAN_WAPI
11890 if( csrIsProfileWapi( pProfile ) )
11891 {
11892 //Check whether we need to allocate more memory
11893 if(ieLen > pSession->nWapiReqIeLength)
11894 {
11895 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11896 {
11897 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11898 }
11899 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11900 if(!HAL_STATUS_SUCCESS(status)) break;
11901 }
11902 pSession->nWapiReqIeLength = ieLen;
11903 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11904 wTmp = pal_cpu_to_be16( ieLen );
11905 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11906 pBuf += sizeof(tANI_U16);
11907 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11908 pBuf += ieLen;
11909 }
11910 else//should be WPA/WPA2 otherwise
11911#endif /* FEATURE_WLAN_WAPI */
11912 {
11913 //Check whether we need to allocate more memory
11914 if(ieLen > pSession->nWpaRsnReqIeLength)
11915 {
11916 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11917 {
11918 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11919 }
11920 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
11921 if(!HAL_STATUS_SUCCESS(status)) break;
11922 }
11923 pSession->nWpaRsnReqIeLength = ieLen;
11924 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
11925 wTmp = pal_cpu_to_be16( ieLen );
11926 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11927 pBuf += sizeof(tANI_U16);
11928 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11929 pBuf += ieLen;
11930 }
11931 }
11932 else
11933 {
11934 //free whatever old info
11935 pSession->nWpaRsnReqIeLength = 0;
11936 if(pSession->pWpaRsnReqIE)
11937 {
11938 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11939 pSession->pWpaRsnReqIE = NULL;
11940 }
11941#ifdef FEATURE_WLAN_WAPI
11942 pSession->nWapiReqIeLength = 0;
11943 if(pSession->pWapiReqIE)
11944 {
11945 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11946 pSession->pWapiReqIE = NULL;
11947 }
11948#endif /* FEATURE_WLAN_WAPI */
11949 //length is two bytes
11950 *pBuf = 0;
11951 *(pBuf + 1) = 0;
11952 pBuf += 2;
11953 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011954#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011955 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011956 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011957 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070011958 //length is two bytes
11959 *pBuf = 0;
11960 *(pBuf + 1) = 0;
11961 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011962 }
11963 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011964 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011965 // cckmIE
11966 if( csrIsProfileCCX( pProfile ) )
11967 {
11968 // Insert the CCKM IE into the join request
11969 ieLen = csrConstructCcxCckmIe( pMac,
11970 pSession,
11971 pProfile,
11972 pBssDescription,
11973 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070011974 pSession->nWpaRsnReqIeLength,
11975 (void *)( wpaRsnIE ) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011976 }
11977 else
11978 {
11979 ieLen = 0;
11980 }
11981 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
11982 if( ieLen )
11983 {
11984 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
11985 wTmp = pal_cpu_to_be16( ieLen );
11986 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11987 pBuf += sizeof(tANI_U16);
11988 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11989 pBuf += ieLen;
11990 }
11991 else
11992 {
11993 //Indicate you have no CCKM IE
11994 //length is two bytes
11995 *pBuf = 0;
11996 *(pBuf + 1) = 0;
11997 pBuf += 2;
11998 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011999 }
12000#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012001 // addIEScan
12002 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
12003 {
12004 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012005 if(ieLen > pSession->nAddIEScanLength)
12006 {
12007 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
12008 {
12009 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12010 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012011 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012012 (void **)&pSession->pAddIEScan, ieLen);
12013 if(!HAL_STATUS_SUCCESS(status)) break;
12014 }
12015 pSession->nAddIEScanLength = ieLen;
12016 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
12017 pProfile->pAddIEScan, ieLen);
12018 wTmp = pal_cpu_to_be16( ieLen );
12019 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12020 pBuf += sizeof(tANI_U16);
12021 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
12022 pBuf += ieLen;
12023 }
12024 else
12025 {
12026 pSession->nAddIEScanLength = 0;
12027 if(pSession->pAddIEScan)
12028 {
12029 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12030 pSession->pAddIEScan = NULL;
12031 }
12032 *pBuf = 0;
12033 *(pBuf + 1) = 0;
12034 pBuf += 2;
12035 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012036 // addIEAssoc
12037 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12038 {
12039 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012040 if(ieLen > pSession->nAddIEAssocLength)
12041 {
12042 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
12043 {
12044 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12045 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012046 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012047 (void **)&pSession->pAddIEAssoc, ieLen);
12048 if(!HAL_STATUS_SUCCESS(status)) break;
12049 }
12050 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012051 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070012052 pProfile->pAddIEAssoc, ieLen);
12053 wTmp = pal_cpu_to_be16( ieLen );
12054 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12055 pBuf += sizeof(tANI_U16);
12056 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
12057 pBuf += ieLen;
12058 }
12059 else
12060 {
12061 pSession->nAddIEAssocLength = 0;
12062 if(pSession->pAddIEAssoc)
12063 {
12064 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12065 pSession->pAddIEAssoc = NULL;
12066 }
12067 *pBuf = 0;
12068 *(pBuf + 1) = 0;
12069 pBuf += 2;
12070 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012071
12072 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012073 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012074 //Unmask any AC in reassoc that is ACM-set
12075 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12076 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012077 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012078 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12079 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012080#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012081 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012082#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012083 uapsd_mask &= ~(acm_mask);
12084 }
12085 else
12086 {
12087 uapsd_mask = 0;
12088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012089 }
12090 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012091
Jeff Johnson295189b2012-06-20 16:38:30 -070012092 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
12093 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012094 pBuf += sizeof(tANI_U32);
12095
Jeff Johnson295189b2012-06-20 16:38:30 -070012096 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
12097 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012098 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012099#ifdef WLAN_FEATURE_11W
12100 //MgmtEncryption
12101 if (pProfile->MFPEnabled)
12102 {
12103 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12104 }
12105 else
12106 {
12107 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12108 }
12109 palCopyMemory(pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32));
12110 pBuf += sizeof(tANI_U32);
12111#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012112#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012113 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012114 if (csrIsProfile11r( pProfile )
12115#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012116 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12117 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012118#endif
12119 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012120 {
12121 // is11Rconnection;
12122 dwTmp = pal_cpu_to_be32(TRUE);
12123 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12124 pBuf += sizeof(tAniBool);
12125 }
12126 else
12127 {
12128 // is11Rconnection;
12129 dwTmp = pal_cpu_to_be32(FALSE);
12130 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12131 pBuf += sizeof(tAniBool);
12132 }
12133#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012134#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012135 /* A profile can not be both CCX and 11R. But an 802.11R AP
12136 * may be advertising support for CCX as well. So if we are
12137 * associating Open or explicitly CCX then we will get CCX.
12138 * If we are associating explictly 11R only then we will get
12139 * 11R.
12140 */
12141 if ((csrIsProfileCCX(pProfile) ||
12142 ((pIes->CCXVersion.present)
12143 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012144 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12145 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12146 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012147#ifdef WLAN_FEATURE_11W
12148 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12149#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012150 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012151 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12152 {
12153 // isCCXconnection;
12154 dwTmp = pal_cpu_to_be32(TRUE);
12155 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12156 pBuf += sizeof(tAniBool);
12157 }
12158 else
12159 {
12160 //isCCXconnection;
12161 dwTmp = pal_cpu_to_be32(FALSE);
12162 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12163 pBuf += sizeof(tAniBool);
12164 }
12165
12166 if (eWNI_SME_JOIN_REQ == messageType)
12167 {
12168 tCCXTspecInfo ccxTspec;
12169 // CCX-Tspec IEs in the ASSOC request is presently not supported
12170 // so nullify the TSPEC parameters
12171 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12172 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12173 pBuf += sizeof(tCCXTspecInfo);
12174 }
12175 else if (eWNI_SME_REASSOC_REQ == messageType)
12176 {
12177 if ((csrIsProfileCCX(pProfile) ||
12178 ((pIes->CCXVersion.present)
12179 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012180 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12181 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12182 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012183#ifdef WLAN_FEATURE_11W
12184 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12185#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012186 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012187 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012188 {
12189 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012190 // CCX Tspec information
12191 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12192 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12193 *pBuf = ccxTspec.numTspecs;
12194 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012195 // Copy the TSPEC information only if present
12196 if (ccxTspec.numTspecs) {
12197 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
12198 }
12199 pBuf += sizeof(ccxTspec.tspec);
12200 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012201 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012202 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012203 tCCXTspecInfo ccxTspec;
12204 // CCX-Tspec IEs in the ASSOC request is presently not supported
12205 // so nullify the TSPEC parameters
12206 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12207 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12208 pBuf += sizeof(tCCXTspecInfo);
12209 }
12210 }
12211#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012212#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012213 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012214 if (pMac->roam.configParam.isFastTransitionEnabled
12215#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012216 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012217#endif
12218 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012219 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012220 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012221 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012222 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012223 }
12224 else
12225 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012226 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012227 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012228 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012229 }
12230#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012231#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012232 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012233 {
12234 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012235 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012236 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012237 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012238 }
12239 else
12240 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012241 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012242 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012243 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012244 }
12245#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012246
12247 // txLdpcIniFeatureEnabled
12248 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12249 pBuf++;
12250
Kiran4a17ebe2013-01-31 10:43:43 -080012251 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12252 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12253 {
12254 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12255 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12256 csrApplyPower2Current(pMac);
12257 }
12258
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012259#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012260 // txBFIniFeatureEnabled
12261 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12262 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012263
12264 // txBFCsnValue
12265 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12266 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012267#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012268 //BssDesc
12269 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12270 (tANI_U8)pProfile->uapsd_mask);
12271 status = palSendMBMessage(pMac->hHdd, pMsg );
12272 if(!HAL_STATUS_SUCCESS(status))
12273 {
12274 break;
12275 }
12276 else
12277 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012278#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012279 if (eWNI_SME_JOIN_REQ == messageType)
12280 {
12281 //Tush-QoS: notify QoS module that join happening
12282 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12283 }
12284 else if (eWNI_SME_REASSOC_REQ == messageType)
12285 {
12286 //Tush-QoS: notify QoS module that reassoc happening
12287 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12288 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012289#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012290 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012291 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012292 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012293}
12294
Jeff Johnson295189b2012-06-20 16:38:30 -070012295//
12296eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12297{
12298 eHalStatus status = eHAL_STATUS_SUCCESS;
12299 tSirSmeDisassocReq *pMsg;
12300 tANI_U8 *pBuf;
12301 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012302 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12303 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12304 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012305 do {
12306 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12307 if ( !HAL_STATUS_SUCCESS(status) ) break;
12308 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12309 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12310 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012311 pBuf = &pMsg->sessionId;
12312 // sessionId
12313 *pBuf++ = (tANI_U8)sessionId;
12314 // transactionId
12315 *pBuf = 0;
12316 *( pBuf + 1 ) = 0;
12317 pBuf += sizeof(tANI_U16);
12318
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012319 if ( (pSession->pCurRoamProfile != NULL) &&
12320 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12321 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 {
12323 // Set the bssid address before sending the message to LIM
12324 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12325 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012326 // Set the peer MAC address before sending the message to LIM
12327 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12328 pBuf = pBuf + sizeof ( tSirMacAddr );
12329 }
12330 else
12331 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012332 // Set the peer MAC address before sending the message to LIM
12333 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12334 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12336 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012337 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012338 if(!HAL_STATUS_SUCCESS(status))
12339 {
12340 palFreeMemory(pMac->hHdd, pMsg);
12341 break;
12342 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012343 // reasonCode
12344 wTmp = pal_cpu_to_be16(reasonCode);
12345 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12346 if(!HAL_STATUS_SUCCESS(status))
12347 {
12348 palFreeMemory(pMac->hHdd, pMsg);
12349 break;
12350 }
12351 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012352 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12353 Here we should not send the disassoc over the air to the AP */
12354 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12355#ifdef WLAN_FEATURE_VOWIFI_11R
12356 && csrRoamIs11rAssoc(pMac)
12357#endif
12358 )
12359 {
12360 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12361 }
12362 pBuf += sizeof(tANI_U8);
12363 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012364 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012365 return( status );
12366}
Jeff Johnson295189b2012-06-20 16:38:30 -070012367eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12368{
12369 eHalStatus status = eHAL_STATUS_SUCCESS;
12370 tSirSmeTkipCntrMeasReq *pMsg;
12371 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012372 do
12373 {
12374 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12375 if ( !HAL_STATUS_SUCCESS(status) ) break;
12376 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12377 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12378 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012379 pBuf = &pMsg->sessionId;
12380 // sessionId
12381 *pBuf++ = (tANI_U8)sessionId;
12382 // transactionId
12383 *pBuf = 0;
12384 *( pBuf + 1 ) = 0;
12385 pBuf += sizeof(tANI_U16);
12386 // bssid
12387 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12388 pBuf = pBuf + sizeof ( tSirMacAddr );
12389 // bEnable
12390 *pBuf = (tANI_BOOLEAN)bEnable;
12391 if(!HAL_STATUS_SUCCESS(status))
12392 {
12393 palFreeMemory(pMac->hHdd, pMsg);
12394 break;
12395 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012396 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012397 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012398 return( status );
12399}
Jeff Johnson295189b2012-06-20 16:38:30 -070012400eHalStatus
12401csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12402 VOS_MODULE_ID modId, tSirMacAddr bssId,
12403 void *pUsrContext, void *pfnSapEventCallback,
12404 tANI_U8 *pAssocStasBuf )
12405{
12406 eHalStatus status = eHAL_STATUS_SUCCESS;
12407 tSirSmeGetAssocSTAsReq *pMsg;
12408 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12409 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012410 do
12411 {
12412 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12413 if (!HAL_STATUS_SUCCESS(status)) break;
12414 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12415 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012416 pBuf = (tANI_U8 *)&pMsg->bssId;
12417 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012418 // bssId
12419 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12420 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012421 // modId
12422 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12423 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12424 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012425 // pUsrContext
12426 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12427 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12428 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012429 // pfnSapEventCallback
12430 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12431 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12432 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012433 // pAssocStasBuf
12434 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12435 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12436 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012437 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012438 status = palSendMBMessage( pMac->hHdd, pMsg );
12439 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012440 return( status );
12441 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012442eHalStatus
12443csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12444 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12445 {
12446 eHalStatus status = eHAL_STATUS_SUCCESS;
12447 tSirSmeGetWPSPBCSessionsReq *pMsg;
12448 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12449 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012450 do
12451 {
12452 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12453 if (!HAL_STATUS_SUCCESS(status)) break;
12454 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12455 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012456 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
12457 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012458 // pUsrContext
12459 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12460 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12461 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012462 // pSapEventCallback
12463 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12464 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12465 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012466 // bssId
12467 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12468 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012469 // MAC Address of STA in WPS session
12470 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12471 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012472 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012473 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012474 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012475 return( status );
12476}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012477
12478eHalStatus
12479csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12480{
12481 tpSirChangeBIParams pMsg;
12482 tANI_U16 len = 0;
12483 eHalStatus status = eHAL_STATUS_SUCCESS;
12484 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12485
12486 if(!pSession)
12487 {
12488 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12489 return eHAL_STATUS_FAILURE;
12490 }
12491
12492 //NO need to update the Beacon Params if update beacon parameter flag is not set
12493 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12494 return eHAL_STATUS_SUCCESS;
12495
12496 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12497
12498 /* Create the message and send to lim */
12499 len = sizeof(tSirChangeBIParams);
12500 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12501 if(HAL_STATUS_SUCCESS(status))
12502 {
12503 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12504 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12505 pMsg->length = len;
12506
12507 // bssId
12508 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012509 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 -080012510 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12511 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12512 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012513 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012514 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12515 status = palSendMBMessage(pMac->hHdd, pMsg);
12516 }
12517 return status;
12518}
12519
Jeff Johnson295189b2012-06-20 16:38:30 -070012520eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12521{
12522 eHalStatus status = eHAL_STATUS_SUCCESS;
12523 tSirSmeDeauthReq *pMsg;
12524 tANI_U8 *pBuf;
12525 tANI_U16 wTmp;
12526 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12527 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12528 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012529 do {
12530 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12531 if ( !HAL_STATUS_SUCCESS(status) ) break;
12532 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12533 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12534 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12535 //sessionId
12536 pBuf = &pMsg->sessionId;
12537 *pBuf++ = (tANI_U8)sessionId;
12538
12539 //tansactionId
12540 *pBuf = 0;
12541 *(pBuf + 1 ) = 0;
12542 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012543 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012544 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012545 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12546 // Set the BSSID before sending the message to LIM
12547 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12548 pBuf = pBuf + sizeof(tSirMacAddr);
12549 }
12550 else
12551 {
12552 // Set the BSSID before sending the message to LIM
12553 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12554 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012555 }
12556 if(!HAL_STATUS_SUCCESS(status))
12557 {
12558 palFreeMemory(pMac->hHdd, pMsg);
12559 break;
12560 }
12561 // Set the peer MAC address before sending the message to LIM
12562 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12563 pBuf = pBuf + sizeof(tSirMacAddr);
12564 if(!HAL_STATUS_SUCCESS(status))
12565 {
12566 palFreeMemory(pMac->hHdd, pMsg);
12567 break;
12568 }
12569 wTmp = pal_cpu_to_be16(reasonCode);
12570 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12571 if(!HAL_STATUS_SUCCESS(status))
12572 {
12573 palFreeMemory(pMac->hHdd, pMsg);
12574 break;
12575 }
12576 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012577 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012578 return( status );
12579}
12580
Jeff Johnson295189b2012-06-20 16:38:30 -070012581eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12582{
12583 eHalStatus status = eHAL_STATUS_SUCCESS;
12584 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012585 do {
12586 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12587 if ( !HAL_STATUS_SUCCESS(status) ) break;
12588 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12589 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12590 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12591 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12592 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12593 if(!HAL_STATUS_SUCCESS(status))
12594 {
12595 palFreeMemory(pMac->hHdd, pMsg);
12596 break;
12597 }
12598//To test reconn
12599 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12600 if(!HAL_STATUS_SUCCESS(status))
12601 {
12602 palFreeMemory(pMac->hHdd, pMsg);
12603 break;
12604 }
12605//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012606 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012607 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012608 return( status );
12609}
12610
Jeff Johnson295189b2012-06-20 16:38:30 -070012611eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12612{
12613 eHalStatus status = eHAL_STATUS_SUCCESS;
12614 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012615 do {
12616 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12617 if ( !HAL_STATUS_SUCCESS(status) ) break;
12618 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12619 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12620 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12621 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12622 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12623 if(!HAL_STATUS_SUCCESS(status))
12624 {
12625 palFreeMemory(pMac->hHdd, pMsg);
12626 break;
12627 }
12628 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12629 if(!HAL_STATUS_SUCCESS(status))
12630 {
12631 palFreeMemory(pMac->hHdd, pMsg);
12632 break;
12633 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012635 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012636 return( status );
12637}
Jeff Johnson295189b2012-06-20 16:38:30 -070012638eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12639{
12640 eHalStatus status = eHAL_STATUS_SUCCESS;
12641 tSirSmeAssocCnf *pMsg;
12642 tANI_U8 *pBuf;
12643 tSirResultCodes statusCode;
12644 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012645 do {
12646 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12647 if ( !HAL_STATUS_SUCCESS(status) ) break;
12648 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12649 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12650 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012651 pBuf = (tANI_U8 *)&pMsg->statusCode;
12652 if(HAL_STATUS_SUCCESS(Halstatus))
12653 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12654 else
12655 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12656 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12657 pBuf += sizeof(tSirResultCodes);
12658 // bssId
12659 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12660 pBuf += sizeof (tSirMacAddr);
12661 // peerMacAddr
12662 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12663 pBuf += sizeof (tSirMacAddr);
12664 // aid
12665 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12666 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12667 pBuf += sizeof (tANI_U16);
12668 // alternateBssId
12669 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12670 pBuf += sizeof (tSirMacAddr);
12671 // alternateChannelId
12672 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012673 status = palSendMBMessage( pMac->hHdd, pMsg );
12674 if(!HAL_STATUS_SUCCESS(status))
12675 {
12676 //pMsg is freed by palSendMBMessage
12677 break;
12678 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012679 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012680 return( status );
12681}
Jeff Johnson295189b2012-06-20 16:38:30 -070012682eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12683 tpSirSmeAssocInd pAssocInd,
12684 eHalStatus Halstatus,
12685 tANI_U8 sessionId)
12686{
12687 tSirMsgQ msgQ;
12688 eHalStatus status = eHAL_STATUS_SUCCESS;
12689 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12690 tANI_U8 *pBuf;
12691 tSirResultCodes statusCode;
12692 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012693 do {
12694 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12695 if ( !HAL_STATUS_SUCCESS(status) ) break;
12696 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012697
Jeff Johnson295189b2012-06-20 16:38:30 -070012698 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12699 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12700
12701 pMsg->sessionId = sessionId;
12702
12703 pBuf = (tANI_U8 *)&pMsg->statusCode;
12704 if(HAL_STATUS_SUCCESS(Halstatus))
12705 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12706 else
12707 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12708 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12709 pBuf += sizeof(tSirResultCodes);
12710 // bssId
12711 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12712 pBuf += sizeof (tSirMacAddr);
12713 // peerMacAddr
12714 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12715 pBuf += sizeof (tSirMacAddr);
12716 // StaId
12717 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12718 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12719 pBuf += sizeof (tANI_U16);
12720 // alternateBssId
12721 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12722 pBuf += sizeof (tSirMacAddr);
12723 // alternateChannelId
12724 *pBuf = 11;
12725 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012726 // Instead of copying roam Info, we just copy only WmmEnabled , RsnIE information
12727 //Wmm
12728 *pBuf = pAssocInd->wmmEnabledSta;
12729 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012730 //RSN IE
12731 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12732 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012733 //Additional IE
12734 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12735 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012736 //reassocReq
12737 *pBuf = pAssocInd->reassocReq;
12738 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012739 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12740 msgQ.bodyptr = pMsg;
12741 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012742 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012743 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012744 return( status );
12745}
Jeff Johnson295189b2012-06-20 16:38:30 -070012746
Jeff Johnson295189b2012-06-20 16:38:30 -070012747eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId ,
12748 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12749 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12750 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12751 tANI_U8 *pKeyRsc )
12752{
12753 tSirSmeSetContextReq *pMsg;
12754 tANI_U16 msgLen;
12755 eHalStatus status = eHAL_STATUS_FAILURE;
12756 tAniEdType tmpEdType;
12757 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053012758 tANI_U8 *pBuf = NULL;
12759 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012760 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012761 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012762 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012763 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12764 // key set. Since we only support upto one key, we always allocate memory for 1 key
12765 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12766 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12767 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12768 ( sizeof( pMsg->keyMaterial.key ) );
12769
12770 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12771 if ( !HAL_STATUS_SUCCESS(status) ) break;
12772 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12773 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12774 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012775 //sessionId
12776 pBuf = &pMsg->sessionId;
12777 *pBuf = (tANI_U8)sessionId;
12778 pBuf++;
12779 // transactionId
12780 *pBuf = 0;
12781 *(pBuf + 1) = 0;
12782 pBuf += sizeof(tANI_U16);
12783 // peerMacAddr
12784 palCopyMemory( pMac->hHdd, pBuf,
12785 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12786
12787 pBuf += sizeof(tSirMacAddr);
12788
12789 // bssId
12790 palCopyMemory( pMac->hHdd, pBuf,
12791 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12792
12793 pBuf += sizeof(tSirMacAddr);
12794
12795 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012796 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12797 // in the tSirKeyMaterial keyMaterial; field).
12798 //
12799 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12800 // shorter than this max size. Is LIM interpreting this ok ?
12801 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 -070012802 // set pMsg->keyMaterial.edType
12803 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12804 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12805 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012806 // set the pMsg->keyMaterial.numKeys field
12807 *p = numKeys;
12808 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012809 // set pSirKey->keyId = keyId;
12810 *p = keyId;
12811 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012812 // set pSirKey->unicast = (tANI_U8)fUnicast;
12813 *p = (tANI_U8)fUnicast;
12814 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012815 // set pSirKey->keyDirection = aniKeyDirection;
12816 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12817 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12818 p += sizeof(tAniKeyDirection);
12819 // pSirKey->keyRsc = ;;
12820 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12821 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012822 // set pSirKey->paeRole
12823 *p = paeRole; // 0 is Supplicant
12824 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012825 // set pSirKey->keyLength = keyLength;
12826 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012827 if ( keyLength && pKey )
12828 {
12829 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12830 if(keyLength == 16)
12831 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012832 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 -070012833 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12834 pKey[5], pKey[6], pKey[7], pKey[8],
12835 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12836 }
12837 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012839 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012840 return( status );
12841}
12842
Jeff Johnson295189b2012-06-20 16:38:30 -070012843eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12844 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12845{
12846 eHalStatus status;
12847 tSirSmeStartBssReq *pMsg;
12848 tANI_U8 *pBuf = NULL;
12849 tANI_U8 *wTmpBuf = NULL;
12850 tANI_U16 msgLen, wTmp;
12851 tANI_U32 dwTmp;
12852 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012853 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012854 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012855 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012856
12857 if(!pSession)
12858 {
12859 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12860 return eHAL_STATUS_FAILURE;
12861 }
12862
Jeff Johnson295189b2012-06-20 16:38:30 -070012863 do {
12864 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12865 pSession->joinFailStatusCode.reasonCode = 0;
12866 msgLen = sizeof(tSirSmeStartBssReq);
12867 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12868 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12870 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012871 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012872 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012873 //sessionId
12874 *pBuf = (tANI_U8)sessionId;
12875 pBuf++;
12876 // transactionId
12877 *pBuf = 0;
12878 *(pBuf + 1) = 0;
12879 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012880 // bssid
12881 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12882 pBuf += sizeof(tSirMacAddr);
12883 // selfMacAddr
12884 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12885 pBuf += sizeof(tSirMacAddr);
12886 // beaconInterval
12887 if( pBssDesc && pBssDesc->beaconInterval )
12888 {
12889 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12890 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012891 else if(pParam->beaconInterval)
12892 {
12893 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12894 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012895 else
12896 {
12897 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
12898 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070012899 if(csrIsconcurrentsessionValid (pMac, sessionId,
12900 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070012901 == eHAL_STATUS_SUCCESS )
12902 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012903 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070012904 pParam->bssPersona);
12905 //Update the beacon Interval
12906 pParam->beaconInterval = wTmp;
12907 }
12908 else
12909 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012910 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070012911 status = eHAL_STATUS_FAILURE;
Gopichand Nakkala114718f2013-03-25 19:19:46 -070012912 palFreeMemory( pMac->hHdd, pMsg );
Jeff Johnsone7245742012-09-05 17:12:55 -070012913 return status;
12914 }
12915
Jeff Johnson295189b2012-06-20 16:38:30 -070012916 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12917 pBuf += sizeof(tANI_U16);
12918 // dot11mode
12919 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
12920 pBuf += 1;
12921 // bssType
12922 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
12923 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
12924 pBuf += sizeof(tSirBssType);
12925 // ssId
12926 if( pParam->ssId.length )
12927 {
12928 // ssId len
12929 *pBuf = pParam->ssId.length;
12930 pBuf++;
12931 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
12932 pBuf += pParam->ssId.length;
12933 }
12934 else
12935 {
12936 *pBuf = 0;
12937 pBuf++;
12938 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012939 // set the channel Id
12940 *pBuf = pParam->operationChn;
12941 pBuf++;
12942 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070012943 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
12944 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
12945 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070012946
Jeff Johnson295189b2012-06-20 16:38:30 -070012947 // Set privacy
12948 *pBuf = pParam->privacy;
12949 pBuf++;
12950
12951 //Set Uapsd
12952 *pBuf = pParam->ApUapsdEnable;
12953 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012954 //Set SSID hidden
12955 *pBuf = pParam->ssidHidden;
12956 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012957 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
12958 pBuf++;
12959
12960 //Ht protection Enable/Disable
12961 *pBuf = (tANI_U8)pParam->protEnabled;
12962 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012963 //Enable Beacons to Receive for OBSS protection Enable/Disable
12964 *pBuf = (tANI_U8)pParam->obssProtEnabled;
12965 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012966 //set cfg related to protection
12967 wTmp = pal_cpu_to_be16( pParam->ht_protection );
12968 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12969 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012970 // Set Auth type
12971 authType = pal_cpu_to_be32(pParam->authType);
12972 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
12973 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012974 // Set DTIM
12975 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
12976 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12977 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012978 // Set wps_state
12979 *pBuf = pParam->wps_state;
12980 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012981 //Persona
12982 *pBuf = (tANI_U8)pParam->bssPersona;
12983 pBuf++;
12984
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080012985 //txLdpcIniFeatureEnabled
12986 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
12987 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012988
Jeff Johnson295189b2012-06-20 16:38:30 -070012989
12990 // set RSN IE
12991 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
12992 {
12993 status = eHAL_STATUS_INVALID_PARAMETER;
12994 palFreeMemory( pMac->hHdd, pMsg );
12995 break;
12996 }
12997 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
12998 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12999 pBuf += sizeof(tANI_U16);
13000 if( wTmp )
13001 {
13002 wTmp = pParam->nRSNIELength;
13003 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
13004 pBuf += wTmp;
13005 }
13006 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
13007 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
13008 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013009 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13010 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013011 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
13012 pBuf += pParam->operationalRateSet.numRates ;
13013 *pBuf++ = pParam->extendedRateSet.numRates;
13014 if(0 != pParam->extendedRateSet.numRates)
13015 {
13016 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
13017 pBuf += pParam->extendedRateSet.numRates;
13018 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013019 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13020 pMsg->length = pal_cpu_to_be16(msgLen);
13021
13022 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013023 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013024 return( status );
13025}
13026
Jeff Johnson295189b2012-06-20 16:38:30 -070013027eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13028{
13029 eHalStatus status = eHAL_STATUS_FAILURE;
13030 tSirSmeStopBssReq *pMsg;
13031 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13032 tANI_U8 *pBuf;
13033 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013034
13035 if(!pSession)
13036 {
13037 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13038 return eHAL_STATUS_FAILURE;
13039 }
13040
Jeff Johnson295189b2012-06-20 16:38:30 -070013041 do {
13042 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13043 if ( !HAL_STATUS_SUCCESS(status) ) break;
13044 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13045 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13046 pBuf = &pMsg->sessionId;
13047 //sessionId
13048 *pBuf = (tANI_U8)sessionId;
13049 pBuf++;
13050 // transactionId
13051 *pBuf = 0;
13052 pBuf += sizeof(tANI_U16);
13053 //reason code
13054 *pBuf = 0;
13055 pBuf += sizeof(tSirResultCodes);
13056 // bssid
13057 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13058 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13059 {
13060 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
13061 }
13062 else
13063 {
13064 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
13065 }
13066 pBuf += sizeof(tSirMacAddr);
13067 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13068 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013069 status = palSendMBMessage( pMac->hHdd, pMsg );
13070#if 0
13071 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13072 if ( !HAL_STATUS_SUCCESS(status) ) break;
13073 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13074 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13075 pMsg->reasonCode = 0;
13076 // bssid
13077 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13078 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13079 {
13080 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13081 }
13082 else
13083 {
13084 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13085 }
13086 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
13087 pMsg->transactionId = 0;
13088 pMsg->sessionId = (tANI_U8)sessionId;
13089 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13090 status = palSendMBMessage( pMac->hHdd, pMsg );
13091#endif
13092 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013093 return( status );
13094}
13095
Jeff Johnson295189b2012-06-20 16:38:30 -070013096eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13097 tCsrRoamModifyProfileFields *pModProfileFields,
13098 tANI_U32 *pRoamId, v_BOOL_t fForce)
13099{
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 eHalStatus status = eHAL_STATUS_FAILURE;
13101 tANI_U32 roamId = 0;
13102 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013103 if((csrIsConnStateConnected(pMac, sessionId)) &&
13104 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
13105 &pSession->connectedProfile.modifyProfileFields,
13106 sizeof(tCsrRoamModifyProfileFields)))) )
13107 {
13108 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13109 if(pRoamId)
13110 {
13111 *pRoamId = roamId;
13112 }
13113
Jeff Johnson295189b2012-06-20 16:38:30 -070013114 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13115 eCsrSmeIssuedReassocToSameAP, roamId,
13116 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013117 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013118 return status;
13119}
Jeff Johnson295189b2012-06-20 16:38:30 -070013120static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13121{
13122 eHalStatus status = eHAL_STATUS_SUCCESS;
13123 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070013124 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
13125 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13126 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13127 return (status);
13128}
Jeff Johnson295189b2012-06-20 16:38:30 -070013129eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13130{
13131 eHalStatus status = eHAL_STATUS_SUCCESS;
13132 tListElem *pEntry = NULL;
13133 tSmeCmd *pCommand = NULL;
13134 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013135 do
13136 {
13137 if(pMsg == NULL)
13138 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013139 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013140 status = eHAL_STATUS_FAILURE;
13141 break;
13142 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013143 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13144 if(pEntry)
13145 {
13146 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13147 if(eSmeCommandAddStaSession == pCommand->command)
13148 {
13149 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013150 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013151 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013152 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013153 //Remove this command out of the active list
13154 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13155 {
13156 //Now put this command back on the avilable command list
13157 csrReleaseCommand(pMac, pCommand);
13158 }
13159 smeProcessPendingQueue( pMac );
13160 }
13161 else
13162 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013163 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 -070013164 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013165 status = eHAL_STATUS_FAILURE;
13166 break;
13167 }
13168 }
13169 else
13170 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013171 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 -070013172 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013173 status = eHAL_STATUS_FAILURE;
13174 break;
13175 }
13176 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013177 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013178}
Jeff Johnson295189b2012-06-20 16:38:30 -070013179eHalStatus csrSendMBAddSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13180{
13181 tSirSmeAddStaSelfReq *pMsg;
13182 tANI_U16 msgLen;
13183 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013184 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013185 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13186 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013187 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13188 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013189 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013190 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13191 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013192 // self station address
13193 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013194 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070013195 pMsg->selfMacAddr[0],
13196 pMsg->selfMacAddr[1],
13197 pMsg->selfMacAddr[2],
13198 pMsg->selfMacAddr[3],
13199 pMsg->selfMacAddr[4],
13200 pMsg->selfMacAddr[5]);
13201 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013202 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013203 return( status );
13204}
Jeff Johnson295189b2012-06-20 16:38:30 -070013205eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr sessionMacAddr)
13206{
13207 eHalStatus status = eHAL_STATUS_SUCCESS;
13208 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013209 pCommand = csrGetCommandBuffer(pMac);
13210 if(NULL == pCommand)
13211 {
13212 status = eHAL_STATUS_RESOURCES;
13213 }
13214 else
13215 {
13216 pCommand->command = eSmeCommandAddStaSession;
13217 pCommand->sessionId = (tANI_U8)sessionId;
13218 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013219 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13220 if( !HAL_STATUS_SUCCESS( status ) )
13221 {
13222 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013223 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013224 }
13225 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013226 return (status);
13227}
Jeff Johnson295189b2012-06-20 16:38:30 -070013228eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13229{
13230 return csrSendMBAddSelfStaReqMsg( pMac,
13231 pCommand->u.addStaSessionCmd.selfMacAddr );
13232}
Jeff Johnson295189b2012-06-20 16:38:30 -070013233eHalStatus csrRoamOpenSession( tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext,
13234 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId )
13235{
13236 eHalStatus status = eHAL_STATUS_SUCCESS;
13237 tANI_U32 i;
13238 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013239 *pbSessionId = CSR_SESSION_ID_INVALID;
13240 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13241 {
13242 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13243 {
13244 pSession = CSR_GET_SESSION( pMac, i );
13245 status = eHAL_STATUS_SUCCESS;
13246 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13247 pSession->sessionId = (tANI_U8)i;
13248 pSession->callback = callback;
13249 pSession->pContext = pContext;
13250 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
13251 *pbSessionId = (tANI_U8)i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013252 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerRoaming, csrRoamRoamingTimerHandler,
13253 &pSession->roamingTimerInfo);
13254 if(!HAL_STATUS_SUCCESS(status))
13255 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013256 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013257 break;
13258 }
13259#ifdef FEATURE_WLAN_BTAMP_UT_RF
13260 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerJoinRetry, csrRoamJoinRetryTimerHandler,
13261 &pSession->joinRetryTimerInfo);
13262 if(!HAL_STATUS_SUCCESS(status))
13263 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013264 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013265 break;
13266 }
13267#endif
13268 pSession->ibssJoinTimerInfo.pMac = pMac;
13269 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -070013270 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerIbssJoining, csrRoamIbssJoinTimerHandler,
13271 &pSession->ibssJoinTimerInfo);
13272 if(!HAL_STATUS_SUCCESS(status))
13273 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013274 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013275 break;
13276 }
13277 status = csrIssueAddStaForSessionReq ( pMac, i, pSelfMacAddr );
13278 break;
13279 }
13280 }
13281 if( CSR_ROAM_SESSION_MAX == i )
13282 {
13283 //No session is available
13284 status = eHAL_STATUS_RESOURCES;
13285 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013286 return ( status );
13287}
Jeff Johnson295189b2012-06-20 16:38:30 -070013288eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13289{
13290 eHalStatus status = eHAL_STATUS_SUCCESS;
13291 tListElem *pEntry = NULL;
13292 tSmeCmd *pCommand = NULL;
13293 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013294 do
13295 {
13296 if(pMsg == NULL)
13297 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013298 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013299 status = eHAL_STATUS_FAILURE;
13300 break;
13301 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013302 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13303 if(pEntry)
13304 {
13305 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13306 if(eSmeCommandDelStaSession == pCommand->command)
13307 {
13308 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013309 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013310 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013311 //This session is done.
13312 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013313 if(pCommand->u.delStaSessionCmd.callback)
13314 {
13315
13316 status = sme_ReleaseGlobalLock( &pMac->sme );
13317 if ( HAL_STATUS_SUCCESS( status ) )
13318 {
13319 pCommand->u.delStaSessionCmd.callback(
13320 pCommand->u.delStaSessionCmd.pContext);
13321 status = sme_AcquireGlobalLock( &pMac->sme );
13322 if (! HAL_STATUS_SUCCESS( status ) )
13323 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013324 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013325 return status;
13326 }
13327 }
13328 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013329 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013330 }
13331 }
13332
13333 //Remove this command out of the active list
13334 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13335 {
13336 //Now put this command back on the avilable command list
13337 csrReleaseCommand(pMac, pCommand);
13338 }
13339 smeProcessPendingQueue( pMac );
13340 }
13341 else
13342 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013343 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 -070013344 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013345 status = eHAL_STATUS_FAILURE;
13346 break;
13347 }
13348 }
13349 else
13350 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013351 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 -070013352 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013353 status = eHAL_STATUS_FAILURE;
13354 break;
13355 }
13356 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013357 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013358}
Jeff Johnson295189b2012-06-20 16:38:30 -070013359eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13360{
13361 tSirSmeDelStaSelfReq *pMsg;
13362 tANI_U16 msgLen;
13363 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013364 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013365 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13366 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013367 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13368 if ( !HAL_STATUS_SUCCESS(status) ) break;
13369
13370 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013371 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13372 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013373 // self station address
13374 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013375 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013376 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013377 return( status );
13378}
Jeff Johnson295189b2012-06-20 16:38:30 -070013379eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13380 tSirMacAddr sessionMacAddr,
13381 csrRoamSessionCloseCallback callback,
13382 void *pContext)
13383{
13384 eHalStatus status = eHAL_STATUS_SUCCESS;
13385 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013386 pCommand = csrGetCommandBuffer(pMac);
13387 if(NULL == pCommand)
13388 {
13389 status = eHAL_STATUS_RESOURCES;
13390 }
13391 else
13392 {
13393 pCommand->command = eSmeCommandDelStaSession;
13394 pCommand->sessionId = (tANI_U8)sessionId;
13395 pCommand->u.delStaSessionCmd.callback = callback;
13396 pCommand->u.delStaSessionCmd.pContext = pContext;
13397 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013398 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13399 if( !HAL_STATUS_SUCCESS( status ) )
13400 {
13401 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013402 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013403 }
13404 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013405 return (status);
13406}
Jeff Johnson295189b2012-06-20 16:38:30 -070013407eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13408{
13409 return csrSendMBDelSelfStaReqMsg( pMac,
13410 pCommand->u.delStaSessionCmd.selfMacAddr );
13411}
Jeff Johnson295189b2012-06-20 16:38:30 -070013412static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13413{
13414 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13415 tListElem *pEntry, *pNext;
13416 tSmeCmd *pCommand;
13417 tDblLinkList localList;
13418
13419 vos_mem_zero(&localList, sizeof(tDblLinkList));
13420 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13421 {
13422 smsLog(pMac, LOGE, FL(" failed to open list"));
13423 return;
13424 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013425 csrLLLock(pList);
13426 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13427 while(pEntry != NULL)
13428 {
13429 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13430 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13431 if(pCommand->sessionId == sessionId)
13432 {
13433 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13434 {
13435 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13436 }
13437 }
13438 pEntry = pNext;
13439 }
13440 csrLLUnlock(pList);
13441
13442 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13443 {
13444 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13445 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13446 }
13447 csrLLClose(&localList);
13448}
13449
Jeff Johnson295189b2012-06-20 16:38:30 -070013450void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13451{
13452 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13453 {
13454 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013455 csrRoamStop(pMac, sessionId);
13456 csrFreeConnectBssDesc(pMac, sessionId);
13457 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13458 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
13459 palTimerFree(pMac->hHdd, pSession->hTimerRoaming);
13460#ifdef FEATURE_WLAN_BTAMP_UT_RF
13461 palTimerFree(pMac->hHdd, pSession->hTimerJoinRetry);
13462#endif
13463 palTimerFree(pMac->hHdd, pSession->hTimerIbssJoining);
13464 purgeSmeSessionCmdList(pMac, sessionId);
13465 purgeCsrSessionCmdList(pMac, sessionId);
13466 csrInitSession(pMac, sessionId);
13467 }
13468}
13469
Jeff Johnson295189b2012-06-20 16:38:30 -070013470eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13471 tANI_BOOLEAN fSync,
13472 csrRoamSessionCloseCallback callback,
13473 void *pContext )
13474{
13475 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013476 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13477 {
13478 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13479 if(fSync)
13480 {
13481 csrCleanupSession(pMac, sessionId);
13482 }
13483 else
13484 {
13485 purgeSmeSessionCmdList(pMac, sessionId);
13486 purgeCsrSessionCmdList(pMac, sessionId);
13487 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13488 pSession->selfMacAddr, callback, pContext);
13489 }
13490 }
13491 else
13492 {
13493 status = eHAL_STATUS_INVALID_PARAMETER;
13494 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 return ( status );
13496}
13497
Jeff Johnson295189b2012-06-20 16:38:30 -070013498static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13499{
13500 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013501
13502 if(!pSession)
13503 {
13504 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13505 return;
13506 }
13507
Jeff Johnson295189b2012-06-20 16:38:30 -070013508 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13509 pSession->sessionId = CSR_SESSION_ID_INVALID;
13510 pSession->callback = NULL;
13511 pSession->pContext = NULL;
13512 pSession->ibss_join_pending = FALSE;
13513 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13514 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13515 csrFreeRoamProfile( pMac, sessionId );
13516 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13517 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13518 csrFreeConnectBssDesc(pMac, sessionId);
13519 csrScanEnable(pMac);
13520 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13521 if(pSession->pWpaRsnReqIE)
13522 {
13523 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13524 pSession->pWpaRsnReqIE = NULL;
13525 }
13526 pSession->nWpaRsnReqIeLength = 0;
13527 if(pSession->pWpaRsnRspIE)
13528 {
13529 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13530 pSession->pWpaRsnRspIE = NULL;
13531 }
13532 pSession->nWpaRsnRspIeLength = 0;
13533#ifdef FEATURE_WLAN_WAPI
13534 if(pSession->pWapiReqIE)
13535 {
13536 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13537 pSession->pWapiReqIE = NULL;
13538 }
13539 pSession->nWapiReqIeLength = 0;
13540 if(pSession->pWapiRspIE)
13541 {
13542 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13543 pSession->pWapiRspIE = NULL;
13544 }
13545 pSession->nWapiRspIeLength = 0;
13546#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013547 if(pSession->pAddIEScan)
13548 {
13549 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13550 pSession->pAddIEScan = NULL;
13551 }
13552 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013553 if(pSession->pAddIEAssoc)
13554 {
13555 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13556 pSession->pAddIEAssoc = NULL;
13557}
13558 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013559}
13560
Jeff Johnson295189b2012-06-20 16:38:30 -070013561eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13562{
13563 eHalStatus status = eHAL_STATUS_FAILURE;
13564 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013565 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13566 {
13567 if( CSR_IS_SESSION_VALID( pMac, i ) )
13568 {
13569 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13570 {
13571 //Found it
13572 status = eHAL_STATUS_SUCCESS;
13573 *pSessionId = i;
13574 break;
13575 }
13576 }
13577 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013578 return( status );
13579}
13580
Jeff Johnson295189b2012-06-20 16:38:30 -070013581//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13582//session because for IBSS, the bssid changes.
13583static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13584{
13585 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13586 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013587 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13588 {
13589 if( CSR_IS_SESSION_VALID( pMac, i ) )
13590 {
13591 pSession = CSR_GET_SESSION( pMac, i );
13592 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13593 {
13594 //Found it
13595 nRet = i;
13596 break;
13597 }
13598 }
13599 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013600 return (nRet);
13601}
Jeff Johnson295189b2012-06-20 16:38:30 -070013602static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13603{
13604 /* Update the current BSS info in ho control block based on connected
13605 profile info from pmac global structure */
13606
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013607 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013608 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13609 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013610 /* Check for user misconfig of RSSI trigger threshold */
13611 pMac->roam.configParam.vccRssiThreshold =
13612 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13613 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13614 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013615 /* Check for user misconfig of UL MAC Loss trigger threshold */
13616 pMac->roam.configParam.vccUlMacLossThreshold =
13617 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13618 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013619#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13620 {
13621 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013622 /* Indicate the neighbor roal algorithm about the connect indication */
13623 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13624 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13625 }
13626#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013627}
13628
Jeff Johnson295189b2012-06-20 16:38:30 -070013629static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13630{
13631 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013632
13633 if(!pSession)
13634 {
13635 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13636 return;
13637 }
13638
Jeff Johnson295189b2012-06-20 16:38:30 -070013639 //Only to handle the case for Handover on infra link
13640 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13641 {
13642 return;
13643 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013644 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13645 csrRoamDeregStatisticsReq(pMac);
13646 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13647#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13648 /* Indicate the neighbor roal algorithm about the disconnect indication */
13649 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13650#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013651
13652 //Remove this code once SLM_Sessionization is supported
13653 //BMPS_WORKAROUND_NOT_NEEDED
13654 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013655 csrIsInfraApStarted( pMac ) &&
13656 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013657 {
13658 pMac->roam.configParam.doBMPSWorkaround = 0;
13659 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013660}
13661
Jeff Johnson295189b2012-06-20 16:38:30 -070013662void csrRoamTlStatsTimerHandler(void *pv)
13663{
13664 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13665 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013666 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13667
Jeff Johnsone7245742012-09-05 17:12:55 -070013668 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13669
Jeff Johnson295189b2012-06-20 16:38:30 -070013670#if 0
13671 // TODO Persession .???
13672 //req TL for stats
13673 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13674 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013675 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013676 }
13677 else
13678 {
13679 //save in SME
13680 csrRoamSaveStatsFromTl(pMac, tlStats);
13681 }
13682#endif
13683 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13684 {
13685 if(pMac->roam.tlStatsReqInfo.periodicity)
13686 {
13687 //start timer
13688 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13689 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
13690 if(!HAL_STATUS_SUCCESS(status))
13691 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013692 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013693 return;
13694 }
13695 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13696 }
13697 }
13698}
Jeff Johnson295189b2012-06-20 16:38:30 -070013699void csrRoamPeStatsTimerHandler(void *pv)
13700{
13701 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13702 eHalStatus status;
13703 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13704 VOS_STATUS vosStatus;
13705 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 pPeStatsReqListEntry->timerRunning = FALSE;
13707 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13708 {
13709 // If we entered here, meaning the timer could not be successfully
13710 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13711
13712 /* Destroy the timer */
13713 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13714 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013716 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013717 }
13718
13719 // Free the entry
13720 palFreeMemory(pMac->hHdd, pPeStatsReqListEntry);
13721 pPeStatsReqListEntry = NULL;
13722 }
13723 else
13724 {
13725 if(!pPeStatsReqListEntry->rspPending)
13726 {
13727 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13728 pPeStatsReqListEntry->staId);
13729 if(!HAL_STATUS_SUCCESS(status))
13730 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013731 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013732 }
13733 else
13734 {
13735 pPeStatsReqListEntry->rspPending = TRUE;
13736 }
13737 }
13738
13739 //send down a req
13740 if(pPeStatsReqListEntry->periodicity &&
13741 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13742 {
13743 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13744 if(ePMC_FULL_POWER == powerState)
13745 {
13746 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13747 {
13748 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13749 }
13750 }
13751 else
13752 {
13753 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13754 {
13755 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13756 }
13757 }
13758 //start timer
13759 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13760 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13761 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013762 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 return;
13764 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013765 pPeStatsReqListEntry->timerRunning = TRUE;
13766
13767 }
13768
13769 }
13770}
Jeff Johnson295189b2012-06-20 16:38:30 -070013771void csrRoamStatsClientTimerHandler(void *pv)
13772{
13773 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013774 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13775 {
13776#if 0
13777 // TODO Stats fix for multisession
13778 //start the timer
13779 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13780
13781 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013783 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013784 }
13785#endif
13786 }
13787#if 0
13788 //send up the stats report
13789 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13790 pStaEntry->staId, pStaEntry->pContext);
13791#endif
13792}
13793
13794
13795
Jeff Johnson295189b2012-06-20 16:38:30 -070013796eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13797{
13798 tAniGetPEStatsReq *pMsg;
13799 eHalStatus status = eHAL_STATUS_SUCCESS;
13800 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13801 if ( !HAL_STATUS_SUCCESS(status) )
13802 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013803 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 return status;
13805 }
13806 // need to initiate a stats request to PE
13807 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13808 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13809 pMsg->staId = staId;
13810 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013811 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013812 if(!HAL_STATUS_SUCCESS(status))
13813 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013814 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013816 return status;
13817}
Jeff Johnson295189b2012-06-20 16:38:30 -070013818void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13819{
13820 tAniGetPEStatsRsp *pSmeStatsRsp;
13821 eHalStatus status = eHAL_STATUS_FAILURE;
13822 tListElem *pEntry = NULL;
13823 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13824 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13825 tANI_U32 tempMask = 0;
13826 tANI_U8 counter = 0;
13827 tANI_U8 *pStats = NULL;
13828 tANI_U32 length = 0;
13829 v_PVOID_t pvosGCtx;
13830 v_S7_t rssi = 0;
13831 tANI_U32 *pRssi = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013832 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13833 if(pSmeStatsRsp->rc)
13834 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013835 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 goto post_update;
13837 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013838 tempMask = pSmeStatsRsp->statsMask;
13839 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013840 /* subtract all statistics from this length, and after processing the entire
13841 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13842 * in this 'stats' message.
13843 */
13844 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013845 //new stats info from PE, fill up the stats strucutres in PMAC
13846 while(tempMask)
13847 {
13848 if(tempMask & 1)
13849 {
13850 switch(counter)
13851 {
13852 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013853 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013854 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13855 pStats, sizeof(tCsrSummaryStatsInfo));
13856 if(!HAL_STATUS_SUCCESS(status))
13857 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013858 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013859 }
13860 pStats += sizeof(tCsrSummaryStatsInfo);
13861 length -= sizeof(tCsrSummaryStatsInfo);
13862 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013863 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013864 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013865 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13866 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13867 if(!HAL_STATUS_SUCCESS(status))
13868 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013869 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013870 }
13871 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13872 length -= sizeof(tCsrGlobalClassAStatsInfo);
13873 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013875 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013876 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13877 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13878 if(!HAL_STATUS_SUCCESS(status))
13879 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013880 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 }
13882 pStats += sizeof(tCsrGlobalClassBStatsInfo);
13883 length -= sizeof(tCsrGlobalClassBStatsInfo);
13884 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013885 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013886 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013887 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
13888 pStats, sizeof(tCsrGlobalClassCStatsInfo));
13889 if(!HAL_STATUS_SUCCESS(status))
13890 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013891 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013892 }
13893 pStats += sizeof(tCsrGlobalClassCStatsInfo);
13894 length -= sizeof(tCsrGlobalClassCStatsInfo);
13895 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013896 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013897 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013898 if( CSR_MAX_STA > pSmeStatsRsp->staId )
13899 {
13900 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
13901 pStats, sizeof(tCsrPerStaStatsInfo));
13902 }
13903 else
13904 {
13905 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013906 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013907 VOS_ASSERT( 0 );
13908 }
13909 if(!HAL_STATUS_SUCCESS(status))
13910 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013911 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013912 }
13913 pStats += sizeof(tCsrPerStaStatsInfo);
13914 length -= sizeof(tCsrPerStaStatsInfo);
13915 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013916 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013917 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013919 }
13920 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013921 tempMask >>=1;
13922 counter++;
13923 }
13924 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
13925 if (length != 0)
13926 {
13927 pRssi = (tANI_U32*)pStats;
13928 rssi = (v_S7_t)*pRssi;
13929 }
13930 else
13931 {
13932 /* If riva is not sending rssi, continue to use the hack */
13933 rssi = RSSI_HACK_BMPS;
13934 }
13935 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -070013936post_update:
13937 //make sure to update the pe stats req list
13938 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
13939 if(pEntry)
13940 {
13941 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
13942 pPeStaEntry->rspPending = FALSE;
13943
13944 }
13945 //check the one timer cases
13946 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
13947 if(pEntry)
13948 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013949 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013950 if(pTempStaEntry->timerExpired)
13951 {
13952 //send up the stats report
13953 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
13954 pTempStaEntry->staId, pTempStaEntry->pContext);
13955 //also remove from the client list
13956 csrRoamRemoveStatListEntry(pMac, pEntry);
13957 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013958 }
13959 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013960}
Jeff Johnson295189b2012-06-20 16:38:30 -070013961tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13962{
13963 tListElem *pEntry = NULL;
13964 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013965 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013966 if(!pEntry)
13967 {
13968 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013969 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 return NULL;
13971 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013972 while( pEntry )
13973 {
13974 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013975 if(pTempStaEntry->statsMask == statsMask)
13976 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013977 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070013978 break;
13979 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
13981 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013982 return pEntry;
13983}
13984
Jeff Johnson295189b2012-06-20 16:38:30 -070013985tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
13986 tANI_BOOLEAN update)
13987{
13988 tListElem *pEntry;
13989 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013990 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013991 if(!pEntry)
13992 {
13993 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013994 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013995 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070013996 return NULL;
13997 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013998 while( pEntry )
13999 {
14000 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014001 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14002 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14003 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014004 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014005 if(update)
14006 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014007 pTempStaEntry->periodicity = pStaEntry->periodicity;
14008 pTempStaEntry->callback = pStaEntry->callback;
14009 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 }
14011 break;
14012 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14014 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014015 return pEntry;
14016}
Jeff Johnson295189b2012-06-20 16:38:30 -070014017tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14018{
14019 tListElem *pEntry;
14020 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014021 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014022 if(!pEntry)
14023 {
14024 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014025 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014026 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 return NULL;
14028 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014029 while( pEntry )
14030 {
14031 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014032 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14033 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014034 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014035 break;
14036 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014037 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14038 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014039 return pEntry;
14040}
Jeff Johnson295189b2012-06-20 16:38:30 -070014041eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14042 csrRoamLinkQualityIndCallback callback,
14043 void *pContext)
14044{
14045 pMac->roam.linkQualityIndInfo.callback = callback;
14046 pMac->roam.linkQualityIndInfo.context = pContext;
14047 if( NULL == callback )
14048 {
14049 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14050 }
14051 else
14052 {
14053 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014054 /* do we need to invoke the callback to notify client of initial value ?? */
14055 }
14056 return eHAL_STATUS_SUCCESS;
14057}
Jeff Johnson295189b2012-06-20 16:38:30 -070014058void csrRoamVccTrigger(tpAniSirGlobal pMac)
14059{
14060 eCsrRoamLinkQualityInd newVccLinkQuality;
14061 tANI_U32 ul_mac_loss = 0;
14062 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014063 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14064 /*-------------------------------------------------------------------------
14065 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014066 Check for a change in link quality and notify client if necessary
14067 -------------------------------------------------------------------------*/
14068 ul_mac_loss_trigger_threshold =
14069 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014070 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014071 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014072 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014073 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14074 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014075 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014076 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14077 }
14078 else
14079 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014080 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014081 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14082 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014083 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14084 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014085 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14086 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014087 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014088 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14089 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014090 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014091 newVccLinkQuality );
14092
14093 /* we now invoke the callback once to notify client of initial value */
14094 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14095 pMac->roam.linkQualityIndInfo.context );
14096 //event: EVENT_WLAN_VCC
14097 }
14098 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014099 pMac->roam.vccLinkQuality = newVccLinkQuality;
14100
Jeff Johnson295189b2012-06-20 16:38:30 -070014101}
Jeff Johnson295189b2012-06-20 16:38:30 -070014102VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14103 v_U8_t rssiNotification,
14104 void * context)
14105{
14106 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14107 eCsrRoamLinkQualityInd newVccLinkQuality;
14108 // TODO : Session info unavailable
14109 tANI_U32 sessionId = 0;
14110 VOS_STATUS status = VOS_STATUS_SUCCESS;
14111 /*-------------------------------------------------------------------------
14112 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014113 Check for a change in link quality and notify client if necessary
14114 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014115 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014116 pMac->roam.configParam.vccRssiThreshold);
14117 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14118 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014119 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014120 return VOS_STATUS_SUCCESS;
14121 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014122 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14123 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014124 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014125 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14126 }
14127 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14128 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014129 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014130 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14131 }
14132 else
14133 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014134 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014135 //Set to this so the code below won't do anything
14136 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014137 VOS_ASSERT(0);
14138 }
14139
Jeff Johnson295189b2012-06-20 16:38:30 -070014140 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14141 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014142 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014143 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14144 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014145 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014146 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014147 /* we now invoke the callback once to notify client of initial value */
14148 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14149 pMac->roam.linkQualityIndInfo.context );
14150 //event: EVENT_WLAN_VCC
14151 }
14152 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014153 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014154 return status;
14155}
Jeff Johnson295189b2012-06-20 16:38:30 -070014156tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14157 tDblLinkList *pStaList,
14158 tCsrStatsClientReqInfo *pStaEntry)
14159{
14160 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014161 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014162 //if same entity requested for same set of stats with different periodicity &
14163 // callback update it
14164 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14165 {
14166
14167 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
14168 if (!HAL_STATUS_SUCCESS(status))
14169 {
14170 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014171 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014172 return NULL;
14173 }
14174
Jeff Johnson295189b2012-06-20 16:38:30 -070014175 pNewStaEntry->callback = pStaEntry->callback;
14176 pNewStaEntry->pContext = pStaEntry->pContext;
14177 pNewStaEntry->periodicity = pStaEntry->periodicity;
14178 pNewStaEntry->requesterId = pStaEntry->requesterId;
14179 pNewStaEntry->statsMask = pStaEntry->statsMask;
14180 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14181 pNewStaEntry->pMac = pStaEntry->pMac;
14182 pNewStaEntry->staId = pStaEntry->staId;
14183 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14184
14185 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14186 }
14187 return pNewStaEntry;
14188}
14189
Jeff Johnson295189b2012-06-20 16:38:30 -070014190tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14191 tDblLinkList *pStaList,
14192 tCsrPeStatsReqInfo *pStaEntry)
14193{
14194 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014195 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014196 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
14197 if (!HAL_STATUS_SUCCESS(status))
14198 {
14199 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014200 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014201 return NULL;
14202 }
14203
Jeff Johnson295189b2012-06-20 16:38:30 -070014204 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14205 pNewStaEntry->numClient = pStaEntry->numClient;
14206 pNewStaEntry->periodicity = pStaEntry->periodicity;
14207 pNewStaEntry->statsMask = pStaEntry->statsMask;
14208 pNewStaEntry->pMac = pStaEntry->pMac;
14209 pNewStaEntry->staId = pStaEntry->staId;
14210 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14211 pNewStaEntry->rspPending = pStaEntry->rspPending;
14212
14213 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014214 return pNewStaEntry;
14215}
Jeff Johnson295189b2012-06-20 16:38:30 -070014216eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14217 tCsrRssiCallback callback,
14218 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14219{
14220 eHalStatus status = eHAL_STATUS_SUCCESS;
14221 vos_msg_t msg;
14222 tANI_U32 sessionId;
14223
14224 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014225 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014226 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14227 if ( !HAL_STATUS_SUCCESS(status) )
14228 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014229 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014230 return status;
14231 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014232 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14233
14234 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14235 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14236 pMsg->sessionId = sessionId;
14237 pMsg->staId = staId;
14238 pMsg->rssiCallback = callback;
14239 pMsg->pDevContext = pContext;
14240 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014241 msg.type = eWNI_SME_GET_RSSI_REQ;
14242 msg.bodyptr = pMsg;
14243 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014244 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14245 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014246 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014247 palFreeMemory(pMac->hHdd, (void *)pMsg);
14248 status = eHAL_STATUS_FAILURE;
14249 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014250 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014251 return status;
14252}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014253
14254#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14255eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14256 tCsrRssiCallback callback,
14257 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14258{
14259 eHalStatus status = eHAL_STATUS_SUCCESS;
14260 tAniGetRssiReq *pMsg;
14261
14262 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14263 if ( !HAL_STATUS_SUCCESS(status) )
14264 {
14265 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
14266 return status;
14267 }
14268 // need to initiate a stats request to PE
14269 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
14270 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14271 pMsg->staId = staId;
14272 pMsg->rssiCallback = callback;
14273 pMsg->pDevContext = pContext;
14274 pMsg->pVosContext = pVosContext;
14275 status = palSendMBMessage(pMac->hHdd, pMsg );
14276 if(!HAL_STATUS_SUCCESS(status))
14277 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070014278 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
14279 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014280 status = eHAL_STATUS_FAILURE;
14281 }
14282 return status;
14283}
14284#endif
14285
Jeff Johnson295189b2012-06-20 16:38:30 -070014286eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
14287 tANI_U32 statsMask,
14288 tCsrStatsCallback callback,
14289 tANI_U32 periodicity, tANI_BOOLEAN cache,
14290 tANI_U8 staId, void *pContext)
14291{
14292 tCsrStatsClientReqInfo staEntry;
14293 tCsrStatsClientReqInfo *pStaEntry = NULL;
14294 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14295 tListElem *pEntry = NULL;
14296 tANI_BOOLEAN found = FALSE;
14297 eHalStatus status = eHAL_STATUS_SUCCESS;
14298 tANI_BOOLEAN insertInClientList = FALSE;
14299 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070014300 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014301
14302 if( csrIsAllSessionDisconnected(pMac) )
14303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014304 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014305 return eHAL_STATUS_FAILURE;
14306 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014307 if((!statsMask) && (!callback))
14308 {
14309 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014310 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070014311 return eHAL_STATUS_FAILURE;
14312 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014313 //for the search list method for deregister
14314 staEntry.requesterId = requesterId;
14315 staEntry.statsMask = statsMask;
14316 //requester wants to deregister or just an error
14317 if((statsMask) && (!callback))
14318 {
14319 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
14320 if(!pEntry)
14321 {
14322 //msg
14323 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014324 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014325 return eHAL_STATUS_FAILURE;
14326 }
14327 else
14328 {
14329 //clean up & return
14330 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070014331 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014332 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014333 pStaEntry->pPeStaEntry->numClient--;
14334 //check if we need to delete the entry from peStatsReqList too
14335 if(!pStaEntry->pPeStaEntry->numClient)
14336 {
14337 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14338 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014339 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014340
Jeff Johnson295189b2012-06-20 16:38:30 -070014341 //check if we need to stop the tl stats timer too
14342 pMac->roam.tlStatsReqInfo.numClient--;
14343 if(!pMac->roam.tlStatsReqInfo.numClient)
14344 {
14345 if(pMac->roam.tlStatsReqInfo.timerRunning)
14346 {
14347 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14348 if(!HAL_STATUS_SUCCESS(status))
14349 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014350 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014351 return eHAL_STATUS_FAILURE;
14352 }
14353 }
14354 pMac->roam.tlStatsReqInfo.periodicity = 0;
14355 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14356 }
14357 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014358 // Destroy the vos timer...
14359 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14360 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14361 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014362 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014363 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014364 csrRoamRemoveStatListEntry(pMac, pEntry);
14365 pStaEntry = NULL;
14366 return eHAL_STATUS_SUCCESS;
14367 }
14368 }
14369
14370 if(cache && !periodicity)
14371 {
14372 //return the cached stats
14373 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14374 }
14375 else
14376 {
14377 //add the request in the client req list
14378 staEntry.callback = callback;
14379 staEntry.pContext = pContext;
14380 staEntry.periodicity = periodicity;
14381 staEntry.pPeStaEntry = NULL;
14382 staEntry.staId = staId;
14383 staEntry.pMac = pMac;
14384 staEntry.timerExpired = FALSE;
14385
14386
Jeff Johnson295189b2012-06-20 16:38:30 -070014387 //if periodic report requested with non cached result from PE/TL
14388 if(periodicity)
14389 {
14390
14391 //if looking for stats from PE
14392 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14393 {
14394
14395 //check if same request made already & waiting for rsp
14396 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14397 periodicity, &found, staId);
14398 if(!pPeStaEntry)
14399 {
14400 //bail out, maxed out on number of req for PE
14401 return eHAL_STATUS_FAILURE;
14402 }
14403 else
14404 {
14405 staEntry.pPeStaEntry = pPeStaEntry;
14406 }
14407
14408 }
14409 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14410 if(statsMask & (1 << eCsrGlobalClassDStats))
14411 {
14412 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14413 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014414 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014415 }
14416 else
14417 {
14418
14419 //update periodicity
14420 if(pMac->roam.tlStatsReqInfo.periodicity)
14421 {
14422 pMac->roam.tlStatsReqInfo.periodicity =
14423 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14424 }
14425 else
14426 {
14427 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14428 }
14429 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14430 {
14431 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14432 }
14433
14434 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14435 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014436 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14437 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014438 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014439 //req TL for class D stats
14440 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14441 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014442 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014443 }
14444 else
14445 {
14446 //save in SME
14447 csrRoamSaveStatsFromTl(pMac, pTlStats);
14448 }
14449 vos_mem_free(pTlStats);
14450 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014451 }
14452 else
14453 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014454 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014455 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014456
Jeff Johnson295189b2012-06-20 16:38:30 -070014457 if(pMac->roam.tlStatsReqInfo.periodicity)
14458 {
14459 //start timer
14460 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14461 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
14462 if(!HAL_STATUS_SUCCESS(status))
14463 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014464 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014465 return eHAL_STATUS_FAILURE;
14466 }
14467 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14468 }
14469 }
14470 }
14471 pMac->roam.tlStatsReqInfo.numClient++;
14472 }
14473
14474 insertInClientList = TRUE;
14475 }
14476 //if one time report requested with non cached result from PE/TL
14477 else if(!cache && !periodicity)
14478 {
14479 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14480 {
14481 //send down a req
14482 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14483 if(!HAL_STATUS_SUCCESS(status))
14484 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014485 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014486 }
14487 //so that when the stats rsp comes back from PE we respond to upper layer
14488 //right away
14489 staEntry.timerExpired = TRUE;
14490 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014491 }
14492 if(statsMask & (1 << eCsrGlobalClassDStats))
14493 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014494 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14495 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014496 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014497 //req TL for class D stats
14498 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14499 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014500 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014501 }
14502 else
14503 {
14504 //save in SME
14505 csrRoamSaveStatsFromTl(pMac, pTlStats);
14506 }
14507 vos_mem_free(pTlStats);
14508 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014509 }
14510 else
14511 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014512 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014513 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014514
14515 }
14516 //if looking for stats from TL only
14517 if(!insertInClientList)
14518 {
14519 //return the stats
14520 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14521 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014522 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014523 if(insertInClientList)
14524 {
14525 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14526 if(!pStaEntry)
14527 {
14528 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014529 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014530 return eHAL_STATUS_FAILURE;
14531 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014532 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014533 //Init & start timer if needed
14534 if(periodicity)
14535 {
14536 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14537 csrRoamStatsClientTimerHandler, pStaEntry );
14538 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14539 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014540 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014541 return eHAL_STATUS_FAILURE;
14542 }
14543 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14544 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14545 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014546 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014547 return eHAL_STATUS_FAILURE;
14548 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014549 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014550 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014551 }
14552 return eHAL_STATUS_SUCCESS;
14553}
14554
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014555#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
14556
14557static tSirRetStatus
14558csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
14559 tANI_U8* pBD,
14560 tANI_U8 type,
14561 tANI_U8 subType,
14562 tSirMacAddr peerAddr,
14563 tSirMacAddr selfMacAddr)
14564{
14565 tSirRetStatus statusCode = eSIR_SUCCESS;
14566 tpSirMacMgmtHdr pMacHdr;
14567
14568 /* Prepare MAC management header */
14569 pMacHdr = (tpSirMacMgmtHdr) (pBD);
14570
14571 /* Prepare FC */
14572 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14573 pMacHdr->fc.type = type;
14574 pMacHdr->fc.subType = subType;
14575
14576 /* Prepare Address 1 */
14577 palCopyMemory( pMac->hHdd,
14578 (tANI_U8 *) pMacHdr->da,
14579 (tANI_U8 *) peerAddr,
14580 sizeof( tSirMacAddr ));
14581
14582 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
14583
14584 /* Prepare Address 3 */
14585 palCopyMemory( pMac->hHdd,
14586 (tANI_U8 *) pMacHdr->bssId,
14587 (tANI_U8 *) peerAddr,
14588 sizeof( tSirMacAddr ));
14589 return statusCode;
14590} /*** csrRoamScanOffloadPopulateMacHeader() ***/
14591
14592static tSirRetStatus
14593csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
14594 tANI_U8 nChannelNum,
14595 tANI_U32 dot11mode,
14596 tSirMacAddr selfMacAddr,
14597 tANI_U8 *pFrame,
14598 tANI_U16 *pusLen)
14599{
14600 tDot11fProbeRequest pr;
14601 tANI_U32 nStatus, nBytes, nPayload;
14602 tSirRetStatus nSirStatus;
14603 /*Bcast tx*/
14604 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
14605 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14606
14607
14608 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
14609
14610 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
14611
14612 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
14613 {
14614 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
14615 }
14616
14617
14618 if (IS_DOT11_MODE_HT(dot11mode))
14619 {
14620 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
14621 }
14622
14623
14624 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
14625 if ( DOT11F_FAILED( nStatus ) )
14626 {
14627 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14628 "Failed to calculate the packed size f"
14629 "or a Probe Request (0x%08x).\n", nStatus );
14630
14631
14632 nPayload = sizeof( tDot11fProbeRequest );
14633 }
14634 else if ( DOT11F_WARNED( nStatus ) )
14635 {
14636 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14637 "There were warnings while calculating"
14638 "the packed size for a Probe Request ("
14639 "0x%08x).\n", nStatus );
14640 }
14641
14642 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
14643
14644 /* Prepare outgoing frame*/
14645 palZeroMemory( pMac->hHdd, pFrame, nBytes );
14646
14647
14648 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
14649 SIR_MAC_MGMT_PROBE_REQ, bssId ,selfMacAddr);
14650
14651 if ( eSIR_SUCCESS != nSirStatus )
14652 {
14653 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14654 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
14655 nSirStatus );
14656 return nSirStatus;
14657 }
14658
14659
14660 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
14661 sizeof( tSirMacMgmtHdr ),
14662 nPayload, &nPayload );
14663 if ( DOT11F_FAILED( nStatus ) )
14664 {
14665 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14666 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
14667 return eSIR_FAILURE;
14668 }
14669 else if ( DOT11F_WARNED( nStatus ) )
14670 {
14671 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14672 "There were warnings while packing a Probe Request (0x%08x).\n" );
14673 }
14674
14675 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
14676 return eSIR_SUCCESS;
14677}
14678
14679eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
14680{
14681 vos_msg_t msg;
14682 tSirRoamOffloadScanReq *pRequestBuf;
14683 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
14684 tCsrRoamSession *pSession;
14685 tANI_U8 i,num_channels = 0, ucDot11Mode;
14686 tANI_U8 *ChannelList = NULL;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070014687 tANI_U8 MaxDwellPeriod;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014688 tANI_U32 sessionId;
14689 eHalStatus status = eHAL_STATUS_SUCCESS;
14690 tpCsrChannelInfo currChannelListInfo;
14691 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
14692
14693 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled)
14694 {
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070014695 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set \n");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014696 return eHAL_STATUS_FAILURE;
14697 }
14698 status = csrRoamGetSessionIdFromBSSID(pMac,
14699 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
14700 &sessionId);
14701 /*The Dynamic Config Items Update may happen even if the state is in INIT.
14702 * It is important to ensure that the command is passed down to the FW only
14703 * if the Infra Station is in a connected state.A connected station could also be
14704 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
14705 * We also have to ensure that if there is a STOP command we always have to inform Riva,
14706 * irrespective of whichever state we are in.*/
14707 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
14708 (command != ROAM_SCAN_OFFLOAD_STOP))
14709 {
14710 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
14711 pMac->roam.neighborRoamInfo.neighborRoamState, command);
14712 return eHAL_STATUS_FAILURE;
14713 }
14714
14715 if ( !HAL_STATUS_SUCCESS( status ) )
14716 {
14717 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
14718 return eHAL_STATUS_FAILURE;
14719 }
14720 pSession = CSR_GET_SESSION( pMac, sessionId );
14721 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
14722 if (NULL == pRequestBuf)
14723 {
14724 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
14725 return eHAL_STATUS_FAILED_ALLOC;
14726 }
14727
14728 vos_mem_zero(pRequestBuf,sizeof(tSirRoamOffloadScanReq));
14729 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
14730 * host driver reloads, but Riva still up and running*/
14731 if(command == ROAM_SCAN_OFFLOAD_STOP)
14732 pRequestBuf->RoamScanOffloadEnabled = 0;
14733 else
14734 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
14735 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid, pNeighborRoamInfo->currAPbssid,
14736 sizeof(tCsrBssid));
14737 pRequestBuf->ConnectedNetwork.ssId.length =
14738 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
14739 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
14740 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
14741 pRequestBuf->ConnectedNetwork.ssId.length);
14742 pRequestBuf->ConnectedNetwork.authentication =
14743 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
14744 pRequestBuf->ConnectedNetwork.encryption =
14745 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
14746 pRequestBuf->ConnectedNetwork.mcencryption =
14747 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
14748 pRequestBuf->LookupThreshold =
14749 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
14750 pRequestBuf->RoamRssiDiff =
14751 pMac->roam.configParam.RoamRssiDiff;
14752 pRequestBuf->Command = command;
14753 pRequestBuf->StartScanReason = reason;
14754 pRequestBuf->NeighborScanTimerPeriod =
14755 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
14756 pRequestBuf->NeighborRoamScanRefreshPeriod =
14757 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
14758 pRequestBuf->NeighborScanChannelMinTime =
14759 pNeighborRoamInfo->cfgParams.minChannelScanTime;
14760 pRequestBuf->NeighborScanChannelMaxTime =
14761 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
14762 pRequestBuf->EmptyRefreshScanPeriod =
14763 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
14764#ifdef FEATURE_WLAN_CCX
14765 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
14766#endif
14767 if (
14768#ifdef FEATURE_WLAN_CCX
14769 ((pNeighborRoamInfo->isCCXAssoc) &&
14770 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
14771 eANI_BOOLEAN_FALSE)) ||
14772 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
14773#endif // CCX
14774 currChannelListInfo->numOfChannels == 0)
14775 {
14776
14777 /*Retreive the Channel Cache either from ini or from the Occupied Channels list.
14778 * Give Preference to INI Channels.*/
14779 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
14780 {
14781 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
14782 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels ;i++)
14783 {
14784 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14785 {
14786 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14787 }
14788 ChannelList++;
14789 }
14790 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14791 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
14792 }
14793 else{
14794 ChannelList = pMac->scan.occupiedChannels.channelList;
14795 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
14796 {
14797 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14798 {
14799 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14800 }
14801 ChannelList++;
14802 }
14803 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14804 /* If the profile changes as to what it was earlier, inform the FW through
14805 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
14806 * for the earlier profile and try to learn them afresh.*/
14807 if (reason == REASON_FLUSH_CHANNEL_LIST)
14808 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
14809 else {
14810 if (csrNeighborRoamIsNewConnectedProfile(pMac))
14811 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
14812 else
14813 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
14814 }
14815 }
14816 }
14817#ifdef FEATURE_WLAN_CCX
14818 else
14819 {
14820 /* If CCX is enabled, and a neighbor Report is received,then
14821 * Ignore the INI Channels or the Occupied Channel List. Consider
14822 * the channels in the neighbor list sent by the CCX AP.*/
14823 if (currChannelListInfo->numOfChannels != 0)
14824 {
14825 ChannelList = currChannelListInfo->ChannelList;
14826 for (i=0;i<currChannelListInfo->numOfChannels;i++)
14827 {
14828 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14829 {
14830 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14831 }
14832 ChannelList++;
14833 }
14834 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14835 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
14836 }
14837 }
14838#endif
14839 num_channels = 0;
14840 ChannelList = NULL;
14841
14842 /* Maintain the Valid Channels List*/
14843 if (0 == strncmp(pMac->scan.countryCodeCurrent, "KR", 2))
14844 {
14845 ChannelList = pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
14846 for(i=0; i<pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels; i++)
14847 {
14848 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14849 {
14850 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
14851 }
14852 ChannelList++;
14853 }
14854 pRequestBuf->ValidChannelCount = num_channels;
14855 } else {
14856 ChannelList = pMac->roam.validChannelList;
14857 for(i=0; i<pMac->roam.numValidChannels; i++)
14858 {
14859 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14860 {
14861 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
14862 }
14863 ChannelList++;
14864 }
14865 pRequestBuf->ValidChannelCount = num_channels;
14866 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070014867 pRequestBuf->MDID.mdiePresent =
14868 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
14869 pRequestBuf->MDID.mobilityDomain =
14870 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070014871 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
14872
14873 /*Max Dwell Period is calculated here to ensure that,
14874 * Home Away Time is atleast equal to (MaxDwellPeriod +
14875 * (2*SRF)), where SRF is the RF Switching time.The RF
14876 * switching time is considered twice to consider the
14877 * time to go off channel and return to the home channel.*/
14878 MaxDwellPeriod = pRequestBuf->NeighborScanChannelMaxTime/pRequestBuf->nProbes;
14879 if(MaxDwellPeriod < 1)
14880 MaxDwellPeriod = 1;
14881 if(pMac->roam.configParam.nRoamScanHomeAwayTime <
14882 (MaxDwellPeriod + (2 * SIR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
14883 {
14884 pRequestBuf->HomeAwayTime = MaxDwellPeriod + (2 * SIR_ROAM_SCAN_CHANNEL_SWITCH_TIME);
14885 } else {
14886 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
14887 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014888 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
14889 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
14890 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
14891 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
14892 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
14893
14894 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
14895 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070014896 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014897 msg.reserved = 0;
14898 msg.bodyptr = pRequestBuf;
14899 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
14900 {
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070014901 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014902 vos_mem_free(pRequestBuf);
14903 return eHAL_STATUS_FAILURE;
14904 }
14905
14906 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
14907 return status;
14908}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070014909
14910eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
14911{
14912 switch(reason)
14913 {
14914 case 0:
14915 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
14916 break;
14917 case REASON_OS_REQUESTED_ROAMING_NOW:
14918 csrNeighborRoamProceedWithHandoffReq(pMac);
14919 break;
14920 default:
14921 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with unknown Reason %d", reason);
14922 }
14923 return eHAL_STATUS_SUCCESS;
14924}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014925#endif
14926
Jeff Johnson295189b2012-06-20 16:38:30 -070014927tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
14928 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
14929{
14930 tANI_BOOLEAN found = FALSE;
14931 eHalStatus status = eHAL_STATUS_SUCCESS;
14932 tCsrPeStatsReqInfo staEntry;
14933 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
14934 tListElem *pStaEntry = NULL;
14935 VOS_STATUS vosStatus;
14936 tPmcPowerState powerState;
14937 *pFound = FALSE;
14938
14939 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
14940 if(pStaEntry)
14941 {
14942 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
14943 if(pTempStaEntry->periodicity)
14944 {
14945 pTempStaEntry->periodicity =
14946 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
14947 }
14948 else
14949 {
14950 pTempStaEntry->periodicity = periodicity;
14951 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014952 pTempStaEntry->numClient++;
14953 found = TRUE;
14954 }
14955 else
14956 {
14957 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
14958 staEntry.numClient = 1;
14959 staEntry.periodicity = periodicity;
14960 staEntry.pMac = pMac;
14961 staEntry.rspPending = FALSE;
14962 staEntry.staId = staId;
14963 staEntry.statsMask = statsMask;
14964 staEntry.timerRunning = FALSE;
14965 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
14966 if(!pTempStaEntry)
14967 {
14968 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014969 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014970 return NULL;
14971 }
14972 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014973 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14974 if(ePMC_FULL_POWER == powerState)
14975 {
14976 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14977 {
14978 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14979 }
14980 }
14981 else
14982 {
14983 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14984 {
14985 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14986 }
14987 }
14988 if(!pTempStaEntry->timerRunning)
14989 {
14990 //send down a req in case of one time req, for periodic ones wait for timer to expire
14991 if(!pTempStaEntry->rspPending &&
14992 !pTempStaEntry->periodicity)
14993 {
14994 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14995 if(!HAL_STATUS_SUCCESS(status))
14996 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014997 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014998 }
14999 else
15000 {
15001 pTempStaEntry->rspPending = TRUE;
15002 }
15003 }
15004 if(pTempStaEntry->periodicity)
15005 {
15006 if(!found)
15007 {
15008
15009 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
15010 csrRoamPeStatsTimerHandler, pTempStaEntry );
15011 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15012 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015013 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015014 return NULL;
15015 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015016 }
15017 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015018 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070015019 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
15020 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15021 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015022 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015023 return NULL;
15024 }
15025 pTempStaEntry->timerRunning = TRUE;
15026 }
15027 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015028 *pFound = found;
15029 return pTempStaEntry;
15030}
15031
Jeff Johnson295189b2012-06-20 16:38:30 -070015032/*
15033 pStaEntry is no longer invalid upon the return of this function.
15034*/
15035static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
15036{
15037 if(pEntry)
15038 {
15039 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15040 {
15041 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015042 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015043 }
15044 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015045
15046void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15047{
15048 tListElem *pEntry;
15049 tCsrPeStatsReqInfo *pTempStaEntry;
15050 VOS_STATUS vosStatus;
15051 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015052 if(!pEntry)
15053 {
15054 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015055 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015056 return;
15057 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015058 while( pEntry )
15059 {
15060 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015061 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15062 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015063 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015064 if(pTempStaEntry->timerRunning)
15065 {
15066 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15067 /* If we are not able to stop the timer here, just remove
15068 * the entry from the linked list. Destroy the timer object
15069 * and free the memory in the timer CB
15070 */
15071 if( vosStatus == VOS_STATUS_SUCCESS )
15072 {
15073 /* the timer is successfully stopped */
15074 pTempStaEntry->timerRunning = FALSE;
15075
15076 /* Destroy the timer */
15077 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15078 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15079 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015080 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015081 }
15082 }
15083 else
15084 {
15085 // the timer could not be stopped. Hence destroy and free the
15086 // memory for the PE stat entry in the timer CB.
15087 pTempStaEntry->timerStopFailed = TRUE;
15088 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015089 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015090
15091 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15092 {
15093 // Only free the memory if we could stop the timer successfully
15094 if(!pTempStaEntry->timerStopFailed)
15095 {
15096 palFreeMemory(pMac->hHdd, pTempStaEntry);
15097 pTempStaEntry = NULL;
15098 }
15099 break;
15100 }
15101
15102 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15103 }
15104 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015105 return;
15106}
15107
15108
Jeff Johnsone7245742012-09-05 17:12:55 -070015109void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015110{
15111
Jeff Johnsone7245742012-09-05 17:12:55 -070015112 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15113 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15114 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15115 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15116 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15117 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15118 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015119 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015120 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15121 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15122 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15123 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15124 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15125 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015126 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015127 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15128 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015129
15130}
15131
Jeff Johnson295189b2012-06-20 16:38:30 -070015132void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15133 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15134{
15135 tANI_U8 stats[500];
15136 tANI_U8 *pStats = NULL;
15137 tANI_U32 tempMask = 0;
15138 tANI_U8 counter = 0;
15139 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015140 if(!callback)
15141 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015142 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015143 return;
15144 }
15145 if(!statsMask)
15146 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015147 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015148 return;
15149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015150 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015151 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015152 while(tempMask)
15153 {
15154 if(tempMask & 1)
15155 {
15156 //new stats info from PE, fill up the stats strucutres in PMAC
15157 switch(counter)
15158 {
15159 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015160 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015161 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
15162 sizeof(tCsrSummaryStatsInfo));
15163 if(!HAL_STATUS_SUCCESS(status))
15164 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015165 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015166 }
15167 pStats += sizeof(tCsrSummaryStatsInfo);
15168 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015169 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015170 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015171 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
15172 sizeof(tCsrGlobalClassAStatsInfo));
15173 if(!HAL_STATUS_SUCCESS(status))
15174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015175 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015176 }
15177 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015178 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015179 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015180 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015181 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
15182 sizeof(tCsrGlobalClassBStatsInfo));
15183 if(!HAL_STATUS_SUCCESS(status))
15184 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015185 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015186 }
15187 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015188 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015189 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015190 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015191 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
15192 sizeof(tCsrGlobalClassCStatsInfo));
15193 if(!HAL_STATUS_SUCCESS(status))
15194 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015195 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015196 }
15197 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015198 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015199 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015200 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015201 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
15202 sizeof(tCsrGlobalClassDStatsInfo));
15203 if(!HAL_STATUS_SUCCESS(status))
15204 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015205 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015206 }
15207 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015208 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015209 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015210 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015211 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
15212 sizeof(tCsrPerStaStatsInfo));
15213 if(!HAL_STATUS_SUCCESS(status))
15214 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015215 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015216 }
15217 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015218 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015219 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015220 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015221 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015222 }
15223 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015224 tempMask >>=1;
15225 counter++;
15226 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015227 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070015228}
15229
Jeff Johnson295189b2012-06-20 16:38:30 -070015230eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
15231{
15232 tListElem *pEntry = NULL;
15233 tListElem *pPrevEntry = NULL;
15234 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15235 eHalStatus status = eHAL_STATUS_SUCCESS;
15236 VOS_STATUS vosStatus;
15237 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015238 if(!pEntry)
15239 {
15240 //list empty
15241 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015242 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015243 return status;
15244 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015245 while( pEntry )
15246 {
15247 if(pPrevEntry)
15248 {
15249 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15250 //send up the stats report
15251 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15252 pTempStaEntry->staId, pTempStaEntry->pContext);
15253 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15254 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015255 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015256 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
15257 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015258 pTempStaEntry->pPeStaEntry->numClient--;
15259 //check if we need to delete the entry from peStatsReqList too
15260 if(!pTempStaEntry->pPeStaEntry->numClient)
15261 {
15262 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
15263 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015264 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015265 //check if we need to stop the tl stats timer too
15266 pMac->roam.tlStatsReqInfo.numClient--;
15267 if(!pMac->roam.tlStatsReqInfo.numClient)
15268 {
15269 if(pMac->roam.tlStatsReqInfo.timerRunning)
15270 {
15271 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15272 if(!HAL_STATUS_SUCCESS(status))
15273 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015274 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015275 //we will continue
15276 }
15277 }
15278 pMac->roam.tlStatsReqInfo.periodicity = 0;
15279 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15280 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015281 if (pTempStaEntry->periodicity)
15282 {
15283 //While creating StaEntry in csrGetStatistics,
15284 //Initializing and starting timer only when periodicity is set.
15285 //So Stop and Destroy timer only when periodicity is set.
15286
Jeff Johnsone7245742012-09-05 17:12:55 -070015287 vos_timer_stop( &pTempStaEntry->timer );
15288 // Destroy the vos timer...
15289 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
15290 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15291 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015292 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015293 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015294 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015295
Jeff Johnson295189b2012-06-20 16:38:30 -070015296
15297 pPrevEntry = pEntry;
15298 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15299 }
15300 //the last one
15301 if(pPrevEntry)
15302 {
15303 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15304 //send up the stats report
15305 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15306 pTempStaEntry->staId, pTempStaEntry->pContext);
15307 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15308 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015309 return status;
15310
15311}
15312
Jeff Johnson295189b2012-06-20 16:38:30 -070015313eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
15314 tRequestFullPowerReason *pReason,
15315 tANI_BOOLEAN *pfNeedPower )
15316{
15317 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15318 tRequestFullPowerReason reason = eSME_REASON_OTHER;
15319 tPmcState pmcState;
15320 eHalStatus status = eHAL_STATUS_SUCCESS;
15321 // TODO : Session info unavailable
15322 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015323 if( pfNeedPower )
15324 {
15325 *pfNeedPower = eANI_BOOLEAN_FALSE;
15326 }
15327 //We only handle CSR commands
15328 if( !(eSmeCsrCommandMask & pCommand->command) )
15329 {
15330 return eHAL_STATUS_SUCCESS;
15331 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015332 //Check PMC state first
15333 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015334 switch( pmcState )
15335 {
15336 case REQUEST_IMPS:
15337 case IMPS:
15338 if( eSmeCommandScan == pCommand->command )
15339 {
15340 switch( pCommand->u.scanCmd.reason )
15341 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015342#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15343 case eCsrScanGetLfrResult:
15344#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015345 case eCsrScanGetResult:
15346 case eCsrScanBGScanAbort:
15347 case eCsrScanBGScanEnable:
15348 case eCsrScanGetScanChnInfo:
15349 //Internal process, no need for full power
15350 fNeedFullPower = eANI_BOOLEAN_FALSE;
15351 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015352 default:
15353 //Other scans are real scan, ask for power
15354 fNeedFullPower = eANI_BOOLEAN_TRUE;
15355 break;
15356 } //switch
15357 }
15358 else
15359 {
15360 //ask for power for roam and status change
15361 fNeedFullPower = eANI_BOOLEAN_TRUE;
15362 }
15363 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015364 case REQUEST_BMPS:
15365 case BMPS:
15366 case REQUEST_START_UAPSD:
15367 case UAPSD:
15368 //We treat WOWL same as BMPS
15369 case REQUEST_ENTER_WOWL:
15370 case WOWL:
15371 if( eSmeCommandRoam == pCommand->command )
15372 {
15373 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
15374 tCsrScanResult *pScanResult;
15375 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015376 switch ( pCommand->u.roamCmd.roamReason )
15377 {
15378 case eCsrForcedDisassoc:
15379 case eCsrForcedDisassocMICFailure:
15380 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15381 fNeedFullPower = eANI_BOOLEAN_TRUE;
15382 break;
15383 case eCsrSmeIssuedDisassocForHandoff:
15384 case eCsrForcedDeauth:
15385 case eCsrHddIssuedReassocToSameAP:
15386 case eCsrSmeIssuedReassocToSameAP:
15387 fNeedFullPower = eANI_BOOLEAN_TRUE;
15388 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015389 case eCsrCapsChange:
15390 fNeedFullPower = eANI_BOOLEAN_TRUE;
15391 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015392 default:
15393 //Check whether the profile is already connected. If so, no need for full power
15394 //Note: IBSS is ignored for now because we don't support powersave in IBSS
15395 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
15396 {
15397 //Only need to check the first one
15398 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
15399 if( pEntry )
15400 {
15401 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
15402#if 0
15403 // TODO : Session Specific info pConnectBssDesc
15404 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
15405 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
15406 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
15407 {
15408 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
15409 // with Authenticating first. To force this, stop the current association (Disassociate) and
15410 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
15411 // a new Association.
15412 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
15413 {
15414 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
15415 {
15416 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
15417 //No need for full power
15418 //Set the flag so the code later can avoid to do the above
15419 //check again.
15420 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
15421 break;
15422 }
15423 }
15424 }
15425#endif
15426 }
15427 }
15428 //If we are here, full power is needed
15429 fNeedFullPower = eANI_BOOLEAN_TRUE;
15430 break;
15431 }
15432 }
15433 else if( eSmeCommandWmStatusChange == pCommand->command )
15434 {
15435 //need full power for all
15436 fNeedFullPower = eANI_BOOLEAN_TRUE;
15437 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
15438 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015439#ifdef FEATURE_WLAN_TDLS
15440 else if( eSmeCommandTdlsAddPeer == pCommand->command )
15441 {
15442 //TDLS link is getting established. need full power
15443 fNeedFullPower = eANI_BOOLEAN_TRUE;
15444 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
15445 }
15446#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015447 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015448 case REQUEST_STOP_UAPSD:
15449 case REQUEST_EXIT_WOWL:
15450 if( eSmeCommandRoam == pCommand->command )
15451 {
15452 fNeedFullPower = eANI_BOOLEAN_TRUE;
15453 switch ( pCommand->u.roamCmd.roamReason )
15454 {
15455 case eCsrForcedDisassoc:
15456 case eCsrForcedDisassocMICFailure:
15457 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15458 break;
15459 default:
15460 break;
15461 }
15462 }
15463 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015464 case STOPPED:
15465 case REQUEST_STANDBY:
15466 case STANDBY:
15467 case LOW_POWER:
15468 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015469 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070015470 status = eHAL_STATUS_FAILURE;
15471 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015472 case FULL_POWER:
15473 case REQUEST_FULL_POWER:
15474 default:
15475 //No need to ask for full power. This has to be FULL_POWER state
15476 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015477 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070015478 if( pReason )
15479 {
15480 *pReason = reason;
15481 }
15482 if( pfNeedPower )
15483 {
15484 *pfNeedPower = fNeedFullPower;
15485 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015486 return ( status );
15487}
15488
Jeff Johnson295189b2012-06-20 16:38:30 -070015489static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15490{
15491 eHalStatus status = eHAL_STATUS_SUCCESS;
15492 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15493 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070015494 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070015495 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
15496 {
15497 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
15498 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015499 return ( status );
15500}
15501
Jeff Johnson295189b2012-06-20 16:38:30 -070015502tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
15503{
15504 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015505 if( pCmd )
15506 {
15507 pMac->roam.sPendingCommands++;
15508 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015509 return ( pCmd );
15510}
15511
Jeff Johnson295189b2012-06-20 16:38:30 -070015512void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
15513{
15514 if (pMac->roam.sPendingCommands > 0)
15515 {
15516 //All command allocated through csrGetCommandBuffer need to
15517 //decrement the pending count when releasing.
15518 pMac->roam.sPendingCommands--;
15519 smeReleaseCommand( pMac, pCommand );
15520 }
15521 else
15522 {
15523 smsLog(pMac, LOGE, FL( "no pending commands"));
15524 VOS_ASSERT(0);
15525 }
15526}
15527
Jeff Johnson295189b2012-06-20 16:38:30 -070015528//Return SUCCESS is the command is queued, failed
15529eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
15530{
15531 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015532 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
15533 {
15534 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
15535 pCommand->u.scanCmd.reason);
15536 return eHAL_STATUS_CSR_WRONG_STATE;
15537 }
15538
15539 //We can call request full power first before putting the command into pending Q
15540 //because we are holding SME lock at this point.
15541 status = csrRequestFullPower( pMac, pCommand );
15542 if( HAL_STATUS_SUCCESS( status ) )
15543 {
15544 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070015545 //make sure roamCmdPendingList is not empty first
15546 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
15547 if( fNoCmdPending )
15548 {
15549 smePushCommand( pMac, pCommand, fHighPriority );
15550 }
15551 else
15552 {
15553 //Other commands are waiting for PMC callback, queue the new command to the pending Q
15554 //no list lock is needed since SME lock is held
15555 if( !fHighPriority )
15556 {
15557 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15558 }
15559 else {
15560 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15561 }
15562 }
15563 }
15564 else if( eHAL_STATUS_PMC_PENDING == status )
15565 {
15566 //no list lock is needed since SME lock is held
15567 if( !fHighPriority )
15568 {
15569 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15570 }
15571 else {
15572 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15573 }
15574 //Let caller know the command is queue
15575 status = eHAL_STATUS_SUCCESS;
15576 }
15577 else
15578 {
15579 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
15580 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015581 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070015582 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015583 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015584}
Jeff Johnson295189b2012-06-20 16:38:30 -070015585eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
15586{
15587 eHalStatus status = eHAL_STATUS_SUCCESS;
15588 tSirUpdateAPWPSIEsReq *pMsg;
15589 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
15590
15591 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15592 if (NULL == pSession)
15593 {
15594 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15595 return eHAL_STATUS_FAILURE;
15596 }
15597
Jeff Johnson295189b2012-06-20 16:38:30 -070015598 do
15599 {
15600 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15601 if (!HAL_STATUS_SUCCESS(status)) break;
15602 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15603 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
15604
15605 pBuf = (tANI_U8 *)&pMsg->transactionId;
15606 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015607 // transactionId
15608 *pBuf = 0;
15609 *( pBuf + 1 ) = 0;
15610 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015611 // bssId
15612 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15613 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015614 //sessionId
15615 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015616 // APWPSIEs
15617 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
15618 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070015619 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015620 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015621 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015622 return ( status );
15623}
Jeff Johnson295189b2012-06-20 16:38:30 -070015624eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
15625{
15626 eHalStatus status = eHAL_STATUS_SUCCESS;
15627 tSirUpdateAPWPARSNIEsReq *pMsg;
15628 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015629 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15630 if (NULL == pSession)
15631 {
15632 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15633 return eHAL_STATUS_FAILURE;
15634 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015635 do
15636 {
15637 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
15638 if (!HAL_STATUS_SUCCESS(status)) break;
15639 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
15640 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015641 pBuf = (tANI_U8 *)&pMsg->transactionId;
15642 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015643 // transactionId
15644 *pBuf = 0;
15645 *( pBuf + 1 ) = 0;
15646 pBuf += sizeof(tANI_U16);
15647
15648 // bssId
15649 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15650 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015651 // sessionId
15652 *pBuf++ = (tANI_U8)sessionId;
15653
15654 // APWPARSNIEs
15655 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
15656 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015657 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015658 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015659 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015660 return ( status );
15661}
Jeff Johnson295189b2012-06-20 16:38:30 -070015662
15663#ifdef WLAN_FEATURE_VOWIFI_11R
15664//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
15665eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
15666{
15667 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15668 tpSirFTPreAuthReq pftPreAuthReq;
15669 tANI_U16 auth_req_len = 0;
15670 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015671 auth_req_len = sizeof(tSirFTPreAuthReq);
15672 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
15673 if (pftPreAuthReq == NULL)
15674 {
15675 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
15676 return eHAL_STATUS_RESOURCES;
15677 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015678 // Save the SME Session ID here. We need it while processing the preauth response
15679 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015680 vos_mem_zero(pftPreAuthReq, auth_req_len);
15681
15682 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
15683 sizeof(pBssDescription->length) + pBssDescription->length);
15684
15685 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
15686
15687 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
15688
Jeff Johnson295189b2012-06-20 16:38:30 -070015689 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015690 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
15691
Jeff Johnson295189b2012-06-20 16:38:30 -070015692#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080015693 if (csrRoamIs11rAssoc(pMac) &&
15694 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070015695 {
15696 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15697 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15698 pMac->ft.ftSmeContext.auth_ft_ies_length);
15699 }
15700 else
15701#endif
15702 {
15703 pftPreAuthReq->ft_ies_length = 0;
15704 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070015705 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
15706 sizeof(pBssDescription->length) + pBssDescription->length);
15707 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015708 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15709}
Jeff Johnson295189b2012-06-20 16:38:30 -070015710/*--------------------------------------------------------------------------
15711 * This will receive and process the FT Pre Auth Rsp from the current
15712 * associated ap.
15713 *
15714 * This will invoke the hdd call back. This is so that hdd can now
15715 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15716 ------------------------------------------------------------------------*/
15717void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15718{
15719 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15720 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015721#ifdef FEATURE_WLAN_LFR
15722 tCsrRoamInfo roamInfo;
15723#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015724
15725#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015726 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015727#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015728#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015729 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015730 if (status != eHAL_STATUS_SUCCESS) {
15731 /*
15732 * Bail out if pre-auth was not even processed.
15733 */
15734 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15735 return;
15736 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015737#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015738 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15739 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15740 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015741 // Implies a success
15742 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015743 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15744 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
15745 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070015746 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15747 * actual transition from the current to handoff AP is triggered */
15748 status = palTimerStart(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15749 60 * PAL_TIMER_TO_MS_UNIT,
15750 eANI_BOOLEAN_FALSE);
15751 if (eHAL_STATUS_SUCCESS != status)
15752 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015753 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015754 return;
15755 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015756 // Save the received response
15757 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15758 if (csrRoamIs11rAssoc(pMac))
15759 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15760 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15761
15762 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015763#ifdef FEATURE_WLAN_LFR
15764 // If Legacy Fast Roaming is enabled, signal the supplicant
15765 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015766 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015767 {
15768 // Save the bssid from the received response
15769 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15770 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15771 }
15772
15773#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015774
15775 // Done with it, init it.
15776 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15777}
15778#endif
15779#ifdef FEATURE_WLAN_BTAMP_UT_RF
15780void csrRoamJoinRetryTimerHandler(void *pv)
15781{
15782 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
15783 tpAniSirGlobal pMac = pInfo->pMac;
15784 tANI_U32 sessionId = pInfo->sessionId;
15785 tCsrRoamSession *pSession;
15786
15787 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15788 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015789 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015790 pSession = CSR_GET_SESSION( pMac, sessionId );
15791 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
15792 {
15793 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
15794 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015795 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015796 }
15797 }
15798 }
15799}
Jeff Johnson295189b2012-06-20 16:38:30 -070015800eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
15801{
15802 eHalStatus status = eHAL_STATUS_FAILURE;
15803 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15804
15805 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
15806 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015807 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070015808 pSession->maxRetryCount--;
15809 pSession->joinRetryTimerInfo.pMac = pMac;
15810 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
15811 status = palTimerStart(pMac->hHdd, pSession->hTimerJoinRetry, interval, eANI_BOOLEAN_FALSE);
15812 if(!HAL_STATUS_SUCCESS(status))
15813 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015814 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015815 }
15816 }
15817 else
15818 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015819 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070015820 pSession->maxRetryCount);
15821 }
15822
15823 return (status);
15824}
Jeff Johnson295189b2012-06-20 16:38:30 -070015825eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
15826{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015827 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070015828 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15829 {
15830 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerJoinRetry));
15831 }
15832
15833 return eHAL_STATUS_SUCCESS;
15834}
15835#endif
15836
15837
15838/*
15839 pBuf points to the beginning of the message
15840 LIM packs disassoc rsp as below,
15841 messageType - 2 bytes
15842 messageLength - 2 bytes
15843 sessionId - 1 byte
15844 transactionId - 2 bytes (tANI_U16)
15845 reasonCode - 4 bytes (sizeof(tSirResultCodes))
15846 peerMacAddr - 6 bytes
15847 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
15848*/
15849static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
15850{
15851 if(pBuf && pRsp)
15852 {
15853 pBuf += 4; //skip type and length
15854 pRsp->sessionId = *pBuf++;
15855 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
15856 pBuf += 2;
15857 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
15858 pBuf += 4;
15859 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
15860 }
15861}
15862
Jeff Johnsond13512a2012-07-17 11:42:19 -070015863eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15864{
15865 static uNvTables nvTables;
15866 eHalStatus status = eHAL_STATUS_SUCCESS;
15867 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
15868
15869 /* read the country code from NV and use it */
15870 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
15871 {
15872 palCopyMemory( pMac->hHdd, pCountry,
15873 nvTables.defaultCountryTable.countryCode,
15874 WNI_CFG_COUNTRY_CODE_LEN );
15875 return status;
15876 }
15877 else
15878 {
15879 palCopyMemory( pMac->hHdd, pCountry,
15880 "XXX",
15881 WNI_CFG_COUNTRY_CODE_LEN );
15882 status = eHAL_STATUS_FAILURE;
15883 return status;
15884 }
15885}
15886
15887eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15888{
15889 palCopyMemory( pMac->hHdd, pCountry,
15890 pMac->scan.countryCode11d,
15891 WNI_CFG_COUNTRY_CODE_LEN );
15892 return eHAL_STATUS_SUCCESS;
15893}
schang86c22c42013-03-13 18:41:24 -070015894
15895eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
15896{
15897 tSirSetTxPowerReq *pMsg = NULL;
15898 eHalStatus status = eHAL_STATUS_SUCCESS;
15899 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15900
15901 if (!pSession)
15902 {
15903 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15904 return eHAL_STATUS_FAILURE;
15905 }
15906
15907 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetTxPowerReq));
15908 if (HAL_STATUS_SUCCESS(status))
15909 {
15910 palZeroMemory(pMac->hHdd, (void *)pMsg, sizeof(tSirSetTxPowerReq));
15911 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
15912 pMsg->length = sizeof(tSirSetTxPowerReq);
15913 pMsg->mwPower = mW;
15914 palCopyMemory( pMac->hHdd,
15915 (tSirMacAddr *)pMsg->bssId,
15916 &pSession->selfMacAddr,
15917 sizeof(tSirMacAddr) );
15918 status = palSendMBMessage(pMac->hHdd, pMsg);
15919 if (!HAL_STATUS_SUCCESS(status))
15920 {
15921 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015922 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070015923 }
15924 }
15925 return status;
15926}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015927
15928/* Returns whether a session is in VOS_STA_MODE...or not */
15929tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
15930{
15931 tCsrRoamSession *pSession = NULL;
15932 pSession = CSR_GET_SESSION ( pMac, sessionId );
15933 if(!pSession)
15934 {
15935 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
15936 return eANI_BOOLEAN_FALSE;
15937 }
15938 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
15939 {
15940 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
15941 return eANI_BOOLEAN_FALSE;
15942 }
15943 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
15944 {
15945 return eANI_BOOLEAN_FALSE;
15946 }
15947 /* There is a possibility that the above check may fail,because
15948 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
15949 * when it is connected.So,we may sneak through the above check even
15950 * if we are not a STA mode INFRA station. So, if we sneak through
15951 * the above condition, we can use the following check if we are
15952 * really in STA Mode.*/
15953
15954 if ( NULL != pSession->pCurRoamProfile )
15955 {
15956 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
15957 {
15958 return eANI_BOOLEAN_TRUE;
15959 } else {
15960 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
15961 return eANI_BOOLEAN_FALSE;
15962 }
15963 }
15964
15965 return eANI_BOOLEAN_FALSE;
15966}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015967
15968#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15969eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
15970 tCsrHandoffRequest *pHandoffInfo)
15971{
15972 eHalStatus status = eHAL_STATUS_SUCCESS;
15973 vos_msg_t msg;
15974
15975 tAniHandoffReq *pMsg;
15976 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniHandoffReq));
15977 if ( !HAL_STATUS_SUCCESS(status) )
15978 {
15979 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
15980 return status;
15981 }
15982 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
15983 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
15984 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
15985 pMsg->channel = pHandoffInfo->channel;
15986 palCopyMemory(pMac->hHdd, pMsg->bssid,
15987 pHandoffInfo->bssid,
15988 6);
15989 msg.type = eWNI_SME_HANDOFF_REQ;
15990 msg.bodyptr = pMsg;
15991 msg.reserved = 0;
15992 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15993 {
15994 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
15995 palFreeMemory(pMac->hHdd, (void *)pMsg);
15996 status = eHAL_STATUS_FAILURE;
15997 }
15998 return status;
15999}
16000#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */