blob: 074f975ca22c9dd59339415551eadce629c42cab [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/** ------------------------------------------------------------------------- *
43 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -070044
Jeff Johnson295189b2012-06-20 16:38:30 -070045
46 \file csrApiRoam.c
47
48 Implementation for the Common Roaming interfaces.
49
50 Copyright (C) 2008 Qualcomm, Incorporated
51
52
53 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070054/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070055 EDIT HISTORY FOR FILE
56
Jeff Johnson295189b2012-06-20 16:38:30 -070057 This section contains comments describing changes made to the module.
58 Notice that changes are listed in reverse chronological order.
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060 when who what, where, why
61---------- --- --------------------------------------------------------
6206/03/10 js Added support to hostapd driven
63 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070064===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "aniGlobal.h" //for tpAniSirGlobal
66#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070067#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070068#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070069#include "palApi.h"
70#include "csrInsideApi.h"
71#include "smsDebug.h"
72#include "logDump.h"
73#include "smeQosInternal.h"
74#include "wlan_qct_tl.h"
75#include "smeInside.h"
76#include "vos_diag_core_event.h"
77#include "vos_diag_core_log.h"
78#include "csrApi.h"
79#include "pmc.h"
80#include "vos_nvitem.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070081#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
82#include "csrNeighborRoam.h"
83#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Jeff Johnson295189b2012-06-20 16:38:30 -070084#ifdef FEATURE_WLAN_CCX
85#include "csrCcx.h"
86#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070087#define CSR_NUM_IBSS_START_CHANNELS_50 4
88#define CSR_NUM_IBSS_START_CHANNELS_24 3
89#define CSR_DEF_IBSS_START_CHANNEL_50 36
90#define CSR_DEF_IBSS_START_CHANNEL_24 1
91#define CSR_IBSS_JOIN_TIMEOUT_PERIOD ( 1 * PAL_TIMER_TO_SEC_UNIT ) // 1 second
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080092#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD ( 5 * PAL_TIMER_TO_SEC_UNIT ) // 5 seconds, for WPA, WPA2, CCKM
Jeff Johnson295189b2012-06-20 16:38:30 -070093#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
94/*---------------------------------------------------------------------------
95 OBIWAN recommends [8 10]% : pick 9%
96---------------------------------------------------------------------------*/
97#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070098/*---------------------------------------------------------------------------
99 OBIWAN recommends -85dBm
100---------------------------------------------------------------------------*/
101#define CSR_VCC_RSSI_THRESHOLD 80
102#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
103#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
104#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
105#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -0700106//We use constatnt 4 here
107//This macro returns true when higher AC parameter is bigger than lower AC for a difference
108//The bigger the number, the less chance of TX
109//It must put lower AC as the first parameter.
110#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700111//Flag to send/do not send disassoc frame over the air
112#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700113#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700114#define MAX_CB_VALUE_IN_INI (2)
115
Jeff Johnson295189b2012-06-20 16:38:30 -0700116/*--------------------------------------------------------------------------
117 Static Type declarations
118 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800119static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800120#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
121static const char KR_3[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
122 36, 40, 44, 48, 52, 56, 60, 64, 100, 104,
123 108, 112, 116, 120, 124, 149, 153, 157, 161};
124static const char KR_24[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
125 36, 40, 44, 48, 52, 56, 60, 64, 100, 104,
126 108, 112, 116, 120, 124, 149, 153, 157, 161};
127static const char KR_25[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
128 36, 40, 44, 48, 149, 153, 157, 161};
129#endif
130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131/*--------------------------------------------------------------------------
132 Type declarations
133 ------------------------------------------------------------------------*/
134#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700135int diagAuthTypeFromCSRType(eCsrAuthType authType)
136{
137 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700138 switch(authType)
139 {
140 case eCSR_AUTH_TYPE_SHARED_KEY:
141 n = AUTH_SHARED;
142 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700143 case eCSR_AUTH_TYPE_WPA:
144 n = AUTH_WPA_EAP;
145 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700146 case eCSR_AUTH_TYPE_WPA_PSK:
147 n = AUTH_WPA_PSK;
148 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700149 case eCSR_AUTH_TYPE_RSN:
150 n = AUTH_WPA2_EAP;
151 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700152 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700153#ifdef WLAN_FEATURE_11W
154 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
155#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 n = AUTH_WPA2_PSK;
157 break;
158#ifdef FEATURE_WLAN_WAPI
159 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
160 n = AUTH_WAPI_CERT;
161 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
163 n = AUTH_WAPI_PSK;
164 break;
165#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 default:
167 break;
168 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 return (n);
170}
Jeff Johnson295189b2012-06-20 16:38:30 -0700171int diagEncTypeFromCSRType(eCsrEncryptionType encType)
172{
173 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700174 switch(encType)
175 {
176 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
177 case eCSR_ENCRYPT_TYPE_WEP40:
178 n = ENC_MODE_WEP40;
179 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
181 case eCSR_ENCRYPT_TYPE_WEP104:
182 n = ENC_MODE_WEP104;
183 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700184 case eCSR_ENCRYPT_TYPE_TKIP:
185 n = ENC_MODE_TKIP;
186 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700187 case eCSR_ENCRYPT_TYPE_AES:
188 n = ENC_MODE_AES;
189 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700190#ifdef FEATURE_WLAN_WAPI
191 case eCSR_ENCRYPT_TYPE_WPI:
192 n = ENC_MODE_SMS4;
193 break;
194#endif /* FEATURE_WLAN_WAPI */
195 default:
196 break;
197 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700198 return (n);
199}
Jeff Johnson295189b2012-06-20 16:38:30 -0700200#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700201static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
202static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700203static void initConfigParam(tpAniSirGlobal pMac);
204static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
205 eCsrRoamCompleteResult Result, void *Context );
206static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
207 tCsrRoamProfile *pProfile,
208 tANI_BOOLEAN *pfSameIbss );
209static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
210static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700211 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
212static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700213eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
214static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
215eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
216eHalStatus csrRoamClose(tpAniSirGlobal pMac);
217void csrRoamMICErrorTimerHandler(void *pv);
218void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
219tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
220
221static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
222static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
223static void csrRoamRoamingTimerHandler(void *pv);
224eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
225eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
226static void csrRoamIbssJoinTimerHandler(void *pv);
227eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
228eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
229static void csrRoamWaitForKeyTimeOutHandler(void *pv);
230
231static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700232static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700233static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
234eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
235 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
236 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
237 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
238 tANI_U8 *pKeyRsc );
239static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
240 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
241 tCsrRoamProfile *pProfile );
242void csrRoamStatisticsTimerHandler(void *pv);
243void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700244static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
245VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
246 v_U8_t rssiNotification,
247 void * context);
248static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
249void csrRoamVccTrigger(tpAniSirGlobal pMac);
250eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
251/*
252 pStaEntry is no longer invalid upon the return of this function.
253*/
254static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700255static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700256static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700257tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
258 tDblLinkList *pStaList,
259 tCsrStatsClientReqInfo *pStaEntry);
260void csrRoamStatsClientTimerHandler(void *pv);
261tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
262 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
263void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
264 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700265void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700266void csrRoamTlStatsTimerHandler(void *pv);
267void csrRoamPeStatsTimerHandler(void *pv);
268tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
269void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
270tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
271eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
272static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
273static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
274static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
275static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
276 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
277//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
278static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
279void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
280#ifdef FEATURE_WLAN_BTAMP_UT_RF
281void csrRoamJoinRetryTimerHandler(void *pv);
282#endif
283extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700284extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700285static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700286void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
288//Initialize global variables
289static void csrRoamInitGlobals(tpAniSirGlobal pMac)
290{
291 if(pMac)
292 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800293 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
294 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700295 }
296 return;
297}
298
Jeff Johnson295189b2012-06-20 16:38:30 -0700299static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
300{
301 if(pMac)
302 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800303 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 }
305 return;
306}
Jeff Johnson295189b2012-06-20 16:38:30 -0700307eHalStatus csrOpen(tpAniSirGlobal pMac)
308{
309 eHalStatus status = eHAL_STATUS_SUCCESS;
310 static uNvTables nvTables;
311 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700312 v_REGDOMAIN_t regId;
313 tANI_U32 i;
314
315 do
316 {
317 /* Initialize CSR Roam Globals */
318 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
320 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
321
322 initConfigParam(pMac);
323 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
324 break;
325 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
326 break;
327 pMac->roam.nextRoamId = 1; //Must not be 0
328 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
329 break;
330 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
331 break;
332 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
333 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
335 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
336 {
337 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
338 nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
339 status = eHAL_STATUS_SUCCESS;
340 }
341 else
342 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800343 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 //hardcoded for now
345 pMac->scan.countryCodeDefault[0] = 'U';
346 pMac->scan.countryCodeDefault[1] = 'S';
347 pMac->scan.countryCodeDefault[2] = 'I';
348 //status = eHAL_STATUS_SUCCESS;
349 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700350 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault, &regId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 WDA_SetRegDomain(pMac, regId);
353 pMac->scan.domainIdDefault = regId;
354 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
356 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
357 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700358 }while(0);
359
360 return (status);
361}
362
Jeff Johnson295189b2012-06-20 16:38:30 -0700363eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
364{
365 eHalStatus status = eHAL_STATUS_SUCCESS;
366 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
367 v_REGDOMAIN_t regId;
368 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 if(NULL == apCntryCode)
370 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800371 smsLog( pMac, LOGW, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 return eHAL_STATUS_FAILURE;
373 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700374 smsLog( pMac, LOGW, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700375 /* To get correct Regulatory domain from NV table
376 * 2 character Country code should be used
377 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700378 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
379/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700381
382 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800384 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700385 return eHAL_STATUS_FAILURE;
386 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700387*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700388 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId);
389 if (status != eHAL_STATUS_SUCCESS)
390 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700391 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 return status;
393 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 status = WDA_SetRegDomain(hHal, regId);
395 if (status != eHAL_STATUS_SUCCESS)
396 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700397 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700398 return status;
399 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700400 pMac->scan.domainIdDefault = regId;
401 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700402 /* Clear CC field */
403 palFillMemory( pMac->hHdd,
404 pMac->scan.countryCodeDefault,
405 WNI_CFG_COUNTRY_CODE_LEN,
406 0 );
407 /* Copy 2 or 3 bytes country code */
408 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
409 apCntryCode, cntryCodeLength );
Jeff Johnson295189b2012-06-20 16:38:30 -0700410 /* If 2 bytes country code, 3rd byte must be filled with space */
411 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
412 {
413 palFillMemory( pMac->hHdd,
414 pMac->scan.countryCodeDefault + 2,
415 1,
416 0x20 );
417 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700418 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
419 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
420 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700421 return status;
422}
Jeff Johnson295189b2012-06-20 16:38:30 -0700423eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
424{
425 eHalStatus status = eHAL_STATUS_SUCCESS;
426 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
427 tANI_U8 index = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700428 palCopyMemory( pMac->hHdd, pParam->Csr11dinfo.countryCode,
429 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN );
Jeff Johnson295189b2012-06-20 16:38:30 -0700430 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
431 {
432 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
433 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
434 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
435 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
436 }
437 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
438
439 return status;
440}
Jeff Johnson295189b2012-06-20 16:38:30 -0700441eHalStatus csrClose(tpAniSirGlobal pMac)
442{
443 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800444
Jeff Johnson295189b2012-06-20 16:38:30 -0700445 csrStop(pMac);
446 csrRoamClose(pMac);
447 csrScanClose(pMac);
448 csrLLClose(&pMac->roam.statsClientReqList);
449 csrLLClose(&pMac->roam.peStatsReqList);
450 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700451 /* DeInit Globals */
452 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 return (status);
454}
Jeff Johnson295189b2012-06-20 16:38:30 -0700455eHalStatus csrStart(tpAniSirGlobal pMac)
456{
457 eHalStatus status = eHAL_STATUS_SUCCESS;
458 tANI_U32 i;
459
460 do
461 {
462 //save the global vos context
463 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
464 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
465 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
466
467 status = csrRoamStart(pMac);
468 if(!HAL_STATUS_SUCCESS(status)) break;
469 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
470 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
471 if(!HAL_STATUS_SUCCESS(status)) break;
472 pMac->roam.sPendingCommands = 0;
473 csrScanEnable(pMac);
474#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
475 status = csrNeighborRoamInit(pMac);
476#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
477 pMac->roam.tlStatsReqInfo.numClient = 0;
478 pMac->roam.tlStatsReqInfo.periodicity = 0;
479 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
480 //init the link quality indication also
481 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
482 if(!HAL_STATUS_SUCCESS(status))
483 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800484 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 break;
486 }
487 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700488#if defined(ANI_LOGDUMP)
489 csrDumpInit(pMac);
490#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700491 return (status);
492}
493
Jeff Johnson295189b2012-06-20 16:38:30 -0700494eHalStatus csrStop(tpAniSirGlobal pMac)
495{
496 tANI_U32 sessionId;
497 tANI_U32 i;
498
499 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
500 {
501 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
502 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700503 csrScanDisable(pMac);
504 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
505 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
507
508#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
509 csrNeighborRoamClose(pMac);
510#endif
511 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 // deregister from PMC since we register during csrStart()
513 // (ignore status since there is nothing we can do if it fails)
514 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 //Reset the domain back to the deault
516 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800517 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700518
519 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
520 {
521 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP ,i );
522 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
523 }
524
525 return (eHAL_STATUS_SUCCESS);
526}
527
Jeff Johnson295189b2012-06-20 16:38:30 -0700528eHalStatus csrReady(tpAniSirGlobal pMac)
529{
530 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 csrScanGetSupportedChannels( pMac );
532 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
533 //use it to init the background scan list
534 csrInitBGScanChannelList(pMac);
535 /* HDD issues the init scan */
536 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800537 /* If the gScanAgingTime is set to '0' then scan results aging timeout
538 based on timer feature is not enabled*/
539 if(0 != pMac->scan.scanResultCfgAgingTime )
540 {
541 csrScanStartResultCfgAgingTimer(pMac);
542 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 //Store the AC weights in TL for later use
544 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 status = csrInitChannelList( pMac );
546 if ( ! HAL_STATUS_SUCCESS( status ) )
547 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800548 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 status );
550 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 return (status);
552}
Jeff Johnson295189b2012-06-20 16:38:30 -0700553void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
554{
555 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
557 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
558}
Jeff Johnson295189b2012-06-20 16:38:30 -0700559void csrSetGlobalCfgs( tpAniSirGlobal pMac )
560{
Jeff Johnsone7245742012-09-05 17:12:55 -0700561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
563 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
564 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
565 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
566 NULL, eANI_BOOLEAN_FALSE);
567 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700568 /* For now we will just use the 5GHz CB mode ini parameter to decide whether CB supported or not in Probes when there is no session
569 * Once session is established we will use the session related params stored in PE session for CB mode
570 */
571 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
573
574 //Update the operating mode to configured value during initialization,
575 //So that client can advertise full capabilities in Probe request frame.
576 csrSetDefaultDot11Mode( pMac );
577}
578
Jeff Johnson295189b2012-06-20 16:38:30 -0700579eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
580{
581 eHalStatus status = eHAL_STATUS_SUCCESS;
582 tANI_U32 i;
583 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 do
585 {
586 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
587 {
588 pSession = CSR_GET_SESSION( pMac, i );
589 pSession->roamingTimerInfo.pMac = pMac;
590 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
591 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700592 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
593 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
594 status = palTimerAlloc(pMac->hHdd, &pMac->roam.hTimerWaitForKey, csrRoamWaitForKeyTimeOutHandler,
595 &pMac->roam.WaitForKeyTimerInfo);
596 if(!HAL_STATUS_SUCCESS(status))
597 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800598 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 break;
600 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 status = palTimerAlloc(pMac->hHdd, &pMac->roam.tlStatsReqInfo.hTlStatsTimer, csrRoamTlStatsTimerHandler, pMac);
602 if(!HAL_STATUS_SUCCESS(status))
603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800604 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700605 return eHAL_STATUS_FAILURE;
606 }
607 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 return (status);
609}
610
Jeff Johnson295189b2012-06-20 16:38:30 -0700611eHalStatus csrRoamClose(tpAniSirGlobal pMac)
612{
613 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
615 {
616 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
617 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700618 palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey);
619 palTimerFree(pMac->hHdd, pMac->roam.hTimerWaitForKey);
Jeff Johnson295189b2012-06-20 16:38:30 -0700620 palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
621 palTimerFree(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700622 return (eHAL_STATUS_SUCCESS);
623}
624
Jeff Johnson295189b2012-06-20 16:38:30 -0700625eHalStatus csrRoamStart(tpAniSirGlobal pMac)
626{
627 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 return (eHAL_STATUS_SUCCESS);
629}
630
Jeff Johnson295189b2012-06-20 16:38:30 -0700631void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
632{
633 csrRoamStopRoamingTimer(pMac, sessionId);
634 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
635 csrRoamDeregStatisticsReq(pMac);
636}
Jeff Johnson295189b2012-06-20 16:38:30 -0700637eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
638{
639 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800640 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 {
642 status = eHAL_STATUS_SUCCESS;
643 *pState = pMac->roam.roamSession[sessionId].connectState;
644 }
645 return (status);
646}
647
Jeff Johnson295189b2012-06-20 16:38:30 -0700648eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
649{
650 eHalStatus status = eHAL_STATUS_FAILURE;
651 tANI_U32 size = 0;
652 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700653
654 if(!pSession)
655 {
656 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
657 return eHAL_STATUS_FAILURE;
658 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700659
660 if(pProfile)
661 {
662 if(pSession->pConnectBssDesc)
663 {
664 do
665 {
666 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
667 if(size)
668 {
669 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile->pBssDesc, size);
670 if(HAL_STATUS_SUCCESS(status))
671 {
672 palCopyMemory(pMac->hHdd, pProfile->pBssDesc, pSession->pConnectBssDesc, size);
673 }
674 else
675 break;
676 }
677 else
678 {
679 pProfile->pBssDesc = NULL;
680 }
681 pProfile->AuthType = pSession->connectedProfile.AuthType;
682 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
683 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
684 pProfile->BSSType = pSession->connectedProfile.BSSType;
685 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
686 pProfile->CBMode = pSession->connectedProfile.CBMode;
687 palCopyMemory(pMac->hHdd, &pProfile->bssid, &pSession->connectedProfile.bssid, sizeof(tCsrBssid));
688 palCopyMemory(pMac->hHdd, &pProfile->SSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
689#ifdef WLAN_FEATURE_VOWIFI_11R
690 if (pSession->connectedProfile.MDID.mdiePresent)
691 {
692 pProfile->MDID.mdiePresent = 1;
693 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
694 }
695 else
696 {
697 pProfile->MDID.mdiePresent = 0;
698 pProfile->MDID.mobilityDomain = 0;
699 }
700#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700701#ifdef FEATURE_WLAN_CCX
702 pProfile->isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 if (csrIsAuthTypeCCX(pSession->connectedProfile.AuthType))
704 {
705 palCopyMemory( pMac->hHdd, pProfile->ccxCckmInfo.krk,
706 pSession->connectedProfile.ccxCckmInfo.krk, CSR_KRK_KEY_LEN );
707 pProfile->ccxCckmInfo.reassoc_req_num=
708 pSession->connectedProfile.ccxCckmInfo.reassoc_req_num;
709 pProfile->ccxCckmInfo.krk_plumbed =
710 pSession->connectedProfile.ccxCckmInfo.krk_plumbed;
711 }
712#endif
713 }while(0);
714 }
715 }
716
717 return (status);
718}
719
Jeff Johnson295189b2012-06-20 16:38:30 -0700720eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
721{
722 eHalStatus status = eHAL_STATUS_FAILURE;
723
724 if(csrIsConnStateConnected(pMac, sessionId))
725 {
726 if(pProfile)
727 {
728 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
729 }
730 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 return (status);
732}
Jeff Johnson295189b2012-06-20 16:38:30 -0700733eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
734{
735 eHalStatus status = eHAL_STATUS_SUCCESS;
736
737 if(pProfile->pBssDesc)
738 {
739 palFreeMemory(pMac->hHdd, pProfile->pBssDesc);
740 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700741 if(pProfile->pAddIEAssoc)
742 {
743 palFreeMemory(pMac->hHdd, pProfile->pAddIEAssoc);
744 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamConnectedProfile));
746 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
747 return (status);
748}
749
Jeff Johnson295189b2012-06-20 16:38:30 -0700750static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
751{
752 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700753 if( pConnectedInfo->pbFrames )
754 {
755 palFreeMemory( pMac->hHdd, pConnectedInfo->pbFrames );
756 pConnectedInfo->pbFrames = NULL;
757 }
758 pConnectedInfo->nBeaconLength = 0;
759 pConnectedInfo->nAssocReqLength = 0;
760 pConnectedInfo->nAssocRspLength = 0;
761 pConnectedInfo->staId = 0;
762#ifdef WLAN_FEATURE_VOWIFI_11R
763 pConnectedInfo->nRICRspLength = 0;
764#endif
765#ifdef FEATURE_WLAN_CCX
766 pConnectedInfo->nTspecIeLength = 0;
767#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 return ( status );
769}
770
Jeff Johnson295189b2012-06-20 16:38:30 -0700771
772
Jeff Johnsone7245742012-09-05 17:12:55 -0700773
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700774void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
775{
776 csrReinitPreauthCmd(pMac, pCommand);
777 csrReleaseCommand( pMac, pCommand );
778}
779
Jeff Johnson295189b2012-06-20 16:38:30 -0700780void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
781{
782 csrReinitRoamCmd(pMac, pCommand);
783 csrReleaseCommand( pMac, pCommand );
784}
785
Jeff Johnson295189b2012-06-20 16:38:30 -0700786void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
787{
788 csrReinitScanCmd(pMac, pCommand);
789 csrReleaseCommand( pMac, pCommand );
790}
791
Jeff Johnson295189b2012-06-20 16:38:30 -0700792void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
793{
794 csrReinitWmStatusChangeCmd(pMac, pCommand);
795 csrReleaseCommand( pMac, pCommand );
796}
797
Jeff Johnson295189b2012-06-20 16:38:30 -0700798void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
799{
800 palZeroMemory(pMac->hHdd, &pCommand->u.setKeyCmd, sizeof(tSetKeyCmd));
801}
802
Jeff Johnson295189b2012-06-20 16:38:30 -0700803void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
804{
805 palZeroMemory(pMac->hHdd, &pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd));
806}
807
Jeff Johnson295189b2012-06-20 16:38:30 -0700808void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
809{
810 csrReinitSetKeyCmd(pMac, pCommand);
811 csrReleaseCommand( pMac, pCommand );
812}
Jeff Johnson295189b2012-06-20 16:38:30 -0700813void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
814{
815 csrReinitRemoveKeyCmd(pMac, pCommand);
816 csrReleaseCommand( pMac, pCommand );
817}
Jeff Johnson295189b2012-06-20 16:38:30 -0700818void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
819{
820
821 if( eSmeCsrCommandMask & pCommand->command )
822 {
823 switch (pCommand->command)
824 {
825 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800826 // We need to inform the requester before dropping the scan command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800827 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback 0x%X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700828 __func__, pCommand->u.scanCmd.reason, (unsigned int)pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700829 if (NULL != pCommand->u.scanCmd.callback)
830 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800831 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
833 }
834 csrReleaseCommandScan( pMac, pCommand );
835 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 case eSmeCommandRoam:
837 csrReleaseCommandRoam( pMac, pCommand );
838 break;
839
840 case eSmeCommandWmStatusChange:
841 csrReleaseCommandWmStatusChange( pMac, pCommand );
842 break;
843
844 case eSmeCommandSetKey:
845 csrReleaseCommandSetKey( pMac, pCommand );
846 break;
847
848 case eSmeCommandRemoveKey:
849 csrReleaseCommandRemoveKey( pMac, pCommand );
850 break;
851
852 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800853 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 csrReleaseCommand( pMac, pCommand );
855 break;
856 }
857 }
858}
859
Jeff Johnson295189b2012-06-20 16:38:30 -0700860void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
861{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800862 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]", NewSubstate, pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700863
Jeff Johnson295189b2012-06-20 16:38:30 -0700864 if(pMac->roam.curSubState[sessionId] == NewSubstate)
865 {
866 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700867 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 pMac->roam.curSubState[sessionId] = NewSubstate;
869}
870
Jeff Johnson295189b2012-06-20 16:38:30 -0700871eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
872{
873 eCsrRoamState PreviousState;
874
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800875 smsLog( pMac, LOG1, "CSR RoamState: [ %d <== %d ]", NewRoamState, pMac->roam.curState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700876
877 PreviousState = pMac->roam.curState[sessionId];
878
879 if ( NewRoamState != pMac->roam.curState[sessionId] )
880 {
881 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
882 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
883 {
884 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
885 }
886
887 pMac->roam.curState[sessionId] = NewRoamState;
888 }
889 return( PreviousState );
890}
891
Jeff Johnson295189b2012-06-20 16:38:30 -0700892void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_U8 catOffset)
893{
894 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 if(catOffset)
896 {
897 pMac->roam.configParam.bCatRssiOffset = catOffset;
898 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
899 {
900 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)CSR_BEST_RSSI_VALUE - (int)(i * catOffset);
901 }
902 }
903}
904
Jeff Johnson295189b2012-06-20 16:38:30 -0700905static void initConfigParam(tpAniSirGlobal pMac)
906{
907 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
909 pMac->roam.configParam.channelBondingMode24GHz = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
910 pMac->roam.configParam.channelBondingMode5GHz = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700911
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
913 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
914 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
915 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
916 pMac->roam.configParam.HeartbeatThresh24 = 40;
917 pMac->roam.configParam.HeartbeatThresh50 = 40;
918 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
919 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
920 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700921 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 pMac->roam.configParam.RTSThreshold = 2346;
923 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
924 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
925 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
926 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
927 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
928 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
929 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
930 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
931 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
932 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
933 {
934 pMac->roam.configParam.BssPreferValue[i] = i;
935 }
936 csrAssignRssiForCategory(pMac, CSR_DEFAULT_RSSI_DB_GAP);
937 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
938 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
939 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
941 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
942 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
943 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
944 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
945 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800946 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
947 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700948#ifdef WLAN_AP_STA_CONCURRENCY
949 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
950 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
951 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
952 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
953 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Vinay Malekal05fdc812012-12-17 13:04:30 -0800954 pMac->roam.configParam.nNumChanCombinedConc = CSR_NUM_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700955#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700956 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
957 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
958 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
959 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700960#ifdef WLAN_FEATURE_VOWIFI_11R
961 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
962#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700963#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
964 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
965 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
966 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
967 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
968 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
969 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
970 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
971 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
972 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
973 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
974 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -0800975 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700976#endif
Jeff Johnsone7245742012-09-05 17:12:55 -0700977#ifdef WLAN_FEATURE_11AC
978 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
979#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700980
981 pMac->roam.configParam.addTSWhenACMIsOff = 0;
982 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -0700983
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700984 //Remove this code once SLM_Sessionization is supported
985 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -0700986 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700987
Jeff Johnsone7245742012-09-05 17:12:55 -0700988}
Jeff Johnson295189b2012-06-20 16:38:30 -0700989eCsrBand csrGetCurrentBand(tHalHandle hHal)
990{
991 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
992 return pMac->roam.configParam.bandCapability;
993}
Srinivas Girigowdade697412013-02-14 16:31:48 -0800994
995#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
996tANI_BOOLEAN csrIsChannelInCountryValidList(tpAniSirGlobal pMac, tANI_U8 channel)
997{
998 /* Get country code from CFG */
999 tANI_U8 *pCountryCode = pMac->scan.countryCodeCurrent;
1000 tANI_U8 i = 0;
1001 v_BOOL_t retVal = FALSE;
1002 tANI_U8 *pCountryValidChannelList = pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
1003 tANI_U8 *pNumChannels = &pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
1004
1005 /* Compare against KR valid list */
1006 if ((0 == strncmp(pCountryCode, "KR", 2)) &&
1007 (NULL != pCountryValidChannelList))
1008 {
1009 for (i = 0; i <(*pNumChannels); i++)
1010 {
1011 if (channel == pCountryValidChannelList[i])
1012 {
1013 retVal = TRUE;
1014 break;
1015 }
1016 }
1017 }
1018 else
1019 {
1020 retVal = csrRoamIsChannelValid(pMac, channel);
1021 }
1022
1023 return retVal;
1024}
1025
1026void csr_SetRevision(tpAniSirGlobal pMac, tANI_U8 revision)
1027{
1028 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1029 pNeighborRoamInfo->cfgParams.countryChannelInfo.revision = revision;
1030}
1031
1032/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001033 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001034*/
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001035eHalStatus csrFlushBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001036{
1037 eHalStatus status = eHAL_STATUS_SUCCESS;
1038 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1039
1040 /* Free up the memory first (if required) */
1041 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1042 {
1043 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1044 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001045 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001046 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001047 return status;
1048}
1049
1050
1051
1052/*
1053 This function flushes the roam scan cache and creates fresh cache
1054 based on the input channel list
1055*/
1056eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1057 const tANI_U8 *pChannelList,
1058 const tANI_U8 numChannels)
1059{
1060 eHalStatus status = eHAL_STATUS_SUCCESS;
1061 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1062
Srinivas Girigowdade697412013-02-14 16:31:48 -08001063 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1064
1065 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1066 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1067
1068 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1069 {
1070 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1071 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1072 return eHAL_STATUS_RESOURCES;
1073 }
1074
1075 /* Update the roam global structure */
1076 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1077 pChannelList,
1078 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1079 return status;
1080}
1081
1082/* This function modifies the bgscan channel list set via config ini or
1083 runtime, whenever the band changes.
1084 if the band is auto, then no operation is performed on the channel list
1085 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1086 if the band is 5G, then make sure channel list contains only 5G valid channels
1087*/
1088eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1089 eCsrBand eBand)
1090{
1091 eHalStatus status = eHAL_STATUS_SUCCESS;
1092 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1093 tANI_U8 outNumChannels = 0;
1094 tANI_U8 inNumChannels = 0;
1095 tANI_U8 *inPtr = NULL;
1096 tANI_U8 i = 0;
1097 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1098
1099 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1100
1101 {
1102 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1103 "No update required for channel list "
1104 "either cfg.ini channel list is not set up or "
1105 "auto band (Band %d)", eBand);
1106 return status;
1107 }
1108
1109 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1110 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1111 if (eCSR_BAND_24 == eBand)
1112 {
1113 for (i = 0; i < inNumChannels; i++)
1114 {
1115 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrIsChannelInCountryValidList(pMac, inPtr[i]))
1116 {
1117 ChannelList[outNumChannels++] = inPtr[i];
1118 }
1119 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001120 csrFlushBgScanRoamChannelList(pMac);
1121 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001122 }
1123 else if (eCSR_BAND_5G == eBand)
1124 {
1125 for (i = 0; i < inNumChannels; i++)
1126 {
1127 /* Add 5G Non-DFS channel */
1128 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1129 csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1130 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1131 {
1132 ChannelList[outNumChannels++] = inPtr[i];
1133 }
1134 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001135 csrFlushBgScanRoamChannelList(pMac);
1136 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001137 }
1138 else if (eCSR_BAND_ALL == eBand)
1139 {
1140 for (i = 0; i < inNumChannels; i++)
1141 {
1142 if (csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1143 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1144 {
1145 ChannelList[outNumChannels++] = inPtr[i];
1146 }
1147 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001148 csrFlushBgScanRoamChannelList(pMac);
1149 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001150 }
1151 else
1152 {
1153 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1154 "Invalid band, No operation carried out (Band %d)", eBand);
1155 status = eHAL_STATUS_INVALID_PARAMETER;
1156 }
1157
1158 return status;
1159}
1160
1161/*
1162 This function initializes the valid channel list based on country code
1163*/
1164eHalStatus csrInitCountryValidChannelList(tpAniSirGlobal pMac,
1165 tANI_U8 Revision)
1166{
1167 eHalStatus status = eHAL_STATUS_SUCCESS;
1168 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001169 tANI_U8 **pOutChannelList = &pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001170 tANI_U8 *pNumChannels = &pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
1171 const tANI_U8 *pChannelList = NULL;
1172
1173 if (SME_KR_3 == Revision)
1174 {
1175 pChannelList = KR_3;
1176 *pNumChannels = sizeof(KR_3)/sizeof(KR_3[0]);
1177 }
1178 else if (SME_KR_24 == Revision)
1179 {
1180 pChannelList = KR_24;
1181 *pNumChannels = sizeof(KR_24)/sizeof(KR_24[0]);
1182 }
1183 else if (SME_KR_25 == Revision)
1184 {
1185 pChannelList = KR_25;
1186 *pNumChannels = sizeof(KR_25)/sizeof(KR_25[0]);
1187 }
1188 else
1189 return eHAL_STATUS_INVALID_PARAMETER;
1190
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001191 /* Free any existing channel list */
1192 vos_mem_free(*pOutChannelList);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001193
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001194 *pOutChannelList = vos_mem_malloc(*pNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001195
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001196 if (NULL == *pOutChannelList)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001197 {
1198 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1199 *pNumChannels = 0;
1200 return eHAL_STATUS_RESOURCES;
1201 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001202 /* Update the roam global structure */
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001203 palCopyMemory(pMac->hHdd, *pOutChannelList, pChannelList, *pNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001204 return status;
1205}
1206
1207#endif
1208
Jeff Johnson295189b2012-06-20 16:38:30 -07001209eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1210{
1211 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1212 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001213 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1214 (eBand == eCSR_BAND_24))
1215 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001216 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001217 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001218 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001219 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 pMac->roam.configParam.uCfgDot11Mode, eBand);
1221 return eHAL_STATUS_INVALID_PARAMETER;
1222 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1224 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1225 (eBand == eCSR_BAND_5G))
1226 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001227 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001229 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001230 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 pMac->roam.configParam.uCfgDot11Mode, eBand);
1232 return eHAL_STATUS_INVALID_PARAMETER;
1233 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001234 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001235 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001236 pMac->roam.configParam.eBand = eBand;
1237 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001238 csrScanGetSupportedChannels( pMac );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001239#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1240 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
1241#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 status = csrInitGetChannels( pMac );
1243 if (eHAL_STATUS_SUCCESS == status)
1244 csrInitChannelList( hHal );
1245 return status;
1246}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001247
1248
Jeff Johnsone7245742012-09-05 17:12:55 -07001249/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1250 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1251 * Ideally we should have kept the ini value and enum value same and representing the same
1252 * cb values as in 11n standard i.e.
1253 * Set to 1 (SCA) if the secondary channel is above the primary channel
1254 * Set to 3 (SCB) if the secondary channel is below the primary channel
1255 * Set to 0 (SCN) if no secondary channel is present
1256 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1257 * 0 - secondary none
1258 * 1 - secondary LOW
1259 * 2 - secondary HIGH
1260 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1261 * The enum values are as follows:
1262 * PHY_SINGLE_CHANNEL_CENTERED = 0
1263 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1264 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1265 */
1266ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1267{
1268
1269 ePhyChanBondState phyCbState;
1270 switch (cbIniValue) {
1271 // secondary none
1272 case 0:
1273 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1274 break;
1275 // secondary LOW
1276 case 1:
1277 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1278 break;
1279 // secondary HIGH
1280 case 2:
1281 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1282 break;
1283#ifdef WLAN_FEATURE_11AC
1284 case 3:
1285 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1286 break;
1287 case 4:
1288 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1289 break;
1290 case 5:
1291 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1292 break;
1293 case 6:
1294 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1295 break;
1296 case 7:
1297 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1298 break;
1299 case 8:
1300 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1301 break;
1302 case 9:
1303 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1304 break;
1305#endif
1306 default:
1307 // If an invalid value is passed, disable CHANNEL BONDING
1308 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1309 break;
1310 }
1311 return phyCbState;
1312}
1313
1314v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1315{
1316
1317 v_U32_t cbIniValue;
1318 switch (phyCbState) {
1319 // secondary none
1320 case PHY_SINGLE_CHANNEL_CENTERED:
1321 cbIniValue = 0;
1322 break;
1323 // secondary LOW
1324 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1325 cbIniValue = 1;
1326 break;
1327 // secondary HIGH
1328 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1329 cbIniValue = 2;
1330 break;
1331#ifdef WLAN_FEATURE_11AC
1332 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1333 cbIniValue = 3;
1334 break;
1335 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1336 cbIniValue = 4;
1337 break;
1338 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1339 cbIniValue = 5;
1340 break;
1341 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1342 cbIniValue = 6;
1343 break;
1344 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1345 cbIniValue = 7;
1346 break;
1347 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1348 cbIniValue = 8;
1349 break;
1350 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1351 cbIniValue = 9;
1352 break;
1353#endif
1354 default:
1355 // return some invalid value
1356 cbIniValue = 10;
1357 break;
1358 }
1359 return cbIniValue;
1360}
Jeff Johnson295189b2012-06-20 16:38:30 -07001361
1362eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1363{
1364 eHalStatus status = eHAL_STATUS_SUCCESS;
1365
1366 if(pParam)
1367 {
1368 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1369 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1370 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1371 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1372 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1373 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1374
1375 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001376 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1377
Jeff Johnsone7245742012-09-05 17:12:55 -07001378 /* channelBondingMode5GHz plays a dual role right now
1379 * INFRA STA will use this non zero value as CB enabled and SOFTAP will use this non-zero value to determine the secondary channel offset
1380 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1381 */
1382 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001384 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001385 }
1386 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1387 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1388 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001389 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001390 }
1391 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1393 pMac->roam.configParam.phyMode = pParam->phyMode;
1394 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1395 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1396 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1397 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1398 pMac->roam.configParam.TxRate = pParam->TxRate;
1399 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1400 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1401 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1402 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1403 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 //if HDD passed down non zero values then only update,
1405 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001406 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 {
1408 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1409 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001410 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001411 {
1412 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1413 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001414 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 {
1416 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1417 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001418 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001419 {
1420 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1421 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001422 if (pParam->nActiveMaxChnTimeBtc)
1423 {
1424 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1425 }
1426 if (pParam->nActiveMinChnTimeBtc)
1427 {
1428 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1429 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001430#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001431 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001432 {
1433 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1434 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001435 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001436 {
1437 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1438 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001439 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001440 {
1441 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1442 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001443 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001444 {
1445 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1446 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001447 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001448 {
1449 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1450 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001451 if (pParam->nNumChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001452 {
1453 pMac->roam.configParam.nNumChanCombinedConc = pParam->nNumChanCombinedConc;
1454 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001455#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001456 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001457 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 {
1459 //Change the unit from second to microsecond
1460 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1462 {
1463 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1464 }
1465 else
1466 {
1467 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1468 }
1469 }
1470 else
1471 {
1472 pMac->roam.configParam.impsSleepTime = 0;
1473 }
1474 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1476 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 //if HDD passed down non zero values for age params, then only update,
1478 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001479 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 {
1481 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001483 if(pParam->scanAgeTimeNCNPS)
1484 {
1485 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001487 if(pParam->scanAgeTimeNCPS)
1488 {
1489 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 if(pParam->scanAgeTimeCNPS)
1492 {
1493 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1494 }
1495 if(pParam->scanAgeTimeCPS)
1496 {
1497 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1498 }
1499
1500 csrAssignRssiForCategory(pMac, pParam->bCatRssiOffset);
1501 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1502 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1503 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1504 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1505 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001506 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1507 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1509 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1510 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1511 //Assign this before calling CsrInit11dInfo
1512 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 if( csrIs11dSupported( pMac ) )
1514 {
1515 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1516 }
1517 else
1518 {
1519 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1520 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001521
1522 /* Initialize the power + channel information if 11h is enabled.
1523 If 11d is enabled this information has already been initialized */
1524 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1525 {
1526 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1527 }
1528
1529
Jeff Johnson295189b2012-06-20 16:38:30 -07001530#ifdef WLAN_FEATURE_VOWIFI_11R
1531 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001532 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001533#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001534#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001536 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001537 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001538 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001539 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001540 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001541 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001542 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001543#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001544#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1545 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
1546#endif
1547#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001548 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
1549#endif
1550
Jeff Johnson295189b2012-06-20 16:38:30 -07001551#ifdef FEATURE_WLAN_CCX
1552 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1553#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001554#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1555 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.neighborRoamConfig, &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001556 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1557 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1558 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1559 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1560 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1561 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1562 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1563 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001564 {
1565 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001566 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07001567 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1568 {
1569 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1570 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001571 smsLog( pMac, LOG1, "");
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 }
1573#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1575 pMac->scan.fValidateList = pParam->fValidateList;
1576 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1577 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001578 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001580 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1581 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1582 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1583 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1584 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1585 * single session
1586 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001587 //Remove this code once SLM_Sessionization is supported
1588 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001589 pMac->roam.configParam.doBMPSWorkaround = 0;
1590
Jeff Johnsone7245742012-09-05 17:12:55 -07001591#ifdef WLAN_FEATURE_11AC
1592 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001593 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001594 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001595#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001596 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 }
1598
1599 return status;
1600}
1601
Jeff Johnson295189b2012-06-20 16:38:30 -07001602eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1603{
1604 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 if(pParam)
1606 {
1607 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1608 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1609 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1610 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1611 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1612 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001613 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1614 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1616 pParam->phyMode = pMac->roam.configParam.phyMode;
1617 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1618 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1619 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1620 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1621 pParam->TxRate = pMac->roam.configParam.TxRate;
1622 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1623 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1624 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1625 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1626 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1628 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1629 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1630 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001631#ifdef WLAN_AP_STA_CONCURRENCY
1632 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1633 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1634 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1635 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1636 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001637 pParam->nNumChanCombinedConc = pMac->roam.configParam.nNumChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001638#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001639 //Change the unit from microsecond to second
1640 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1641 pParam->eBand = pMac->roam.configParam.eBand;
1642 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1643 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1644 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1645 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1646 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1647 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1648 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1649 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1650 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1651 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1652 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1653 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1654 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1656 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1657 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1658 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1660 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1661 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1662 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1663 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001664 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001665 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001666 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001667 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001668
1669#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1670 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1671#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001672#ifdef WLAN_FEATURE_11AC
1673 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001674 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001675 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001676#endif
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001677 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 csrSetChannels(pMac, pParam);
1679
1680 status = eHAL_STATUS_SUCCESS;
1681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 return (status);
1683}
1684
Jeff Johnson295189b2012-06-20 16:38:30 -07001685eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1686{
1687 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1688 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1689 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1690 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 do
1692 {
1693 if(eCSR_BAND_24 == eBand)
1694 {
1695 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1696 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1697 }
1698 if(eCSR_BAND_5G == eBand)
1699 {
1700 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1701 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1702 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1703 )
1704 {
1705 break;
1706 }
1707 }
1708 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1709 {
1710 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1711 }
1712 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1713 {
1714 newPhyMode = eCSR_DOT11_MODE_AUTO;
1715 }
1716 else
1717 {
1718 //Check for dual band and higher capability first
1719 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1720 {
1721 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1722 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1723 }
1724 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1725 {
1726 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1727 if(eCSR_BAND_24 == eBand) break;
1728 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1729 eBand = eCSR_BAND_5G;
1730 }
1731 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1732 {
1733 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1734 if(eCSR_BAND_5G == eBand) break;
1735 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1736 eBand = eCSR_BAND_24;
1737 }
1738 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1739 {
1740 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1741 if(eCSR_BAND_5G == eBand) break;
1742 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1743 eBand = eCSR_BAND_24;
1744 }
1745 else if(eCSR_DOT11_MODE_11n & phyMode)
1746 {
1747 newPhyMode = eCSR_DOT11_MODE_11n;
1748 }
1749 else if(eCSR_DOT11_MODE_abg & phyMode)
1750 {
1751 newPhyMode = eCSR_DOT11_MODE_abg;
1752 }
1753 else if(eCSR_DOT11_MODE_11a & phyMode)
1754 {
1755 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1756 {
1757 if(eCSR_BAND_ALL == eBand)
1758 {
1759 newPhyMode = eCSR_DOT11_MODE_abg;
1760 }
1761 else
1762 {
1763 //bad setting
1764 break;
1765 }
1766 }
1767 else
1768 {
1769 newPhyMode = eCSR_DOT11_MODE_11a;
1770 eBand = eCSR_BAND_5G;
1771 }
1772 }
1773 else if(eCSR_DOT11_MODE_11g & phyMode)
1774 {
1775 newPhyMode = eCSR_DOT11_MODE_11g;
1776 eBand = eCSR_BAND_24;
1777 }
1778 else if(eCSR_DOT11_MODE_11b & phyMode)
1779 {
1780 newPhyMode = eCSR_DOT11_MODE_11b;
1781 eBand = eCSR_BAND_24;
1782 }
1783 else
1784 {
1785 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001786 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 newPhyMode = eCSR_DOT11_MODE_AUTO;
1788 }
1789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 //Done validating
1791 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 //Now we need to check whether a restart is needed.
1793 if(eBand != pMac->roam.configParam.eBand)
1794 {
1795 fRestartNeeded = eANI_BOOLEAN_TRUE;
1796 break;
1797 }
1798 if(newPhyMode != pMac->roam.configParam.phyMode)
1799 {
1800 fRestartNeeded = eANI_BOOLEAN_TRUE;
1801 break;
1802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 if(HAL_STATUS_SUCCESS(status))
1805 {
1806 pMac->roam.configParam.eBand = eBand;
1807 pMac->roam.configParam.phyMode = newPhyMode;
1808 if(pfRestartNeeded)
1809 {
1810 *pfRestartNeeded = fRestartNeeded;
1811 }
1812 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001813 return (status);
1814}
1815
Jeff Johnson295189b2012-06-20 16:38:30 -07001816void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
1817{
1818 tANI_U8 Index;
1819 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 // for dual band NICs, don't need to trim the channel list....
1821 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
1822 {
1823 // 2.4 GHz band operation requires the channel list to be trimmed to
1824 // the 2.4 GHz channels only...
1825 if ( CSR_IS_24_BAND_ONLY( pMac ) )
1826 {
1827 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
1828 Index++ )
1829 {
1830 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
1831 {
1832 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1833 cChannels++;
1834 }
1835 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1837 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1838 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1839 // only if we need to.
1840 //
1841 // The amount of memory to clear is the number of channesl that we trimmed
1842 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1843
1844 if ( pChannelList->numChannels > cChannels )
1845 {
1846 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1847 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1848
1849 }
1850
1851 pChannelList->numChannels = cChannels;
1852 }
1853 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
1854 {
1855 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
1856 {
1857 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
1858 {
1859 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1860 cChannels++;
1861 }
1862 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1864 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1865 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1866 // only if we need to.
1867 //
1868 // The amount of memory to clear is the number of channesl that we trimmed
1869 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1870 if ( pChannelList->numChannels > cChannels )
1871 {
1872 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1873 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1874 }
1875
1876 pChannelList->numChannels = cChannels;
1877 }
1878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001879}
Jeff Johnson295189b2012-06-20 16:38:30 -07001880#define INFRA_AP_DEFAULT_CHANNEL 6
1881eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
1882{
1883 tANI_U8 index= 0;
1884 eHalStatus status = eHAL_STATUS_FAILURE;
1885 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
1886 {
1887 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
1888 status = eHAL_STATUS_SUCCESS;
1889 break;
1890 }
1891 }
1892 return status;
1893}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001894
1895eHalStatus csrGet5GChannels(tpAniSirGlobal pMac)
1896{
1897 eHalStatus status = eHAL_STATUS_SUCCESS;
1898 tANI_U8 num20MHzChannelsFound = 0;
1899 VOS_STATUS vosStatus;
1900 tANI_U8 num40MHzChannelsFound = 0;
1901 tANI_U8 Index = 0;
1902 tANI_U8 channelList = 0;
1903
1904 // Updating the defaultpower Table for changed Domain Id
1905 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1906 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1907
1908 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1909 {
1910 smsLog( pMac, LOGE, FL("failed to get channels"));
1911 status = eHAL_STATUS_FAILURE;
1912 }
1913 else
1914 {
1915 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1916 {
1917 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1918 }
1919
1920 // Move the only 5GHZ channel list to the global data,
1921 // As 2.4GHZ list coming from the AP for the changed domain
1922 // structure -- this will be used as the scan list
1923 for(channelList = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1924 {
1925 // If Channel is 5GHz just break the for loop
1926 if(!(pMac->scan.base20MHzChannels.channelList[ channelList ] > 0 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 14))
1927 break;
1928 }
1929 // Update the 5G channels from nv.bin
1930 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1931 {
1932 if(pMac->scan.defaultPowerTable[Index].chanId >= 36 && pMac->scan.defaultPowerTable[Index].chanId <= 165)
1933 {
1934 pMac->scan.base20MHzChannels.channelList[ channelList ] = pMac->scan.defaultPowerTable[Index].chanId;
1935 channelList++;
1936 }
1937 }
1938
1939 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1940 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1941 // Filling the remaining index as Zero Just for causion
1942 for(Index = pMac->scan.base20MHzChannels.numChannels; Index < WNI_CFG_VALID_CHANNEL_LIST_LEN; Index++)
1943 pMac->scan.base20MHzChannels.channelList[ Index ] = 0;
1944 }
1945 return status;
1946}
1947
1948eHalStatus csrGet24GChannels(tpAniSirGlobal pMac)
1949{
1950 eHalStatus status = eHAL_STATUS_SUCCESS;
1951 tANI_U8 num20MHzChannelsFound = 0;
1952 VOS_STATUS vosStatus;
1953 tANI_U8 Index = 0;
1954 tANI_U8 num40MHzChannelsFound = 0;
1955 tANI_U8 channelList5GBackup[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}, nuum5GchannelListBackup;
1956 tANI_U8 channelList = 0;
1957
1958 // Read the scan channel list (including the power limit) from EEPROM
1959 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1960 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1961
1962 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1963 {
1964 smsLog( pMac, LOGE, FL("failed to get channels \n"));
1965 status = eHAL_STATUS_FAILURE;
1966 }
1967 else
1968 {
1969 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1970 {
1971 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1972 }
1973
1974 // Move the 2.4GHZ channel list only to the global data,
1975 // As 5GHz list been provided by AP as part of 11d IE
1976 // structure -- this will be used as the scan list
1977 for(channelList = 0, nuum5GchannelListBackup = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1978 {
1979 if(pMac->scan.base20MHzChannels.channelList[ channelList ] >= 36 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 165)
1980 {
1981 // First taking the 5GHz channel list backup
1982 channelList5GBackup[nuum5GchannelListBackup] = pMac->scan.base20MHzChannels.channelList[ channelList ];
1983 nuum5GchannelListBackup++;
1984 }
1985 }
1986 // Updating the 2.4GHz list
1987 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1988 {
1989 if(pMac->scan.defaultPowerTable[Index].chanId > 0 && pMac->scan.defaultPowerTable[Index].chanId <= 14)
1990 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[Index].chanId;
1991 }
1992 // Restoring the Backed up 5 GHZ channels
1993 for(channelList = 0;channelList < nuum5GchannelListBackup; channelList++ )
1994 {
1995 pMac->scan.base20MHzChannels.channelList[ Index ] = channelList5GBackup[channelList];
1996 Index++;
1997 }
1998
1999 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > Index) ? num20MHzChannelsFound : Index;
2000 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > Index) ? num20MHzChannelsFound : Index;
2001 }
2002 return (status);
2003}
2004
Jeff Johnson295189b2012-06-20 16:38:30 -07002005eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2006{
2007 eHalStatus status = eHAL_STATUS_SUCCESS;
2008 tANI_U8 num20MHzChannelsFound = 0;
2009 VOS_STATUS vosStatus;
2010 tANI_U8 Index = 0;
2011 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002012
Jeff Johnson295189b2012-06-20 16:38:30 -07002013
2014 //TODO: this interface changed to include the 40MHz channel list
2015 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2016 // Read the scan channel list (including the power limit) from EEPROM
2017 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2018 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2019 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002021 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002022 status = eHAL_STATUS_FAILURE;
2023 }
2024 else
2025 {
2026 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2027 {
2028 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2029 }
2030 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2031 // Move the channel list to the global data
2032 // structure -- this will be used as the scan list
2033 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2034 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002035 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 }
2037 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2038 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2039 {
2040 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2041 }
2042 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2043 {
2044 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2045 }
2046 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002048 return (status);
2049}
2050
Jeff Johnson295189b2012-06-20 16:38:30 -07002051eHalStatus csrInitChannelList( tHalHandle hHal )
2052{
2053 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2054 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2056 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002057 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2058 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002060 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002061
2062 return (status);
2063}
Jeff Johnson295189b2012-06-20 16:38:30 -07002064eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2065 tCsrUpdateConfigParam *pUpdateConfigParam)
2066{
2067 eHalStatus status = eHAL_STATUS_FAILURE;
2068 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2070 status = CsrInit11dInfo(pMac, ps11dinfo);
2071 return status;
2072}
2073
Jeff Johnson295189b2012-06-20 16:38:30 -07002074static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2075{
2076 eHalStatus status = eHAL_STATUS_FAILURE;
2077 tANI_U8 index;
2078 tANI_U32 count=0;
2079 tSirMacChanInfo *pChanInfo;
2080 tSirMacChanInfo *pChanInfoStart;
2081 tANI_BOOLEAN applyConfig = TRUE;
2082
2083 if(!ps11dinfo)
2084 {
2085 return (status);
2086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2088 {
2089 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2090 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
2091 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
2092 if(!HAL_STATUS_SUCCESS(status)) return (status);
2093 }
2094 else
2095 {
2096 //No change
2097 return (eHAL_STATUS_SUCCESS);
2098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 //legacy maintenance
2100 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
2101 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2102 if(!HAL_STATUS_SUCCESS(status)) return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 //Tush: at csropen get this initialized with default, during csr reset if this
2104 // already set with some value no need initilaize with default again
2105 if(0 == pMac->scan.countryCodeCurrent[0])
2106 {
2107 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
2108 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2109 if(!HAL_STATUS_SUCCESS(status)) return (status);
2110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002111 // need to add the max power channel list
2112 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2113 {
2114 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2115 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002116 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2117 {
2118 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2119 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2120 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2121 pChanInfo++;
2122 count++;
2123 }
2124 if(count)
2125 {
2126 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2127 }
2128 palFreeMemory(pMac->hHdd, pChanInfoStart);
2129 }
2130 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2131 if( HAL_STATUS_SUCCESS(status) )
2132 {
2133 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2134 {
2135 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2136 {
2137 applyConfig = FALSE;
2138 }
2139 }
2140
2141 if(TRUE == applyConfig)
2142 {
2143 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002144 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002145 }
2146
2147 }
2148 return (status);
2149}
2150/* Initialize the Channel + Power List in the local cache and in the CFG */
2151eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2152{
2153 tANI_U8 index;
2154 tANI_U32 count=0;
2155 tSirMacChanInfo *pChanInfo;
2156 tSirMacChanInfo *pChanInfoStart;
2157
2158 if(!ps11dinfo || !pMac)
2159 {
2160 return eHAL_STATUS_FAILURE;
2161 }
2162
2163 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2164 {
2165 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2166 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002167
2168 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2169 {
2170 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2171 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2172 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2173 pChanInfo++;
2174 count++;
2175 }
2176 if(count)
2177 {
2178 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2179 }
2180 palFreeMemory(pMac->hHdd, pChanInfoStart);
2181 }
2182
Jeff Johnsone7245742012-09-05 17:12:55 -07002183 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002184}
2185
2186//pCommand may be NULL
2187//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2188void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2189{
2190 tListElem *pEntry, *pNextEntry;
2191 tSmeCmd *pDupCommand;
2192 tDblLinkList localList;
2193
2194 vos_mem_zero(&localList, sizeof(tDblLinkList));
2195 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2196 {
2197 smsLog(pMac, LOGE, FL(" failed to open list"));
2198 return;
2199 }
2200 csrLLLock( &pMac->sme.smeCmdPendingList );
2201 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2202 while( pEntry )
2203 {
2204 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2205 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 // Remove the previous command if..
2207 // - the new roam command is for the same RoamReason...
2208 // - the new roam command is a NewProfileList.
2209 // - the new roam command is a Forced Dissoc
2210 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2211 if (
2212 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2213 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002214 /* This peermac check is requried for Softap/GO scenarios
2215 * For STA scenario below OR check will suffice as pCommand will
2216 * always be NULL for STA scenarios
2217 */
2218 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2220 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2221 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2222 ||
2223 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002224 ( (sessionId == pDupCommand->sessionId) &&
2225 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 ((eCsrForcedDisassoc == eRoamReason) ||
2227 (eCsrHddIssued == eRoamReason))
2228 )
2229 )
2230 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002231 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 // Remove the 'stale' roam command from the pending list...
2233 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2234 {
2235 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2236 }
2237 }
2238 pEntry = pNextEntry;
2239 }
2240 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2241
2242 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2243 {
2244 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2245 //Tell caller that the command is cancelled
2246 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2247 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2248 csrReleaseCommandRoam(pMac, pDupCommand);
2249 }
2250 csrLLClose(&localList);
2251}
Jeff Johnson295189b2012-06-20 16:38:30 -07002252eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2253 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2254{
2255 eHalStatus status = eHAL_STATUS_SUCCESS;
2256#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2257 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2258#endif
2259 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2261 {
2262 pSession = CSR_GET_SESSION( pMac, sessionId );
2263 }
2264 else
2265 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002266 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002267 VOS_ASSERT(0);
2268 return eHAL_STATUS_FAILURE;
2269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002270 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2271 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002272 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002274 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2275 /*
2276 * Decrement bRefAssocStartCnt for FT reassoc failure.
2277 * Reason: For FT reassoc failures, we first call
2278 * csrRoamCallCallback before notifying a failed roam
2279 * completion through csrRoamComplete. The latter in
2280 * turn calls csrRoamProcessResults which tries to
2281 * once again call csrRoamCallCallback if bRefAssocStartCnt
2282 * is non-zero. Since this is redundant for FT reassoc
2283 * failure, decrement bRefAssocStartCnt.
2284 */
2285 pSession->bRefAssocStartCnt--;
2286 }
2287
Jeff Johnson295189b2012-06-20 16:38:30 -07002288 if ( (pSession == NULL) ||
2289 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2290 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002291 smsLog(pMac, LOG1, "Session ID is not valid");
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 return eHAL_STATUS_FAILURE;
2293 }
2294
2295 if(NULL != pSession->callback)
2296 {
2297 if( pRoamInfo )
2298 {
2299 pRoamInfo->sessionId = (tANI_U8)sessionId;
2300 }
2301
2302 /* avoid holding the global lock when making the roaming callback , original change came
2303 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2304 is possible on other OS ports where the callback may need to take locks to protect
2305 HDD state
2306 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2307 that may actually depend on the lock being held */
2308 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2309 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2310 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2311 }
2312 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2313 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2314#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2315 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
2316 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2317 {
2318 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2319 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2320 if(NULL != pRoamInfo->pBssDesc)
2321 {
2322 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2323 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2324 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2326 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2327 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
2328 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2329 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2330 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2333 {
2334 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2335 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2336 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002338 if(eCSR_ROAM_RESULT_FORCED == u2)
2339 {
2340 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2341 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2342 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002344 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2345 {
2346 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2347 connectionStatus.reason = eCSR_REASON_DISASSOC;
2348 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2349 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2351 {
2352 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2353 connectionStatus.reason = eCSR_REASON_DEAUTH;
2354 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002356#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2357
2358 return (status);
2359}
Jeff Johnson295189b2012-06-20 16:38:30 -07002360// Returns whether handoff is currently in progress or not
2361tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2362{
2363#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2364 return csrNeighborRoamIsHandoffInProgress(pMac);
2365#else
2366 return eANI_BOOLEAN_FALSE;
2367#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002368}
Jeff Johnson295189b2012-06-20 16:38:30 -07002369eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2370 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2371{
2372 eHalStatus status = eHAL_STATUS_SUCCESS;
2373 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2374 tANI_U16 reasonCode;
2375 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002376
2377 if(!pSession)
2378 {
2379 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2380 return eHAL_STATUS_FAILURE;
2381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002382
2383 //Restore AC weight in case we change it
2384 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2385 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002386 smsLog(pMac, LOG1, FL(" restore AC weights (%d-%d-%d-%d)"), pMac->roam.ucACWeights[0], pMac->roam.ucACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2388 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2389 }
2390
2391 if ( fMICFailure )
2392 {
2393 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2394 }
2395 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2396 {
2397 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002398 }
2399 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 {
2401 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002403#ifdef WLAN_FEATURE_VOWIFI_11R
2404 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2405 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2406 {
2407 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2408 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002409 }
2410 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002411#endif
2412 if(pSession->pConnectBssDesc)
2413 {
2414 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2415 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002416
Jeff Johnson295189b2012-06-20 16:38:30 -07002417
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002418 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2419 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2420 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2421
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2423
2424 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2425
2426 if(HAL_STATUS_SUCCESS(status))
2427 {
2428 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002429#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2430 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2431 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2432 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002433 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2435 }
2436#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002437 }
2438 else
2439 {
2440 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2441 }
2442
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 return (status);
2444}
Jeff Johnson295189b2012-06-20 16:38:30 -07002445
Jeff Johnson295189b2012-06-20 16:38:30 -07002446/* ---------------------------------------------------------------------------
2447 \fn csrRoamIssueDisassociateStaCmd
2448 \brief csr function that HDD calls to disassociate a associated station
2449 \param sessionId - session Id for Soft AP
2450 \param pPeerMacAddr - MAC of associated station to delete
2451 \param reason - reason code, be one of the tSirMacReasonCodes
2452 \return eHalStatus
2453 ---------------------------------------------------------------------------*/
2454eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2455 tANI_U32 sessionId,
2456 tANI_U8 *pPeerMacAddr,
2457 tANI_U32 reason)
2458{
2459 eHalStatus status = eHAL_STATUS_SUCCESS;
2460 tSmeCmd *pCommand;
2461
2462 do
2463 {
2464 pCommand = csrGetCommandBuffer( pMac );
2465 if ( !pCommand )
2466 {
2467 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2468 status = eHAL_STATUS_RESOURCES;
2469 break;
2470 }
2471 pCommand->command = eSmeCommandRoam;
2472 pCommand->sessionId = (tANI_U8)sessionId;
2473 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2474 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2475 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2476 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2477 if( !HAL_STATUS_SUCCESS( status ) )
2478 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002479 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 csrReleaseCommandRoam( pMac, pCommand );
2481 }
2482 }while(0);
2483
2484 return status;
2485}
2486
2487
Jeff Johnson295189b2012-06-20 16:38:30 -07002488/* ---------------------------------------------------------------------------
2489 \fn csrRoamIssueDeauthSta
2490 \brief csr function that HDD calls to delete a associated station
2491 \param sessionId - session Id for Soft AP
2492 \param pPeerMacAddr - MAC of associated station to delete
2493 \param reason - reason code, be one of the tSirMacReasonCodes
2494 \return eHalStatus
2495 ---------------------------------------------------------------------------*/
2496eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2497 tANI_U32 sessionId,
2498 tANI_U8 *pPeerMacAddr,
2499 tANI_U32 reason)
2500{
2501 eHalStatus status = eHAL_STATUS_SUCCESS;
2502 tSmeCmd *pCommand;
2503
2504 do
2505 {
2506 pCommand = csrGetCommandBuffer( pMac );
2507 if ( !pCommand )
2508 {
2509 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2510 status = eHAL_STATUS_RESOURCES;
2511 break;
2512 }
2513 pCommand->command = eSmeCommandRoam;
2514 pCommand->sessionId = (tANI_U8)sessionId;
2515 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2516 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2517 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2518 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2519 if( !HAL_STATUS_SUCCESS( status ) )
2520 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002521 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 csrReleaseCommandRoam( pMac, pCommand );
2523 }
2524 }while(0);
2525
2526 return status;
2527}
Jeff Johnson295189b2012-06-20 16:38:30 -07002528eHalStatus
2529csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2530 tANI_BOOLEAN bEnable )
2531{
2532 eHalStatus status = eHAL_STATUS_FAILURE;
2533 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2534 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 if (!pSession)
2536 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002537 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 return (status);
2539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002540 if (pSession->pConnectBssDesc)
2541 {
2542 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2543 }
2544 else
2545 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002546 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002547 return (status);
2548 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002549 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = %02x-%02x-%02x-%02x-%02x-%02x, Enable = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2551 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] , bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2553 return (status);
2554}
Jeff Johnson295189b2012-06-20 16:38:30 -07002555eHalStatus
2556csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2557 VOS_MODULE_ID modId, void *pUsrContext,
2558 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2559{
2560 eHalStatus status = eHAL_STATUS_SUCCESS;
2561 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2562 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 if (!pSession)
2564 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002565 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 return (status);
2567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 if(pSession->pConnectBssDesc)
2569 {
2570 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2571 }
2572 else
2573 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002574 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 return (status);
2576 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002577 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2579 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2581 return (status);
2582}
Jeff Johnson295189b2012-06-20 16:38:30 -07002583eHalStatus
2584csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2585 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2586{
2587 eHalStatus status = eHAL_STATUS_SUCCESS;
2588 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2589 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2590
2591 if (!pSession)
2592 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002593 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 return (status);
2595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 if(pSession->pConnectBssDesc)
2597 {
2598 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2599 }
2600 else
2601 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002602 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 return (status);
2604 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002605 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2607 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2608
2609 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2610
2611 return (status);
2612}
Jeff Johnson295189b2012-06-20 16:38:30 -07002613eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2614{
2615 eHalStatus status = eHAL_STATUS_SUCCESS;
2616 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2617 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002618
2619 if (!pSession)
2620 {
2621 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2622 return eHAL_STATUS_FAILURE;
2623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002624
2625 if(pSession->pConnectBssDesc)
2626 {
2627 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2628 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002629 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2631 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2633
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302634 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002635 if(!HAL_STATUS_SUCCESS(status))
2636 {
2637 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2638 }
2639
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 return (status);
2641}
2642
Jeff Johnson295189b2012-06-20 16:38:30 -07002643eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2644{
2645 eHalStatus status = eHAL_STATUS_SUCCESS;
2646 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2647 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002648
2649 if(!pSession)
2650 {
2651 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2652 return eHAL_STATUS_FAILURE;
2653 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002654
2655 // If no BSS description was found in this connection (happens with start IBSS), then
2656 // nix the BSS description that we keep around for the connected BSS) and get out...
2657 if(NULL == pBssDesc)
2658 {
2659 csrFreeConnectBssDesc(pMac, sessionId);
2660 }
2661 else
2662 {
2663 size = pBssDesc->length + sizeof( pBssDesc->length );
2664 if(NULL != pSession->pConnectBssDesc)
2665 {
2666 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2667 {
2668 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2669 csrFreeConnectBssDesc(pMac, sessionId);
2670 }
2671 }
2672 if(NULL == pSession->pConnectBssDesc)
2673 {
2674 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2675 }
2676 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2677 {
2678 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2679 }
2680 }
2681
2682 return (status);
2683}
2684
Jeff Johnson295189b2012-06-20 16:38:30 -07002685eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2686 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2687 tDot11fBeaconIEs *pIes)
2688{
2689 eHalStatus status = eHAL_STATUS_SUCCESS;
2690 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302692 if (pIes == NULL)
2693 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002694
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 do
2696 {
2697 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2698 //get qos
2699 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2700 //get SSID
2701 if(pIes->SSID.present)
2702 {
2703 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2704 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2705 }
2706 else
2707 pBssConfig->SSID.length = 0;
2708 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2709 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002710 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 //Return failed if profile doesn't have an SSID either.
2712 if(pProfile->SSIDs.numOfSSIDs == 0)
2713 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002714 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 status = eHAL_STATUS_FAILURE;
2716 break;
2717 }
2718 }
2719 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2720 {
2721 pBssConfig->eBand = eCSR_BAND_5G;
2722 }
2723 else
2724 {
2725 pBssConfig->eBand = eCSR_BAND_24;
2726 }
2727 //phymode
2728 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2729 {
2730 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2731 }
2732 else
2733 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002734 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 //force it
2736 if(eCSR_BAND_24 == pBssConfig->eBand)
2737 {
2738 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2739 }
2740 else
2741 {
2742 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2743 }
2744 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 //Qos
2746 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2747 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2748 {
2749 //Joining BSS is not 11n capable and WMM is disabled on client.
2750 //Disable QoS and WMM
2751 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2752 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302753
2754 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302755 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302756 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2757 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2758 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2759 {
2760 //Joining BSS is 11n capable and WMM is disabled on AP.
2761 //Assume all HT AP's are QOS AP's and enable WMM
2762 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2763 }
2764
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 //auth type
2766 switch( pProfile->negotiatedAuthType )
2767 {
2768 default:
2769 case eCSR_AUTH_TYPE_WPA:
2770 case eCSR_AUTH_TYPE_WPA_PSK:
2771 case eCSR_AUTH_TYPE_WPA_NONE:
2772 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2773 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2774 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 case eCSR_AUTH_TYPE_SHARED_KEY:
2776 pBssConfig->authType = eSIR_SHARED_KEY;
2777 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002778 case eCSR_AUTH_TYPE_AUTOSWITCH:
2779 pBssConfig->authType = eSIR_AUTO_SWITCH;
2780 break;
2781 }
2782 //short slot time
2783 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2784 {
2785 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2786 }
2787 else
2788 {
2789 pBssConfig->uShortSlotTime = 0;
2790 }
2791 if(pBssConfig->BssCap.ibss)
2792 {
2793 //We don't support 11h on IBSS
2794 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2795 }
2796 else
2797 {
2798 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2799 }
2800 //power constraint
2801 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2802 //heartbeat
2803 if ( CSR_IS_11A_BSS( pBssDesc ) )
2804 {
2805 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2806 }
2807 else
2808 {
2809 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2810 }
2811 //Join timeout
2812 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002813 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 if ( pBssDesc->beaconInterval )
2815 {
2816 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002817 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 }
2819 else
2820 {
2821 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2822 }
2823 //validate CB
2824 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2825 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 return (status);
2827}
2828
Jeff Johnson295189b2012-06-20 16:38:30 -07002829static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2830 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2831{
2832 eHalStatus status = eHAL_STATUS_SUCCESS;
2833 tANI_U8 operationChannel = 0;
2834 tANI_U8 qAPisEnabled = FALSE;
2835 //SSID
2836 pBssConfig->SSID.length = 0;
2837 if(pProfile->SSIDs.numOfSSIDs)
2838 {
2839 //only use the first one
2840 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2841 }
2842 else
2843 {
2844 //SSID must present
2845 return eHAL_STATUS_FAILURE;
2846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 //Settomg up the capabilities
2848 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2849 {
2850 pBssConfig->BssCap.ibss = 1;
2851 }
2852 else
2853 {
2854 pBssConfig->BssCap.ess = 1;
2855 }
2856 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2857 {
2858 pBssConfig->BssCap.privacy = 1;
2859 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 pBssConfig->eBand = pMac->roam.configParam.eBand;
2861 //phymode
2862 if(pProfile->ChannelInfo.ChannelList)
2863 {
2864 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2865 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2867 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 //QOS
2869 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 if ( pBssConfig->BssCap.ess == 1 )
2871 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 /*For Softap case enable WMM*/
2873 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2874 qAPisEnabled = TRUE;
2875 }
2876 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2878 qAPisEnabled = TRUE;
2879 } else {
2880 qAPisEnabled = FALSE;
2881 }
2882 } else {
2883 qAPisEnabled = TRUE;
2884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2886 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2887 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2888 )
2889 {
2890 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2891 } else {
2892 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2893 }
2894
2895 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08002896 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 {
2898 default:
2899 case eCSR_AUTH_TYPE_WPA:
2900 case eCSR_AUTH_TYPE_WPA_PSK:
2901 case eCSR_AUTH_TYPE_WPA_NONE:
2902 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2903 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2904 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 case eCSR_AUTH_TYPE_SHARED_KEY:
2906 pBssConfig->authType = eSIR_SHARED_KEY;
2907 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 case eCSR_AUTH_TYPE_AUTOSWITCH:
2909 pBssConfig->authType = eSIR_AUTO_SWITCH;
2910 break;
2911 }
2912 //short slot time
2913 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
2914 {
2915 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2916 }
2917 else
2918 {
2919 pBssConfig->uShortSlotTime = 0;
2920 }
2921 //power constraint. We don't support 11h on IBSS
2922 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2923 pBssConfig->uPowerLimit = 0;
2924 //heartbeat
2925 if ( eCSR_BAND_5G == pBssConfig->eBand )
2926 {
2927 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2928 }
2929 else
2930 {
2931 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2932 }
2933 //Join timeout
2934 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002935
Jeff Johnson295189b2012-06-20 16:38:30 -07002936 return (status);
2937}
Jeff Johnson295189b2012-06-20 16:38:30 -07002938static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
2939{
2940 eHalStatus status = eHAL_STATUS_FAILURE;
2941 tDot11fBeaconIEs *pIes = NULL;
2942
2943 do
2944 {
2945 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
2946 {
2947 //err msg
2948 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002949 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 break;
2951 }
2952 //check if the AP is QAP & it supports APSD
2953 if( CSR_IS_QOS_BSS(pIes) )
2954 {
2955 return eHAL_STATUS_SUCCESS;
2956 }
2957 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 return status;
2959}
2960
Jeff Johnson295189b2012-06-20 16:38:30 -07002961void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
2962{
Jeff Johnson295189b2012-06-20 16:38:30 -07002963 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
2964 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
2965 // See !!Note: below in this function...
2966 tANI_U32 PrivacyEnabled = 0;
2967 tANI_U32 RsnEnabled = 0;
2968 tANI_U32 WepDefaultKeyId = 0;
2969 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
2970 tANI_U32 Key0Length = 0;
2971 tANI_U32 Key1Length = 0;
2972 tANI_U32 Key2Length = 0;
2973 tANI_U32 Key3Length = 0;
2974
2975 // Reserve for the biggest key
2976 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
2977 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
2978 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
2979 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
2980
2981 switch ( pProfile->negotiatedUCEncryptionType )
2982 {
2983 case eCSR_ENCRYPT_TYPE_NONE:
2984
2985 // for NO encryption, turn off Privacy and Rsn.
2986 PrivacyEnabled = 0;
2987 RsnEnabled = 0;
2988
2989 // WEP key length and Wep Default Key ID don't matter in this case....
2990
2991 // clear out the WEP keys that may be hanging around.
2992 Key0Length = 0;
2993 Key1Length = 0;
2994 Key2Length = 0;
2995 Key3Length = 0;
2996
2997 break;
2998
2999 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3000
3001 // Privacy is ON. NO RSN for Wep40 static key.
3002 PrivacyEnabled = 1;
3003 RsnEnabled = 0;
3004
3005 // Set the Wep default key ID.
3006 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 // Wep key size if 5 bytes (40 bits).
3008 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3009
3010 // set encryption keys in the CFG database or clear those that are not present in this profile.
3011 if ( pProfile->Keys.KeyLength[0] )
3012 {
3013 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
3014 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3015 }
3016 else
3017 {
3018 Key0Length = 0;
3019 }
3020
3021 if ( pProfile->Keys.KeyLength[1] )
3022 {
3023 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
3024 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
3025 }
3026 else
3027 {
3028 Key1Length = 0;
3029 }
3030
3031 if ( pProfile->Keys.KeyLength[2] )
3032 {
3033 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
3034 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3035 }
3036 else
3037 {
3038 Key2Length = 0;
3039 }
3040
3041 if ( pProfile->Keys.KeyLength[3] )
3042 {
3043 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
3044 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3045 }
3046 else
3047 {
3048 Key3Length = 0;
3049 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 break;
3051
3052 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3053
3054 // Privacy is ON. NO RSN for Wep40 static key.
3055 PrivacyEnabled = 1;
3056 RsnEnabled = 0;
3057
3058 // Set the Wep default key ID.
3059 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3060
3061 // Wep key size if 13 bytes (104 bits).
3062 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3063
3064 // set encryption keys in the CFG database or clear those that are not present in this profile.
3065 if ( pProfile->Keys.KeyLength[0] )
3066 {
3067 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3068 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3069 }
3070 else
3071 {
3072 Key0Length = 0;
3073 }
3074
3075 if ( pProfile->Keys.KeyLength[1] )
3076 {
3077 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3078 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3079 }
3080 else
3081 {
3082 Key1Length = 0;
3083 }
3084
3085 if ( pProfile->Keys.KeyLength[2] )
3086 {
3087 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3088 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3089 }
3090 else
3091 {
3092 Key2Length = 0;
3093 }
3094
3095 if ( pProfile->Keys.KeyLength[3] )
3096 {
3097 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3098 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3099 }
3100 else
3101 {
3102 Key3Length = 0;
3103 }
3104
3105 break;
3106
3107 case eCSR_ENCRYPT_TYPE_WEP40:
3108 case eCSR_ENCRYPT_TYPE_WEP104:
3109 case eCSR_ENCRYPT_TYPE_TKIP:
3110 case eCSR_ENCRYPT_TYPE_AES:
3111#ifdef FEATURE_WLAN_WAPI
3112 case eCSR_ENCRYPT_TYPE_WPI:
3113#endif /* FEATURE_WLAN_WAPI */
3114 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3115 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3116 PrivacyEnabled = (0 != fPrivacy);
3117
3118 // turn on RSN enabled for WPA associations
3119 RsnEnabled = 1;
3120
3121 // WEP key length and Wep Default Key ID don't matter in this case....
3122
3123 // clear out the static WEP keys that may be hanging around.
3124 Key0Length = 0;
3125 Key1Length = 0;
3126 Key2Length = 0;
3127 Key3Length = 0;
3128
3129 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 default:
3131 PrivacyEnabled = 0;
3132 RsnEnabled = 0;
3133 break;
3134 }
3135
3136 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3137 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3138 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3139 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3140 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3141 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3142 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3143 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3144}
3145
Jeff Johnson295189b2012-06-20 16:38:30 -07003146static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3147{
3148 tANI_U32 len = 0;
3149 if(pSSID->length <= WNI_CFG_SSID_LEN)
3150 {
3151 len = pSSID->length;
3152 }
3153 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3154}
3155
Jeff Johnson295189b2012-06-20 16:38:30 -07003156eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3157{
3158 eHalStatus status = eHAL_STATUS_SUCCESS;
3159 tANI_U32 QoSEnabled;
3160 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 // set the CFG enable/disable variables based on the qosType being configured...
3162 switch( qosType )
3163 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3165 QoSEnabled = FALSE;
3166 WmeEnabled = TRUE;
3167 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3169 QoSEnabled = FALSE;
3170 WmeEnabled = TRUE;
3171 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003172 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3173 QoSEnabled = FALSE;
3174 WmeEnabled = TRUE;
3175 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3177 QoSEnabled = TRUE;
3178 WmeEnabled = FALSE;
3179 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 case eCSR_MEDIUM_ACCESS_11e_HCF:
3181 QoSEnabled = TRUE;
3182 WmeEnabled = FALSE;
3183 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 default:
3185 case eCSR_MEDIUM_ACCESS_DCF:
3186 QoSEnabled = FALSE;
3187 WmeEnabled = FALSE;
3188 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 }
3190 //save the WMM setting for later use
3191 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3193 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 return (status);
3195}
Jeff Johnson295189b2012-06-20 16:38:30 -07003196static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3197 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3198{
3199 eHalStatus status = eHAL_STATUS_FAILURE;
3200 int i;
3201 eCsrCfgDot11Mode cfgDot11Mode;
3202 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
3204 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003206
3207 if( NULL != pIes )
3208 {
3209 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 // Originally, we thought that for 11a networks, the 11a rates are always
3211 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3212 // appear in the Operational Rate set. Consequently, in either case, we
3213 // would blindly put the rates we support into our Operational Rate set
3214 // (including the basic rates, which we have already verified are
3215 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 // However, it turns out that this is not always the case. Some AP's
3217 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3218 // too. Now, we're a little more careful:
3219 pDstRate = pOpRateSet->rate;
3220 if(pIes->SuppRates.present)
3221 {
3222 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3223 {
3224 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3225 {
3226 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003227 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003228 }
3229 }
3230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3232 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3233 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3234 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3235 {
3236 // If there are Extended Rates in the beacon, we will reflect those
3237 // extended rates that we support in out Extended Operational Rate
3238 // set:
3239 pDstRate = pExRateSet->rate;
3240 if(pIes->ExtSuppRates.present)
3241 {
3242 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3243 {
3244 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3245 {
3246 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3247 pExRateSet->numRates++;
3248 }
3249 }
3250 }
3251 }
3252 }//Parsing BSSDesc
3253 else
3254 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003255 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 }
3257 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3258 return status;
3259}
3260
3261static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3262 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3263{
3264 int i;
3265 tANI_U8 *pDstRate;
3266 eCsrCfgDot11Mode cfgDot11Mode;
3267 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3268 tANI_U32 OperationalRatesLength = 0;
3269 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3270 tANI_U32 ExtendedOperationalRatesLength = 0;
3271 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3272 tANI_U32 ProprietaryOperationalRatesLength = 0;
3273 tANI_U32 PropRatesEnable = 0;
3274 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3275 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003276 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 if( NULL != pIes )
3278 {
3279 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 // Originally, we thought that for 11a networks, the 11a rates are always
3281 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3282 // appear in the Operational Rate set. Consequently, in either case, we
3283 // would blindly put the rates we support into our Operational Rate set
3284 // (including the basic rates, which we have already verified are
3285 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 // However, it turns out that this is not always the case. Some AP's
3287 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3288 // too. Now, we're a little more careful:
3289 pDstRate = OperationalRates;
3290 if(pIes->SuppRates.present)
3291 {
3292 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3293 {
3294 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3295 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3296 {
3297 *pDstRate++ = pIes->SuppRates.rates[ i ];
3298 OperationalRatesLength++;
3299 }
3300 }
3301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3303 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3304 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3305 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3306 {
3307 // If there are Extended Rates in the beacon, we will reflect those
3308 // extended rates that we support in out Extended Operational Rate
3309 // set:
3310 pDstRate = ExtendedOperationalRates;
3311 if(pIes->ExtSuppRates.present)
3312 {
3313 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3314 {
3315 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3316 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3317 {
3318 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3319 ExtendedOperationalRatesLength++;
3320 }
3321 }
3322 }
3323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 // Enable proprietary MAC features if peer node is Airgo node and STA
3325 // user wants to use them
3326 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3327 {
3328 PropRatesEnable = 1;
3329 }
3330 else
3331 {
3332 PropRatesEnable = 0;
3333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003334 // For ANI network companions, we need to populate the proprietary rate
3335 // set with any proprietary rates we found in the beacon, only if user
3336 // allows them...
3337 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3338 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3339 {
3340 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3341 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3342 {
3343 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3344 }
3345 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3346 }
3347 else {
3348 // No proprietary modes...
3349 ProprietaryOperationalRatesLength = 0;
3350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 /* Get MCS Rate */
3352 pDstRate = MCSRateIdxSet;
3353 if ( pIes->HTCaps.present )
3354 {
3355 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3356 {
3357 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3358 {
3359 MCSRateLength++;
3360 *pDstRate++ = i;
3361 }
3362 }
3363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003364 // Set the operational rate set CFG variables...
3365 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3366 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3367 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3368 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3369 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3370 ProprietaryOperationalRates,
3371 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3372 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3373 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3374 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3375 }//Parsing BSSDesc
3376 else
3377 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003378 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 }
3380}
3381
Jeff Johnson295189b2012-06-20 16:38:30 -07003382static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3383 tCsrRoamProfile *pProfile )
3384{
3385 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3386 { 8,
3387 { SIR_MAC_RATE_6,
3388 SIR_MAC_RATE_9,
3389 SIR_MAC_RATE_12,
3390 SIR_MAC_RATE_18,
3391 SIR_MAC_RATE_24,
3392 SIR_MAC_RATE_36,
3393 SIR_MAC_RATE_48,
3394 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3396 { 4,
3397 { SIR_MAC_RATE_1,
3398 SIR_MAC_RATE_2,
3399 SIR_MAC_RATE_5_5,
3400 SIR_MAC_RATE_11 } } };
3401
3402
3403 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3404 { SIR_MAC_RATE_72,
3405 SIR_MAC_RATE_96,
3406 SIR_MAC_RATE_108 } };
3407 eCsrCfgDot11Mode cfgDot11Mode;
3408 eCsrBand eBand;
3409 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3410 tANI_U32 OperationalRatesLength = 0;
3411 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3412 tANI_U32 ExtendedOperationalRatesLength = 0;
3413 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3414 tANI_U32 ProprietaryOperationalRatesLength = 0;
3415 tANI_U32 PropRatesEnable = 0;
3416 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 if(pProfile->ChannelInfo.ChannelList)
3418 {
3419 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3420 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3423 // networks, the 11b rates appear in the Operational Rate set. In either case,
3424 // we can blindly put the rates we support into our Operational Rate set
3425 // (including the basic rates, which we have already verified are supported
3426 // earlier in the roaming decision).
3427 if ( eCSR_BAND_5G == eBand )
3428 {
3429 // 11a rates into the Operational Rate Set.
3430 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3431 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3432 palCopyMemory( pMac->hHdd, OperationalRates,
3433 DefaultSupportedRates11a.supportedRateSet.rate,
3434 OperationalRatesLength );
3435
3436 // Nothing in the Extended rate set.
3437 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 // populate proprietary rates if user allows them
3439 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3440 {
3441 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3442 sizeof(*DefaultSupportedPropRates.propRate);
3443 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3444 DefaultSupportedPropRates.propRate,
3445 ProprietaryOperationalRatesLength );
3446 }
3447 else
3448 {
3449 // No proprietary modes
3450 ProprietaryOperationalRatesLength = 0;
3451 }
3452 }
3453 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3454 {
3455 // 11b rates into the Operational Rate Set.
3456 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3457 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3458 palCopyMemory( pMac->hHdd, OperationalRates,
3459 DefaultSupportedRates11b.supportedRateSet.rate,
3460 OperationalRatesLength );
3461 // Nothing in the Extended rate set.
3462 ExtendedOperationalRatesLength = 0;
3463 // No proprietary modes
3464 ProprietaryOperationalRatesLength = 0;
3465 }
3466 else
3467 {
3468 // 11G
3469
3470 // 11b rates into the Operational Rate Set.
3471 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3472 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3473 palCopyMemory( pMac->hHdd, OperationalRates,
3474 DefaultSupportedRates11b.supportedRateSet.rate,
3475 OperationalRatesLength );
3476
3477 // 11a rates go in the Extended rate set.
3478 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3479 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3480 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3481 DefaultSupportedRates11a.supportedRateSet.rate,
3482 ExtendedOperationalRatesLength );
3483
3484 // populate proprietary rates if user allows them
3485 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3486 {
3487 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3488 sizeof(*DefaultSupportedPropRates.propRate);
3489 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3490 DefaultSupportedPropRates.propRate,
3491 ProprietaryOperationalRatesLength );
3492 }
3493 else
3494 {
3495 // No proprietary modes
3496 ProprietaryOperationalRatesLength = 0;
3497 }
3498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3500 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3501 {
3502 PropRatesEnable = 1;
3503 }
3504 else
3505 {
3506 PropRatesEnable = 0;
3507 }
3508
3509 // Set the operational rate set CFG variables...
3510 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3511 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3512 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3513 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3514 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3515 ProprietaryOperationalRates,
3516 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3517 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003518}
Jeff Johnson295189b2012-06-20 16:38:30 -07003519void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3520{
3521 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003522
Jeff Johnson295189b2012-06-20 16:38:30 -07003523 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3524 tANI_U32 sessionId;
3525 tSmeCmd *pCommand = NULL;
3526
3527 if(NULL == pEntry)
3528 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003529 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 return;
3531 }
3532 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3533 sessionId = pCommand->sessionId;
3534
3535 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3536 {
3537 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3538 }
3539}
3540
Jeff Johnson295189b2012-06-20 16:38:30 -07003541//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3542tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3543{
3544 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3545 {
3546 return (WNI_CFG_PHY_MODE_11B);
3547 }
3548 else
3549 {
3550 if(eCSR_BAND_24 == band)
3551 return (WNI_CFG_PHY_MODE_11G);
3552 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 return (WNI_CFG_PHY_MODE_11A);
3554}
Jeff Johnson295189b2012-06-20 16:38:30 -07003555
Jeff Johnsone7245742012-09-05 17:12:55 -07003556
3557#ifdef WLAN_FEATURE_11AC
3558ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3559{
3560 switch ( aniCBMode )
3561 {
3562 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3563 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3564 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3565 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3566 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3567 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3568 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3569 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3570 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003571 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003572 return PHY_SINGLE_CHANNEL_CENTERED;
3573 }
3574}
3575#endif
3576
Jeff Johnson295189b2012-06-20 16:38:30 -07003577//pIes may be NULL
3578eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3579 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3580 tDot11fBeaconIEs *pIes)
3581{
3582 eHalStatus status = eHAL_STATUS_SUCCESS;
3583 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3584 tANI_U8 channel = 0;
3585 //Make sure we have the domain info for the BSS we try to connect to.
3586 //Do we need to worry about sequence for OSs that are not Windows??
3587 if(pBssDesc)
3588 {
3589 if(csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
3590 {
3591 //Make sure the 11d info from this BSSDesc can be applied
3592 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3593 csrApplyCountryInformation( pMac, TRUE );
3594 }
Kiran4a17ebe2013-01-31 10:43:43 -08003595 if ((csrIs11dSupported (pMac)) && pIes)
3596 {
3597 if (!pIes->Country.present)
3598 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003601 //Qos
3602 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3603 //SSID
3604 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3605 //fragment threshold
3606 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3607 //RTS threshold
3608 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3609
3610 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3611
3612 //Auth type
3613 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3614 //encryption type
3615 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3616 //short slot time
3617 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 //11d
3619 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3620 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3621 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 /*//11h
3623 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3624 */
3625 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3626 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003627
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile))
3629 {
3630 channel = pProfile->operationChannel;
3631 }
3632 else
3633 {
3634 if(pBssDesc)
3635 {
3636 channel = pBssDesc->channelId;
3637 }
3638 }
3639 if(0 != channel)
3640 {
3641 if(CSR_IS_CHANNEL_24GHZ(channel))
3642 {//for now if we are on 2.4 Ghz, CB will be always disabled
3643 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3644 }
3645 else
3646 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003647 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 }
3649 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003650#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003651 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3652 // in function csrConvertCBIniValueToPhyCBState()
3653 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3654 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003655 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003656 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003657 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003658 }
3659 else
3660 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003661 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003662 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003663 }
3664 else
3665#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3667 //Rate
3668 //Fixed Rate
3669 if(pBssDesc)
3670 {
3671 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3672 }
3673 else
3674 {
3675 csrSetCfgRateSetFromProfile(pMac, pProfile);
3676 }
3677 //Make this the last CFG to set. The callback will trigger a join_req
3678 //Join time out
3679 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3680
3681 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003682 return (status);
3683}
3684
Jeff Johnson295189b2012-06-20 16:38:30 -07003685eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3686 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3687{
3688 eHalStatus status;
3689 tBssConfigParam *pBssConfig;
3690 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003691
3692 if(!pSession)
3693 {
3694 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3695 return eHAL_STATUS_FAILURE;
3696 }
3697
Jeff Johnson295189b2012-06-20 16:38:30 -07003698 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3699 if(HAL_STATUS_SUCCESS(status))
3700 {
3701 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3702 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3703 if(HAL_STATUS_SUCCESS(status))
3704 {
3705 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003706 /* This will allow to pass cbMode during join req */
3707 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 //For IBSS, we need to prepare some more information
3709 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003710 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 )
3712 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003713 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 }
3715 // If we are in an IBSS, then stop the IBSS...
3716 ////Not worry about WDS connection for now
3717 if ( csrIsConnStateIbss( pMac, sessionId ) )
3718 {
3719 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3720 }
3721 else
3722 {
3723 // if we are in an Infrastructure association....
3724 if ( csrIsConnStateInfra( pMac, sessionId ) )
3725 {
3726 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3727 // across SSIDs (roaming to a new SSID)... //
3728 //Not worry about WDS connection for now
3729 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
3730 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
3731 {
3732 // then we need to disassociate from the Infrastructure network...
3733 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
3734 }
3735 else
3736 {
3737 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3738 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
3739 if ( pBssDesc )
3740 {
3741 // Set parameters for this Bss.
3742 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3743 }
3744 }
3745 }
3746 else
3747 {
3748 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3749 // Nothing to stop.
3750 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 )
3753 {
3754 // Set parameters for this Bss.
3755 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3756 }
3757 }
3758 }
3759 }//Success getting BSS config info
3760 palFreeMemory(pMac->hHdd, pBssConfig);
3761 }//Allocate memory
3762
3763 return (status);
3764}
3765
Jeff Johnson295189b2012-06-20 16:38:30 -07003766eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3767 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3768{
3769 eCsrJoinState eRoamState = eCsrContinueRoaming;
3770 eHalStatus status;
3771 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3772 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3773 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003774
3775 if(!pSession)
3776 {
3777 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3778 return (eCsrStopRoaming);
3779 }
3780
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 if( CSR_IS_WDS_STA( pProfile ) )
3782 {
3783 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3784 if( !HAL_STATUS_SUCCESS( status ) )
3785 {
3786 eRoamState = eCsrStopRoaming;
3787 }
3788 }
3789 else
3790 {
3791 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3792 {
3793 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3794 return (eCsrStopRoaming);
3795 }
3796 if ( csrIsInfraBssDesc( pBssDesc ) )
3797 {
3798 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3799 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3800 // have changed and handle the changes (without disturbing the current association).
3801
3802 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3803 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3804 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3805 )
3806 {
3807 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3808 // with Authenticating first. To force this, stop the current association (Disassociate) and
3809 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3810 // a new Association.
3811 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3812 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003813 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d"), pProfile->AuthType, pProfile->EncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3815 {
3816 eRoamState = eCsrReassocToSelfNoCapChange;
3817 }
3818 else
3819 {
3820 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 //The key changes
3822 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3823 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3824 if(HAL_STATUS_SUCCESS(status))
3825 {
3826 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003827 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 //Reapply the config including Keys so reassoc is happening.
3829 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, &bssConfig, pIesLocal);
3830 if(!HAL_STATUS_SUCCESS(status))
3831 {
3832 eRoamState = eCsrStopRoaming;
3833 }
3834 }
3835 else
3836 {
3837 eRoamState = eCsrStopRoaming;
3838 }
3839 }//same profile
3840 }
3841 else
3842 {
3843 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
3844 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3845 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003846 smsLog(pMac, LOGW, FL(" fail to issue disassociate"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 eRoamState = eCsrStopRoaming;
3848 }
3849 }
3850 }
3851 else
3852 {
3853 // note: we used to pre-auth here with open authentication networks but that was not working so well.
3854 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
3855 // work much better.
3856 //
3857 //
3858 // stop the existing network before attempting to join the new network...
3859 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3860 {
3861 eRoamState = eCsrStopRoaming;
3862 }
3863 }
3864 }//Infra
3865 else
3866 {
3867 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3868 {
3869 eRoamState = eCsrStopRoaming;
3870 }
3871 }
3872 if( pIesLocal && !pScanResult->pvIes )
3873 {
3874 palFreeMemory(pMac->hHdd, pIesLocal);
3875 }
3876 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 return( eRoamState );
3878}
3879
Jeff Johnson295189b2012-06-20 16:38:30 -07003880eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3881 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3882{
3883 eHalStatus status = eHAL_STATUS_SUCCESS;
3884 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3886 roamInfo.pBssDesc = pBssDesc;
3887 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3888 return (status);
3889}
Jeff Johnson295189b2012-06-20 16:38:30 -07003890//In case no matching BSS is found, use whatever default we can find
3891static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3892{
3893 //Need to get all negotiated types in place first
3894 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003895 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 {
3897 default:
3898 case eCSR_AUTH_TYPE_WPA:
3899 case eCSR_AUTH_TYPE_WPA_PSK:
3900 case eCSR_AUTH_TYPE_WPA_NONE:
3901 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3902 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3903 break;
3904
3905 case eCSR_AUTH_TYPE_SHARED_KEY:
3906 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
3907 break;
3908
3909 case eCSR_AUTH_TYPE_AUTOSWITCH:
3910 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
3911 break;
3912 }
3913 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
3914 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3915 //In this case, the multicast encryption needs to follow the uncast ones.
3916 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
3917 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3918}
3919
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07003920
3921static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
3922{
3923 switch(pCommand->u.roamCmd.roamReason)
3924 {
3925 case eCsrLostLink1:
3926 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
3927 break;
3928 case eCsrLostLink2:
3929 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
3930 break;
3931 case eCsrLostLink3:
3932 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
3933 break;
3934 default:
3935 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
3936 pCommand->u.roamCmd.roamReason);
3937 break;
3938 }
3939}
3940
Jeff Johnson295189b2012-06-20 16:38:30 -07003941static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
3942{
3943 eHalStatus status;
3944 tCsrScanResult *pScanResult = NULL;
3945 eCsrJoinState eRoamState = eCsrStopRoaming;
3946 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
3947 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
3948 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
3949#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3950 v_U8_t acm_mask = 0;
3951#endif
3952 tANI_U32 sessionId = pCommand->sessionId;
3953 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3954 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
3955 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003956
3957 if(!pSession)
3958 {
3959 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3960 return (eCsrStopRoaming);
3961 }
3962
Jeff Johnson295189b2012-06-20 16:38:30 -07003963 do
3964 {
3965 // Check for Cardbus eject condition, before trying to Roam to any BSS
3966 //***if( !balIsCardPresent(pAdapter) ) break;
3967
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07003968 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
3969 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 if(NULL != pBSSList)
3971 {
3972 // When handling AP's capability change, continue to associate to
3973 // same BSS and make sure pRoamBssEntry is not Null.
3974 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
3975 {
3976 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
3977 {
3978 //Try the first BSS
3979 pCommand->u.roamCmd.pLastRoamBss = NULL;
3980 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
3981 }
3982 else
3983 {
3984 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3985 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3986 {
3987 //Done with all the BSSs
3988 //In this case, will tell HDD the completion
3989 break;
3990 }
3991 else
3992 {
3993 //We need to indicate to HDD that we are done with this one.
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07003994 //palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
3996 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
3997 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
3998 pRoamInfo = &roamInfo;
3999 }
4000 }
4001 while(pCommand->u.roamCmd.pRoamBssEntry)
4002 {
4003 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 /*If concurrency enabled take the concurrent connected channel first. */
4005 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004006 if (vos_concurrent_sessions_running() &&
4007 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 {
4009 concurrentChannel =
4010 csrGetConcurrentOperationChannel(pMac);
4011 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004012 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 if ((concurrentChannel) &&
4014 (concurrentChannel ==
4015 pScanResult->Result.BssDescriptor.channelId))
4016 {
4017 //make this 0 because we do not want the
4018 //below check to pass as we don't want to
4019 //connect on other channel
4020 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4021 FL("Concurrent channel match =%d"),
4022 concurrentChannel);
4023 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 }
4025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004026
4027 if (!concurrentChannel)
4028 {
4029
4030 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4031 sessionId, &pScanResult->Result.BssDescriptor,
4032 pCommand->u.roamCmd.roamId)))
4033 {
4034 //Ok to roam this
4035 break;
4036 }
4037 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004038 else
4039 {
4040 eRoamState = eCsrStopRoamingDueToConcurrency;
4041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4043 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4044 {
4045 //Done with all the BSSs
4046 fDone = eANI_BOOLEAN_TRUE;
4047 break;
4048 }
4049 }
4050 if(fDone)
4051 {
4052 break;
4053 }
4054 }
4055 }
4056 //We have something to roam, tell HDD when it is infra.
4057 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4058 //For WDS, the indication is eCSR_ROAM_WDS_IND
4059 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4060 {
4061 if(pRoamInfo)
4062 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004063 if(pSession->bRefAssocStartCnt)
4064 {
4065 pSession->bRefAssocStartCnt--;
4066 //Complete the last association attemp because a new one is about to be tried
4067 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4068 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004070 }
4071 }
4072 /* If the roaming has stopped, not to continue the roaming command*/
4073 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4074 {
4075 //No need to complete roaming here as it already completes
4076 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4077 pCommand->u.roamCmd.roamReason);
4078 eRoamState = eCsrStopRoaming;
4079 csrSetAbortRoamingCommand(pMac, pCommand);
4080 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004081 }
4082 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4083 if(pScanResult)
4084 {
4085 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4087 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004088 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 fDone = eANI_BOOLEAN_TRUE;
4090 eRoamState = eCsrStopRoaming;
4091 break;
4092 }
4093 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4094 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4095 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4096 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4097 CSR_IS_QOS_BSS(pIesLocal) &&
4098 CSR_IS_UAPSD_BSS(pIesLocal) )
4099 {
4100#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4102 pIesLocal);
4103 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4104#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 }
4106 else
4107 {
4108 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4109 }
4110 if( pIesLocal && !pScanResult->Result.pvIes)
4111 {
4112 palFreeMemory(pMac->hHdd, pIesLocal);
4113 }
4114 }
4115 else
4116 {
4117 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4118 }
4119 roamInfo.pProfile = pProfile;
4120 pSession->bRefAssocStartCnt++;
4121 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4122 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4125 {
4126 // If this is a start IBSS profile, then we need to start the IBSS.
4127 if ( CSR_IS_START_IBSS(pProfile) )
4128 {
4129 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 // Attempt to start this IBSS...
4131 csrRoamAssignDefaultParam( pMac, pCommand );
4132 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4133 if(HAL_STATUS_SUCCESS(status))
4134 {
4135 if ( fSameIbss )
4136 {
4137 eRoamState = eCsrStartIbssSameIbss;
4138 }
4139 else
4140 {
4141 eRoamState = eCsrContinueRoaming;
4142 }
4143 }
4144 else
4145 {
4146 //it somehow fail need to stop
4147 eRoamState = eCsrStopRoaming;
4148 }
4149 break;
4150 }
4151 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 )
4154 {
4155 // Attempt to start this WDS...
4156 csrRoamAssignDefaultParam( pMac, pCommand );
4157 /* For AP WDS, we dont have any BSSDescription */
4158 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4159 if(HAL_STATUS_SUCCESS(status))
4160 {
4161 eRoamState = eCsrContinueRoaming;
4162 }
4163 else
4164 {
4165 //it somehow fail need to stop
4166 eRoamState = eCsrStopRoaming;
4167 }
4168 }
4169 else
4170 {
4171 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004172 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 eRoamState = eCsrStopRoaming;
4174 break;
4175 }
4176 }
4177 else //We have BSS
4178 {
4179 //Need to assign these value because they are used in csrIsSameProfile
4180 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4181 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4182 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4183 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4184 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4185 {
4186 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4187 {
4188 eRoamState = eCsrStartIbssSameIbss;
4189 break;
4190 }
4191 }
4192 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4193 {
4194 //trying to connect to the one already connected
4195 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4196 eRoamState = eCsrReassocToSelfNoCapChange;
4197 break;
4198 }
4199 // Attempt to Join this Bss...
4200 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4201 break;
4202 }
4203
4204 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4206 {
4207 //Need to indicate association_completion if association_start has been done
4208 if(pSession->bRefAssocStartCnt > 0)
4209 {
4210 pSession->bRefAssocStartCnt--;
4211 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004212 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4214 eCSR_ROAM_ASSOCIATION_COMPLETION,
4215 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4216 }
4217 }
4218
4219 return( eRoamState );
4220}
4221
Jeff Johnson295189b2012-06-20 16:38:30 -07004222static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4223{
4224 eHalStatus status = eHAL_STATUS_SUCCESS;
4225 eCsrJoinState RoamState;
4226 tANI_U32 sessionId = pCommand->sessionId;
4227
Jeff Johnson295189b2012-06-20 16:38:30 -07004228 //***if( hddIsRadioStateOn( pAdapter ) )
4229 {
4230 // Attept to join a Bss...
4231 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004232
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004234 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 {
4236 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 // and if connected in Infrastructure mode...
4238 if ( csrIsConnStateInfra(pMac, sessionId) )
4239 {
4240 //... then we need to issue a disassociation
4241 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4242 if(!HAL_STATUS_SUCCESS(status))
4243 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004244 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 //roam command is completed by caller in the failed case
4246 fComplete = eANI_BOOLEAN_TRUE;
4247 }
4248 }
4249 else if( csrIsConnStateIbss(pMac, sessionId) )
4250 {
4251 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4252 if(!HAL_STATUS_SUCCESS(status))
4253 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004254 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 //roam command is completed by caller in the failed case
4256 fComplete = eANI_BOOLEAN_TRUE;
4257 }
4258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4260 {
4261 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4262 if(!HAL_STATUS_SUCCESS(status))
4263 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004264 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 //roam command is completed by caller in the failed case
4266 fComplete = eANI_BOOLEAN_TRUE;
4267 }
4268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004269 else
4270 {
4271 fComplete = eANI_BOOLEAN_TRUE;
4272 }
4273 if(fComplete)
4274 {
4275 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004276 if(eCsrStopRoamingDueToConcurrency == RoamState)
4277 {
4278 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4279 }
4280 else
4281 {
4282 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4283 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 }
4285 }
4286 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4287 {
4288 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4289 }
4290 else if ( eCsrStartIbssSameIbss == RoamState )
4291 {
4292 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4293 }
4294 }//hddIsRadioStateOn
4295
4296 return status;
4297}
Jeff Johnson295189b2012-06-20 16:38:30 -07004298eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4299{
4300 tANI_U32 sessionId;
4301 tCsrRoamSession *pSession;
4302 tCsrScanResult *pScanResult = NULL;
4303 tSirBssDescription *pBssDesc = NULL;
4304 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004305 sessionId = pCommand->sessionId;
4306 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004307
4308 if(!pSession)
4309 {
4310 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4311 return eHAL_STATUS_FAILURE;
4312 }
4313
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4315 {
4316 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004317 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4319 return eHAL_STATUS_FAILURE;
4320 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004321 if (pCommand->u.roamCmd.pRoamBssEntry)
4322 {
4323 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4324 pBssDesc = &pScanResult->Result.BssDescriptor;
4325 }
4326 else
4327 {
4328 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004329 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004330 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4331 return eHAL_STATUS_FAILURE;
4332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004333 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4334 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4335 return status;
4336}
4337
Jeff Johnson295189b2012-06-20 16:38:30 -07004338eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4339{
4340 eHalStatus status = eHAL_STATUS_SUCCESS;
4341 tCsrRoamInfo roamInfo;
4342 tANI_U32 sessionId = pCommand->sessionId;
4343 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004344
4345 if(!pSession)
4346 {
4347 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4348 return eHAL_STATUS_FAILURE;
4349 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004350
4351 switch ( pCommand->u.roamCmd.roamReason )
4352 {
4353 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004355 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 case eCsrSmeIssuedDisassocForHandoff:
4358 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4359#if 0 // TODO : Confirm this change
4360 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4361#else
4362 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4363#endif
4364
4365 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004367 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004368 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004372 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004373 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004374 case eCsrHddIssuedReassocToSameAP:
4375 case eCsrSmeIssuedReassocToSameAP:
4376 {
4377 tDot11fBeaconIEs *pIes = NULL;
4378
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 if( pSession->pConnectBssDesc )
4380 {
4381 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4382 if(!HAL_STATUS_SUCCESS(status) )
4383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004384 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004385 }
4386 else
4387 {
4388 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4389 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4390 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4392 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4393 pSession->bRefAssocStartCnt++;
4394 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4395 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4396
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004397 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004398 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4399 &pCommand->u.roamCmd.roamProfile );
4400 if(!HAL_STATUS_SUCCESS(status))
4401 {
4402 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004403 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004404 }
4405
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 palFreeMemory(pMac->hHdd, pIes);
4407 pIes = NULL;
4408 }
4409 }
4410 break;
4411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004413 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004414 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4415 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4416 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004417 case eCsrSmeIssuedFTReassoc:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004418 smsLog(pMac, LOGE, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004419 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4420 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004421
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 case eCsrStopBss:
4423 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4424 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4425 break;
4426
4427 case eCsrForcedDisassocSta:
4428 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4429 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4430 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4431 pCommand->u.roamCmd.reason);
4432 break;
4433
4434 case eCsrForcedDeauthSta:
4435 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4436 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4437 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4438 pCommand->u.roamCmd.reason);
4439 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004440
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004441 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004442 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004443 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4444 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004445 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004446
4447 default:
4448 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4449
4450 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4451 {
4452 //Remember the roaming profile
4453 csrFreeRoamProfile(pMac, sessionId);
4454 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4455 {
4456 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4457 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4458 }
4459 }
4460
4461 //At this point, original uapsd_mask is saved in pCurRoamProfile
4462 //uapsd_mask in the pCommand may change from this point on.
4463
4464 // Attempt to roam with the new scan results (if we need to..)
4465 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004466 if(!HAL_STATUS_SUCCESS(status))
4467 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004468 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 break;
4471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 return (status);
4473}
4474
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004475void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4476{
4477 pCommand->u.roamCmd.pLastRoamBss = NULL;
4478 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4479 //Because u.roamCmd is union and share with scanCmd and StatusChange
4480 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4481}
4482
Jeff Johnson295189b2012-06-20 16:38:30 -07004483void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4484{
4485 if(pCommand->u.roamCmd.fReleaseBssList)
4486 {
4487 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4488 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4489 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4490 }
4491 if(pCommand->u.roamCmd.fReleaseProfile)
4492 {
4493 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4494 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4495 }
4496 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4497 //Because u.roamCmd is union and share with scanCmd and StatusChange
4498 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4499}
4500
Jeff Johnson295189b2012-06-20 16:38:30 -07004501void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4502{
4503 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4504}
Jeff Johnson295189b2012-06-20 16:38:30 -07004505void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4506{
4507 tListElem *pEntry;
4508 tSmeCmd *pCommand;
4509 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004510 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4512 if ( pEntry )
4513 {
4514 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 // If the head of the queue is Active and it is a ROAM command, remove
4516 // and put this on the Free queue.
4517 if ( eSmeCommandRoam == pCommand->command )
4518 {
4519 //we need to process the result first before removing it from active list because state changes
4520 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4521 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4522 if( fReleaseCommand )
4523 {
4524 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4525 {
4526 csrReleaseCommandRoam( pMac, pCommand );
4527 }
4528 else
4529 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004530 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004531 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 }
4533 }
4534 else
4535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004536 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004537 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 }
4539 }
4540 else
4541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004542 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 }
4544 }
4545 else
4546 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004547 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 if( fReleaseCommand )
4550 {
4551 smeProcessPendingQueue( pMac );
4552 }
4553}
4554
Jeff Johnson295189b2012-06-20 16:38:30 -07004555void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4556{
4557 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004558 if(!pSession)
4559 {
4560 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4561 return;
4562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4564 pSession->NumPmkidCandidate = 0;
4565}
Jeff Johnson295189b2012-06-20 16:38:30 -07004566#ifdef FEATURE_WLAN_WAPI
4567void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4568{
4569 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004570 if(!pSession)
4571 {
4572 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4573 return;
4574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4576 pSession->NumBkidCandidate = 0;
4577}
4578#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004579extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4580
Jeff Johnson295189b2012-06-20 16:38:30 -07004581static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4582 tSirBssDescription *pSirBssDesc,
4583 tDot11fBeaconIEs *pIes)
4584{
4585 eHalStatus status = eHAL_STATUS_SUCCESS;
4586 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4587 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004588
4589 if(!pSession)
4590 {
4591 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4592 return eHAL_STATUS_FAILURE;
4593 }
4594
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 if((eCSR_AUTH_TYPE_WPA == authType) ||
4596 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4597 (eCSR_AUTH_TYPE_RSN == authType) ||
4598 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4599#if defined WLAN_FEATURE_VOWIFI_11R
4600 ||
4601 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4602 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4603#endif /* FEATURE_WLAN_WAPI */
4604#ifdef FEATURE_WLAN_WAPI
4605 ||
4606 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4607 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4608#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004609#ifdef WLAN_FEATURE_11W
4610 ||
4611 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4612#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004613 )
4614 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004617 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 }
4619 if( pIesLocal )
4620 {
4621 tANI_U32 nIeLen;
4622 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004623 if((eCSR_AUTH_TYPE_RSN == authType) ||
4624#if defined WLAN_FEATURE_VOWIFI_11R
4625 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4626 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4627#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004628#if defined WLAN_FEATURE_11W
4629 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4630#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4632 {
4633 if(pIesLocal->RSN.present)
4634 {
4635 //Calculate the actual length
4636 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4637 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4638 + 2 //akm_suite_count
4639 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4640 + 2; //reserved
4641 if( pIesLocal->RSN.pmkid_count )
4642 {
4643 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4644 }
4645 //nIeLen doesn't count EID and length fields
4646 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4647 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004648 palZeroMemory(pMac->hHdd, pSession->pWpaRsnRspIE, nIeLen + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4650 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4651 //copy upto akm_suites
4652 pIeBuf = pSession->pWpaRsnRspIE + 2;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004653 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, sizeof(pIesLocal->RSN.version));
4654 pIeBuf += sizeof(pIesLocal->RSN.version);
4655 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.gp_cipher_suite, sizeof(pIesLocal->RSN.gp_cipher_suite));
4656 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
4657 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count, sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
4658 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 if( pIesLocal->RSN.pwise_cipher_suite_count )
4660 {
4661 //copy pwise_cipher_suites
4662 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4663 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4664 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4665 }
4666 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4667 pIeBuf += 2;
4668 if( pIesLocal->RSN.akm_suite_count )
4669 {
4670 //copy akm_suites
4671 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4672 pIesLocal->RSN.akm_suite_count * 4);
4673 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4674 }
4675 //copy the rest
4676 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4677 pIesLocal->RSN.akm_suite_count * 4,
4678 2 + pIesLocal->RSN.pmkid_count * 4);
4679 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4680 }
4681 }
4682 }
4683 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4684 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4685 {
4686 if(pIesLocal->WPA.present)
4687 {
4688 //Calculate the actual length
4689 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4690 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4691 + 2 //auth_suite_count
4692 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4693 // The WPA capabilities follows the Auth Suite (two octects)--
4694 // this field is optional, and we always "send" zero, so just
4695 // remove it. This is consistent with our assumptions in the
4696 // frames compiler; c.f. bug 15234:
4697 //nIeLen doesn't count EID and length fields
4698 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4699 {
4700 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4701 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4702 pIeBuf = pSession->pWpaRsnRspIE + 2;
4703 //Copy WPA OUI
4704 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4705 pIeBuf += 4;
4706 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4707 pIesLocal->WPA.unicast_cipher_count * 4);
4708 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4709 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4710 pIesLocal->WPA.auth_suite_count * 4);
4711 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4712 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4713 }
4714 }
4715 }
4716#ifdef FEATURE_WLAN_WAPI
4717 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4718 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4719 {
4720 if(pIesLocal->WAPI.present)
4721 {
4722 //Calculate the actual length
4723 nIeLen = 4 //version + akm_suite_count
4724 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4725 + 2 //pwise_cipher_suite_count
4726 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4727 + 6; //gp_cipher_suite + preauth + reserved
4728 if( pIesLocal->WAPI.bkid_count )
4729 {
4730 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4731 }
4732
4733 //nIeLen doesn't count EID and length fields
4734 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4735 {
4736 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4737 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4738 pIeBuf = pSession->pWapiRspIE + 2;
4739 //copy upto akm_suite_count
4740 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 4);
4741 pIeBuf += 4;
4742 if( pIesLocal->WAPI.akm_suite_count )
4743 {
4744 //copy akm_suites
4745 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4746 pIesLocal->WAPI.akm_suite_count * 4);
4747 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4748 }
4749 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4750 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004751 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4752 {
4753 //copy pwise_cipher_suites
4754 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4755 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4756 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4757 }
4758 //gp_cipher_suite + preauth + reserved + bkid_count
4759 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.multicast_cipher_suite, 8);
4760 pIeBuf += 8;
4761 if( pIesLocal->WAPI.bkid_count )
4762 {
4763 //copy akm_suites
4764 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4765 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4766 }
4767 pSession->nWapiRspIeLength = nIeLen + 2;
4768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 }
4770 }
4771#endif /* FEATURE_WLAN_WAPI */
4772 if( !pIes )
4773 {
4774 //locally allocated
4775 palFreeMemory(pMac->hHdd, pIesLocal);
4776 }
4777 }
4778 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004779 return (status);
4780}
4781
Jeff Johnson295189b2012-06-20 16:38:30 -07004782static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4783{
4784 v_U8_t bACWeights[WLANTL_MAX_AC];
4785 v_U8_t paramBk, paramBe, paramVi, paramVo;
4786 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004787 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4788 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4789 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4790 //This doesn't address the case where the lower AC needs a real higher weight
4791 if( pIEs->WMMParams.present )
4792 {
4793 //no change to the lowest ones
4794 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4795 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4796 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4797 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4798 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4799 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4800 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4801 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4802 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4803 {
4804 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4805 fWeightChange = VOS_TRUE;
4806 }
4807 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4808 {
4809 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4810 fWeightChange = VOS_TRUE;
4811 }
4812 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4813 {
4814 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4815 fWeightChange = VOS_TRUE;
4816 }
4817 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4818 {
4819 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4820 fWeightChange = VOS_TRUE;
4821 }
4822 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4823 {
4824 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4825 fWeightChange = VOS_TRUE;
4826 }
4827 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4828 {
4829 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4830 fWeightChange = VOS_TRUE;
4831 }
4832 if(fWeightChange)
4833 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004834 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07004835 bACWeights[2], bACWeights[3]);
4836 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4837 }
4838 }
4839}
Jeff Johnson295189b2012-06-20 16:38:30 -07004840#ifdef WLAN_FEATURE_VOWIFI_11R
4841//Returns whether the current association is a 11r assoc or not
4842tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4843{
4844#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4845 return csrNeighborRoamIs11rAssoc(pMac);
4846#else
4847 return eANI_BOOLEAN_FALSE;
4848#endif
4849}
4850#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004851#ifdef FEATURE_WLAN_CCX
4852//Returns whether the current association is a CCX assoc or not
4853tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4854{
4855#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4856 return csrNeighborRoamIsCCXAssoc(pMac);
4857#else
4858 return eANI_BOOLEAN_FALSE;
4859#endif
4860}
4861#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004862#ifdef FEATURE_WLAN_LFR
4863//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304864tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004865{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304866 tCsrRoamSession *pSession = NULL;
4867
4868 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4869 {
4870 pSession = CSR_GET_SESSION( pMac, sessionId );
4871 if (NULL != pSession->pCurRoamProfile)
4872 {
4873 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4874 {
4875 return eANI_BOOLEAN_FALSE;
4876 }
4877 }
4878 }
4879
Madan Mohan Koyyalamudi9ce36ec2012-10-15 16:03:17 -07004880 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07004881 (!csrIsConcurrentSessionRunning(pMac)));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004882}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004883#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4884//Returns whether "FW based BG scan" is currently enabled...or not
4885tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
4886{
4887 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
4888}
4889#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004890#endif
4891
Jeff Johnson295189b2012-06-20 16:38:30 -07004892//Return true means the command can be release, else not
4893static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4894 eCsrRoamCompleteResult Result, void *Context )
4895{
4896 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4897 tSirBssDescription *pSirBssDesc = NULL;
4898 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4899 tCsrScanResult *pScanResult = NULL;
4900 tCsrRoamInfo roamInfo;
4901 sme_QosAssocInfo assocInfo;
4902 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
4903 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
4904 tDot11fBeaconIEs *pIes = NULL;
4905 tANI_U32 sessionId = pCommand->sessionId;
4906 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4907 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4908 eRoamCmdStatus roamStatus;
4909 eCsrRoamResult roamResult;
4910 eHalStatus status;
4911 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004912 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004913
Jeff Johnson32d95a32012-09-10 13:15:23 -07004914 if(!pSession)
4915 {
4916 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4917 return eANI_BOOLEAN_FALSE;
4918 }
4919
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004920 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07004921 switch( Result )
4922 {
4923 case eCsrJoinSuccess:
4924 // reset the IDLE timer
4925 // !!
4926 // !! fall through to the next CASE statement here is intentional !!
4927 // !!
4928 case eCsrReassocSuccess:
4929 if(eCsrReassocSuccess == Result)
4930 {
4931 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
4932 }
4933 else
4934 {
4935 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
4936 }
4937 // Success Join Response from LIM. Tell NDIS we are connected and save the
4938 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004939 smsLog(pMac, LOGW, FL("receives association indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4941 //always free the memory here
4942 if(pSession->pWpaRsnRspIE)
4943 {
4944 pSession->nWpaRsnRspIeLength = 0;
4945 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
4946 pSession->pWpaRsnRspIE = NULL;
4947 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004948#ifdef FEATURE_WLAN_WAPI
4949 if(pSession->pWapiRspIE)
4950 {
4951 pSession->nWapiRspIeLength = 0;
4952 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
4953 pSession->pWapiRspIE = NULL;
4954 }
4955#endif /* FEATURE_WLAN_WAPI */
4956#ifdef FEATURE_WLAN_BTAMP_UT_RF
4957 //Reset counter so no join retry is needed.
4958 pSession->maxRetryCount = 0;
4959 csrRoamStopJoinRetryTimer(pMac, sessionId);
4960#endif
4961 /* This creates problem since we have not saved the connected profile.
4962 So moving this after saving the profile
4963 */
4964 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
4965 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4966 {
4967 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
4968 }
4969 else
4970 {
4971 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
4972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 //Use the last connected bssdesc for reassoc-ing to the same AP.
4974 //NOTE: What to do when reassoc to a different AP???
4975 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
4976 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
4977 {
4978 pSirBssDesc = pSession->pConnectBssDesc;
4979 if(pSirBssDesc)
4980 {
4981 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4982 }
4983 }
4984 else
4985 {
4986
4987 if(pCommand->u.roamCmd.pRoamBssEntry)
4988 {
4989 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4990 if(pScanResult != NULL)
4991 {
4992 pSirBssDesc = &pScanResult->Result.BssDescriptor;
4993 //this can be NULL
4994 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
4995 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4996 }
4997 }
4998 }
4999 if( pSirBssDesc )
5000 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005001 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005002 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5003 //Save WPA/RSN IE
5004 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5005#ifdef FEATURE_WLAN_CCX
5006 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5007#endif
5008
5009 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5010 // substate change.
5011 // Moving even save profile above so that below mentioned conditon is also met.
5012 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5013 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5015 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5016 // will be dropped for the security context may not be set properly.
5017 //
5018 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5019 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5020 //
5021 // this reordering was done on titan_prod_usb branch and is being replicated here.
5022 //
5023
5024 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5025 !pProfile->bWPSAssociation)
5026 {
5027 // Issue the set Context request to LIM to establish the Unicast STA context
5028 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5029 pProfile->negotiatedUCEncryptionType,
5030 pSirBssDesc, &(pSirBssDesc->bssId),
5031 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5032 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005033 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5035 }
5036 // Issue the set Context request to LIM to establish the Broadcast STA context
5037 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5038 pSirBssDesc, &BroadcastMac,
5039 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5040 }
5041 else
5042 {
5043 //Need to wait for supplicant authtication
5044 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005045 //Set the subestate to WaitForKey in case authentiation is needed
5046 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5047
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 if(pProfile->bWPSAssociation)
5049 {
5050 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5051 }
5052 else
5053 {
5054 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5055 }
5056
5057 //Save sessionId in case of timeout
5058 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5059 //This time should be long enough for the rest of the process plus setting key
5060 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5061 {
5062 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005063 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005064 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5065 }
5066 }
5067
5068 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5069 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 if(Context)
5071 {
5072 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5073 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005074 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5075 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5076#ifdef WLAN_FEATURE_VOWIFI_11R
5077 len += pJoinRsp->parsedRicRspLen;
5078#endif /* WLAN_FEATURE_VOWIFI_11R */
5079#ifdef FEATURE_WLAN_CCX
5080 len += pJoinRsp->tspecIeLen;
5081#endif
5082 if(len)
5083 {
5084 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
5085 (void **)&pSession->connectedInfo.pbFrames, len)))
5086 {
5087 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
5088 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
5089 {
5090 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5091 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5092 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
5093#ifdef WLAN_FEATURE_VOWIFI_11R
5094 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
5095#endif /* WLAN_FEATURE_VOWIFI_11R */
5096#ifdef FEATURE_WLAN_CCX
5097 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
5098#endif
5099 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5100 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5101 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5102 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5103 }
5104 else
5105 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005106 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005107 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
5109 pSession->connectedInfo.pbFrames = NULL;
5110 }
5111 }
5112 }
5113 if(pCommand->u.roamCmd.fReassoc)
5114 {
5115 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5116 }
5117 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5118 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5119 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5120 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5121 }
5122 else
5123 {
5124 if(pCommand->u.roamCmd.fReassoc)
5125 {
5126 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5127 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5128 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5129 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5130 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5131 }
5132 }
5133#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5134 // Indicate SME-QOS with reassoc success event, only after
5135 // copying the frames
5136 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5137#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005138 roamInfo.pBssDesc = pSirBssDesc;
5139 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5140 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5141#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5142 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5143#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5144 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005145 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5146 //It may be better to let QoS do this????
5147 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5148 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005149 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005150 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5151 pmcStartUapsd( pMac, NULL, NULL );
5152 }
Gopichand Nakkalad86a14e2013-04-18 16:41:54 +05305153 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005154 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5155 if( pSession->bRefAssocStartCnt > 0 )
5156 {
5157 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005158 //Remove this code once SLM_Sessionization is supported
5159 //BMPS_WORKAROUND_NOT_NEEDED
5160 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005161 {
5162 pMac->roam.configParam.doBMPSWorkaround = 1;
5163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005164 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5165 }
5166
5167 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005168 // reset the PMKID candidate list
5169 csrResetPMKIDCandidateList( pMac, sessionId );
5170 //Update TL's AC weight base on the current EDCA parameters
5171 //These parameters may change in the course of the connection, that sictuation
5172 //is not taken care here. This change is mainly to address a WIFI WMM test where
5173 //BE has a equal or higher TX priority than VI.
5174 //We only do this for infra link
5175 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5176 {
5177 csrCheckAndUpdateACWeight(pMac, pIes);
5178 }
5179#ifdef FEATURE_WLAN_WAPI
5180 // reset the BKID candidate list
5181 csrResetBKIDCandidateList( pMac, sessionId );
5182#endif /* FEATURE_WLAN_WAPI */
5183 }
5184 else
5185 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005186 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005188 csrScanCancelIdleScan(pMac);
5189 //Not to signal link up because keys are yet to be set.
5190 //The linkup function will overwrite the sub-state that we need to keep at this point.
5191 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5192 {
5193 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5194 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005195 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5196 //enough to let security and DHCP handshake succeed before entry into BMPS
5197 if (pmcShouldBmpsTimerRun(pMac))
5198 {
5199 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5200 != eHAL_STATUS_SUCCESS)
5201 {
5202 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5203 }
5204 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 break;
5207
Jeff Johnson295189b2012-06-20 16:38:30 -07005208 case eCsrStartBssSuccess:
5209 // on the StartBss Response, LIM is returning the Bss Description that we
5210 // are beaconing. Add this Bss Description to our scan results and
5211 // chain the Profile to this Bss Description. On a Start BSS, there was no
5212 // detected Bss description (no partner) so we issued the Start Bss to
5213 // start the Ibss without any Bss description. Lim was kind enough to return
5214 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005215 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Jeff Johnson295189b2012-06-20 16:38:30 -07005218 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5219 if( CSR_IS_IBSS( pProfile ) )
5220 {
5221 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5222 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005223 else if (CSR_IS_INFRA_AP(pProfile))
5224 {
5225 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005227 else
5228 {
5229 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5230 }
5231 if( !CSR_IS_WDS_STA( pProfile ) )
5232 {
5233 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5236 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005237 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 roamInfo.pBssDesc = pSirBssDesc;
5239 //We need to associate_complete it first, becasue Associate_start already indicated.
5240 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5241 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5242 break;
5243 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005245 {
5246 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes );
5247 }
5248 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5249 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5250 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5251 if(pSirBssDesc)
5252 {
5253 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5254 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5255 }
5256 //We are doen with the IEs so free it
5257 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005258#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5259 {
5260 vos_log_ibss_pkt_type *pIbssLog;
5261 tANI_U32 bi;
5262
5263 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5264 if(pIbssLog)
5265 {
5266 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5267 {
5268 //We start the IBSS (didn't find any matched IBSS out there)
5269 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5270 }
5271 else
5272 {
5273 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5274 }
5275 if(pSirBssDesc)
5276 {
5277 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
5278 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5279 }
5280 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5281 {
5282 //***U8 is not enough for beacon interval
5283 pIbssLog->beaconInterval = (v_U8_t)bi;
5284 }
5285 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5286 }
5287 }
5288#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5289 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5290 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005291 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5292 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005293 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5294 csrRoamIssueSetContextReq( pMac, sessionId,
5295 pProfile->negotiatedMCEncryptionType,
5296 pSirBssDesc, &BroadcastMac,
5297 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5298 }
5299 }
5300 else
5301 {
5302 //Keep the state to eCSR_ROAMING_STATE_JOINING
5303 //Need to send join_req.
5304 if(pCommand->u.roamCmd.pRoamBssEntry)
5305 {
5306 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5307 {
5308 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5309 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5310 // Set the roaming substate to 'join attempt'...
5311 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005312 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005313 }
5314 }
5315 else
5316 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005317 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005318 VOS_ASSERT( 0 );
5319 }
5320 }
5321 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5322 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5323 //trigger the connection start indication in Vista
5324 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5325 {
5326 roamStatus = eCSR_ROAM_IBSS_IND;
5327 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5328 if( CSR_IS_WDS( pProfile ) )
5329 {
5330 roamStatus = eCSR_ROAM_WDS_IND;
5331 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 if( CSR_IS_INFRA_AP( pProfile ) )
5334 {
5335 roamStatus = eCSR_ROAM_INFRA_IND;
5336 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005338
5339 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5340 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5341 //trigger the connection start indication in Vista
5342 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5343 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5344 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5345 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5346 {
5347 //We start the IBSS (didn't find any matched IBSS out there)
5348 roamInfo.pBssDesc = pSirBssDesc;
5349 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005350 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005351 //Remove this code once SLM_Sessionization is supported
5352 //BMPS_WORKAROUND_NOT_NEEDED
5353 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005354 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005355 {
5356 pMac->roam.configParam.doBMPSWorkaround = 1;
5357 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005358
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5360 }
5361
5362 csrScanCancelIdleScan(pMac);
5363 //Only use this timer for ibss. BAP has its own timer for WDS
5364 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
5365 {
5366 //start the join IBSS timer
5367 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
5368 pSession->ibss_join_pending = TRUE;
5369 }
5370 if( HAL_STATUS_SUCCESS( status ) )
5371 {
5372 //Already sent join_req for the WDS station
5373 fReleaseCommand = eANI_BOOLEAN_FALSE;
5374 }
5375 else if( CSR_IS_WDS_STA( pProfile ) )
5376 {
5377 //need to send stop BSS because we fail to send join_req
5378 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5379 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5380 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005382 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005383 case eCsrStartBssFailure:
5384#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5385 {
5386 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005387 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5388 if(pIbssLog)
5389 {
5390 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5391 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5392 }
5393 }
5394#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005395 roamStatus = eCSR_ROAM_IBSS_IND;
5396 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5397 if( CSR_IS_WDS( pProfile ) )
5398 {
5399 roamStatus = eCSR_ROAM_WDS_IND;
5400 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5401 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005402 if( CSR_IS_INFRA_AP( pProfile ) )
5403 {
5404 roamStatus = eCSR_ROAM_INFRA_IND;
5405 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005407 if(Context)
5408 {
5409 pSirBssDesc = (tSirBssDescription *)Context;
5410 }
5411 else
5412 {
5413 pSirBssDesc = NULL;
5414 }
5415 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5416 roamInfo.pBssDesc = pSirBssDesc;
5417 //We need to associate_complete it first, becasue Associate_start already indicated.
5418 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5419 csrSetDefaultDot11Mode( pMac );
5420 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 case eCsrSilentlyStopRoaming:
5422 // We are here because we try to start the same IBSS
5423 //No message to PE
5424 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005425 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005426 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5427 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5428 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5429 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5430 if( roamInfo.pBssDesc )
5431 {
5432 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5433 }
5434 //Since there is no change in the current state, simply pass back no result otherwise
5435 //HDD may be mistakenly mark to disconnected state.
5436 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5437 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 case eCsrSilentlyStopRoamingSaveState:
5440 //We are here because we try to connect to the same AP
5441 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005442 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005443 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5444
5445 //to aviod resetting the substate to NONE
5446 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5447 //No need to change substate to wai_for_key because there is no state change
5448 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5449 if( roamInfo.pBssDesc )
5450 {
5451 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5452 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005453 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5454 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5455 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5456 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5457 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5458 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5459 roamInfo.staId = pSession->connectedInfo.staId;
5460 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 pSession->bRefAssocStartCnt--;
5463 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5464 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5465 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5466 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 case eCsrReassocFailure:
5468#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5469 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5470#endif
5471 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005472 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 csrFreeConnectBssDesc(pMac, sessionId);
5474 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5475 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5476 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5477 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5478 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5479 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5480 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5481 eCSR_ROAM_WDS_IND,
5482 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5483 //Need to issue stop_bss
5484 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 case eCsrJoinFailure:
5486 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005487 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 default:
5489 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005490 smsLog(pMac, LOGW, FL("receives no association indication"));
5491 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005492 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5494 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5495 {
5496 //do not free for the other profiles as we need to send down stop BSS later
5497 csrFreeConnectBssDesc(pMac, sessionId);
5498 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5499 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5500 csrSetDefaultDot11Mode( pMac );
5501 }
5502
5503 switch( pCommand->u.roamCmd.roamReason )
5504 {
5505 // If this transition is because of an 802.11 OID, then we transition
5506 // back to INIT state so we sit waiting for more OIDs to be issued and
5507 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005508 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 case eCsrSmeIssuedAssocToSimilarAP:
5510 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005511 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005512 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5513 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5514 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5515 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5516 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005517 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tCsrBssid));
5518
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 /* Defeaturize this later if needed */
5520#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5521 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5522 if (csrRoamIsHandoffInProgress(pMac))
5523 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 /* Should indicate neighbor roam algorithm about the connect failure here */
5525 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5526 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005527#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005528 if(pSession->bRefAssocStartCnt > 0)
5529 {
5530 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005531 if(eCsrJoinFailureDueToConcurrency == Result)
5532 {
5533 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5534 eCSR_ROAM_ASSOCIATION_COMPLETION,
5535 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5536 }
5537 else
5538 {
5539 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 eCSR_ROAM_ASSOCIATION_COMPLETION,
5541 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005544 else
5545 {
5546 /* bRefAssocStartCnt is not incremented when
5547 * eRoamState == eCsrStopRoamingDueToConcurrency
5548 * in csrRoamJoinNextBss API. so handle this in
5549 * else case by sending assoc failure
5550 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005551 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005552 pCommand->u.scanCmd.roamId,
5553 eCSR_ROAM_ASSOCIATION_FAILURE,
5554 eCSR_ROAM_RESULT_FAILURE);
5555 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005556 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005557#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5558 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5559#endif
5560 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5561 csrScanStartIdleScan(pMac);
5562#ifdef FEATURE_WLAN_BTAMP_UT_RF
5563 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5564 //BT activity and not able to recevie WLAN traffic. Retry the join
5565 if( CSR_IS_WDS_STA(pProfile) )
5566 {
5567 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5568 }
5569#endif
5570 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005571 case eCsrHddIssuedReassocToSameAP:
5572 case eCsrSmeIssuedReassocToSameAP:
5573 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5574
5575 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5576#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5577 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5578#endif
5579 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5580 csrScanStartIdleScan(pMac);
5581 break;
5582 case eCsrForcedDisassoc:
5583 case eCsrForcedDeauth:
5584 case eCsrSmeIssuedIbssJoinFailure:
5585 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5586
5587 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5588 {
5589 // Notify HDD that IBSS join failed
5590 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5591 }
5592 else
5593 {
5594 csrRoamCallCallback(pMac, sessionId, NULL,
5595 pCommand->u.roamCmd.roamId,
5596 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5597 }
5598#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5599 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5600#endif
5601 csrRoamLinkDown(pMac, sessionId);
5602 csrScanStartIdleScan(pMac);
5603 break;
5604 case eCsrForcedIbssLeave:
5605 csrRoamCallCallback(pMac, sessionId, NULL,
5606 pCommand->u.roamCmd.roamId,
5607 eCSR_ROAM_IBSS_LEAVE,
5608 eCSR_ROAM_RESULT_IBSS_STOP);
5609 break;
5610 case eCsrForcedDisassocMICFailure:
5611 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5612
5613 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5614#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5615 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5616#endif
5617 csrScanStartIdleScan(pMac);
5618 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005619 case eCsrStopBss:
5620 csrRoamCallCallback(pMac, sessionId, NULL,
5621 pCommand->u.roamCmd.roamId,
5622 eCSR_ROAM_INFRA_IND,
5623 eCSR_ROAM_RESULT_INFRA_STOPPED);
5624 break;
5625 case eCsrForcedDisassocSta:
5626 case eCsrForcedDeauthSta:
5627 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5628 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5629 {
5630 pSession = CSR_GET_SESSION(pMac, sessionId);
5631 if (!pSession)
5632 break;
5633
5634 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5635 {
5636 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5637 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5638 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5639 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5640 roamInfo.statusCode = eSIR_SME_SUCCESS;
5641 status = csrRoamCallCallback(pMac, sessionId,
5642 &roamInfo, pCommand->u.roamCmd.roamId,
5643 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5644 }
5645 }
5646 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 case eCsrLostLink1:
5648 // if lost link roam1 failed, then issue lost link Scan2 ...
5649 csrScanRequestLostLink2(pMac, sessionId);
5650 break;
5651 case eCsrLostLink2:
5652 // if lost link roam2 failed, then issue lost link scan3 ...
5653 csrScanRequestLostLink3(pMac, sessionId);
5654 break;
5655 case eCsrLostLink3:
5656 default:
5657 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5658
5659 //We are done with one round of lostlink roaming here
5660 csrScanHandleFailedLostlink3(pMac, sessionId);
5661 break;
5662 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005663 break;
5664 }
5665 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 return ( fReleaseCommand );
5667}
5668
Jeff Johnson295189b2012-06-20 16:38:30 -07005669eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5670{
5671 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 return (status);
5673}
5674
Jeff Johnson295189b2012-06-20 16:38:30 -07005675eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5676{
5677 eHalStatus status = eHAL_STATUS_SUCCESS;
5678 tANI_U32 size = 0;
5679
5680 do
5681 {
5682 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5683 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5684 {
5685 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5686 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5687 if(!HAL_STATUS_SUCCESS(status))
5688 {
5689 break;
5690 }
5691 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5692 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5693 }
5694 if(pSrcProfile->SSIDs.numOfSSIDs)
5695 {
5696 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5697 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5698 if(!HAL_STATUS_SUCCESS(status))
5699 {
5700 break;
5701 }
5702 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5703 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5704 }
5705 if(pSrcProfile->nWPAReqIELength)
5706 {
5707 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5708 if(!HAL_STATUS_SUCCESS(status))
5709 {
5710 break;
5711 }
5712 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5713 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5714 }
5715 if(pSrcProfile->nRSNReqIELength)
5716 {
5717 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5718 if(!HAL_STATUS_SUCCESS(status))
5719 {
5720 break;
5721 }
5722 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5723 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5724 }
5725#ifdef FEATURE_WLAN_WAPI
5726 if(pSrcProfile->nWAPIReqIELength)
5727 {
5728 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5729 if(!HAL_STATUS_SUCCESS(status))
5730 {
5731 break;
5732 }
5733 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5734 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5735 }
5736#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005737 if(pSrcProfile->nAddIEScanLength)
5738 {
5739 status = palAllocateMemory(pMac->hHdd,
5740 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5741 if(!HAL_STATUS_SUCCESS(status))
5742 {
5743 break;
5744 }
5745 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5746 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5747 pSrcProfile->nAddIEScanLength);
5748 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 if(pSrcProfile->nAddIEAssocLength)
5750 {
5751 status = palAllocateMemory(pMac->hHdd,
5752 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5753 if(!HAL_STATUS_SUCCESS(status))
5754 {
5755 break;
5756 }
5757 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5758 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5759 pSrcProfile->nAddIEAssocLength);
5760 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005761 if(pSrcProfile->ChannelInfo.ChannelList)
5762 {
5763 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5764 if(!HAL_STATUS_SUCCESS(status))
5765 {
5766 break;
5767 }
5768 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5769 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 pDstProfile->AuthType = pSrcProfile->AuthType;
5772 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5773 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5774 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5775 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5776 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07005777#ifdef WLAN_FEATURE_11W
5778 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
5779 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
5780 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
5781#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005782 pDstProfile->BSSType = pSrcProfile->BSSType;
5783 pDstProfile->phyMode = pSrcProfile->phyMode;
5784 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5785
5786#ifdef FEATURE_WLAN_WAPI
5787 if(csrIsProfileWapi(pSrcProfile))
5788 {
5789 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5790 {
5791 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5792 }
5793 }
5794#endif /* FEATURE_WLAN_WAPI */
5795 pDstProfile->CBMode = pSrcProfile->CBMode;
5796 /*Save the WPS info*/
5797 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5798 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07005800 pDstProfile->privacy = pSrcProfile->privacy;
5801 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5802 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5803 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5804 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5805 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5806 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5807 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5808 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5809 pDstProfile->wps_state = pSrcProfile->wps_state;
5810 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Jeff Johnson295189b2012-06-20 16:38:30 -07005811 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005812#ifdef WLAN_FEATURE_VOWIFI_11R
5813 if (pSrcProfile->MDID.mdiePresent)
5814 {
5815 pDstProfile->MDID.mdiePresent = 1;
5816 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5817 }
5818#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 }while(0);
5820
5821 if(!HAL_STATUS_SUCCESS(status))
5822 {
5823 csrReleaseProfile(pMac, pDstProfile);
5824 pDstProfile = NULL;
5825 }
5826
5827 return (status);
5828}
Jeff Johnson295189b2012-06-20 16:38:30 -07005829eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5830{
5831 eHalStatus status = eHAL_STATUS_SUCCESS;
5832 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5833 do
5834 {
5835 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5836 if(pSrcProfile->bssid)
5837 {
5838 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5839 if(!HAL_STATUS_SUCCESS(status))
5840 {
5841 break;
5842 }
5843 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5844 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5845 }
5846 if(pSrcProfile->SSID.ssId)
5847 {
5848 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5849 if(!HAL_STATUS_SUCCESS(status))
5850 {
5851 break;
5852 }
5853 pDstProfile->SSIDs.numOfSSIDs = 1;
5854 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5855 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5856 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5857 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005858 if(pSrcProfile->nAddIEAssocLength)
5859 {
5860 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5861 if(!HAL_STATUS_SUCCESS(status))
5862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005863 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005864 break;
5865 }
5866 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5867 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5868 pSrcProfile->nAddIEAssocLength);
5869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5871 if(!HAL_STATUS_SUCCESS(status))
5872 {
5873 break;
5874 }
5875 pDstProfile->ChannelInfo.numOfChannels = 1;
5876 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 pDstProfile->AuthType.numEntries = 1;
5878 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
5879 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
5880 pDstProfile->EncryptionType.numEntries = 1;
5881 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
5882 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
5883 pDstProfile->mcEncryptionType.numEntries = 1;
5884 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
5885 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
5886 pDstProfile->BSSType = pSrcProfile->BSSType;
5887 pDstProfile->CBMode = pSrcProfile->CBMode;
5888 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5889#ifdef WLAN_FEATURE_VOWIFI_11R
5890 if (pSrcProfile->MDID.mdiePresent)
5891 {
5892 pDstProfile->MDID.mdiePresent = 1;
5893 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5894 }
5895#endif
5896
5897 }while(0);
5898
5899 if(!HAL_STATUS_SUCCESS(status))
5900 {
5901 csrReleaseProfile(pMac, pDstProfile);
5902 pDstProfile = NULL;
5903 }
5904
5905 return (status);
5906}
5907
Jeff Johnson295189b2012-06-20 16:38:30 -07005908eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5909 tScanResultHandle hBSSList,
5910 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
5911 tANI_BOOLEAN fClearScan)
5912{
5913 eHalStatus status = eHAL_STATUS_SUCCESS;
5914 tSmeCmd *pCommand;
5915
5916 pCommand = csrGetCommandBuffer(pMac);
5917 if(NULL == pCommand)
5918 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005919 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 status = eHAL_STATUS_RESOURCES;
5921 }
5922 else
5923 {
5924 if( fClearScan )
5925 {
5926 csrScanCancelIdleScan(pMac);
5927 csrScanAbortMacScanNotForConnect(pMac);
5928 }
5929 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5930 if(NULL == pProfile)
5931 {
5932 //We can roam now
5933 //Since pProfile is NULL, we need to build our own profile, set everything to default
5934 //We can only support open and no encryption
5935 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
5936 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5937 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
5938 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5939 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
5940 }
5941 else
5942 {
5943 //make a copy of the profile
5944 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5945 if(HAL_STATUS_SUCCESS(status))
5946 {
5947 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5948 }
5949 }
5950 pCommand->command = eSmeCommandRoam;
5951 pCommand->sessionId = (tANI_U8)sessionId;
5952 pCommand->u.roamCmd.hBSSList = hBSSList;
5953 pCommand->u.roamCmd.roamId = roamId;
5954 pCommand->u.roamCmd.roamReason = reason;
5955 //We need to free the BssList when the command is done
5956 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
5957 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
5959 FL("CSR PERSONA=%d"),
5960 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5962 if( !HAL_STATUS_SUCCESS( status ) )
5963 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005964 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 csrReleaseCommandRoam( pMac, pCommand );
5966 }
5967 }
5968
5969 return (status);
5970}
Jeff Johnson295189b2012-06-20 16:38:30 -07005971eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5972 tCsrRoamModifyProfileFields *pMmodProfileFields,
5973 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5974{
5975 eHalStatus status = eHAL_STATUS_SUCCESS;
5976 tSmeCmd *pCommand;
5977
5978 pCommand = csrGetCommandBuffer(pMac);
5979 if(NULL == pCommand)
5980 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005981 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 status = eHAL_STATUS_RESOURCES;
5983 }
5984 else
5985 {
5986 csrScanCancelIdleScan(pMac);
5987 csrScanAbortMacScanNotForConnect(pMac);
5988 if(pProfile)
5989 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 //This is likely trying to reassoc to different profile
5991 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5992 //make a copy of the profile
5993 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5994 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005995 }
5996 else
5997 {
5998 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
5999 //how to update WPA/WPA2 info in roamProfile??
6000 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006001 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 if(HAL_STATUS_SUCCESS(status))
6003 {
6004 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6005 }
6006 pCommand->command = eSmeCommandRoam;
6007 pCommand->sessionId = (tANI_U8)sessionId;
6008 pCommand->u.roamCmd.roamId = roamId;
6009 pCommand->u.roamCmd.roamReason = reason;
6010 //We need to free the BssList when the command is done
6011 //For reassoc there is no BSS list, so the boolean set to false
6012 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6013 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6014 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6016 if( !HAL_STATUS_SUCCESS( status ) )
6017 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006018 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6020 csrReleaseCommandRoam( pMac, pCommand );
6021 }
6022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006023 return (status);
6024}
6025
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006026eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6027 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
6028// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6029{
6030 eHalStatus status = eHAL_STATUS_SUCCESS;
6031 tSmeCmd *pCommand;
6032
6033 pCommand = csrGetCommandBuffer(pMac);
6034 if(NULL == pCommand)
6035 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006036 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006037 status = eHAL_STATUS_RESOURCES;
6038 }
6039 else
6040 {
6041 if(pBssDescription)
6042 {
6043 //copy over the parameters we need later
6044 pCommand->command = eSmeCommandRoam;
6045 pCommand->sessionId = (tANI_U8)sessionId;
6046 pCommand->u.roamCmd.roamReason = reason;
6047 //this is the important parameter
6048 //in this case we are using this field for the "next" BSS
6049 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6050 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6051 if( !HAL_STATUS_SUCCESS( status ) )
6052 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006053 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006054 csrReleaseCommandPreauth( pMac, pCommand );
6055 }
6056 }
6057 else
6058 {
6059 //Return failure
6060 status = eHAL_STATUS_RESOURCES;
6061 }
6062 }
6063 return (status);
6064}
6065
6066eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6067{
6068 tListElem *pEntry;
6069 tSmeCmd *pCommand;
6070 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6071 if ( pEntry )
6072 {
6073 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6074 if ( (eSmeCommandRoam == pCommand->command) &&
6075 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6076 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006077 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006078 pCommand->command, pCommand->u.roamCmd.roamReason);
6079 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6080 csrReleaseCommandPreauth( pMac, pCommand );
6081 }
6082 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006083 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006084 pCommand->command, pCommand->u.roamCmd.roamReason);
6085 }
6086 }
6087 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006088 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006089 }
6090 smeProcessPendingQueue( pMac );
6091 return eHAL_STATUS_SUCCESS;
6092}
6093
Jeff Johnson295189b2012-06-20 16:38:30 -07006094eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6095 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6096{
6097 eHalStatus status = eHAL_STATUS_FAILURE;
6098 tScanResultHandle hBSSList;
6099 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6101 if(HAL_STATUS_SUCCESS(status))
6102 {
6103 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6104 if(pRoamId)
6105 {
6106 *pRoamId = roamId;
6107 }
6108 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6109 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6110 if(!HAL_STATUS_SUCCESS(status))
6111 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006112 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006113 csrScanResultPurge(pMac, hBSSList);
6114 }
6115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 return (status);
6117}
6118
Jeff Johnson295189b2012-06-20 16:38:30 -07006119eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6120 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6121{
6122 eHalStatus status = eHAL_STATUS_SUCCESS;
6123 tScanResultHandle hBSSList;
6124 tCsrScanResultFilter *pScanFilter;
6125 tANI_U32 roamId = 0;
6126 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6127 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006128 if (NULL == pProfile)
6129 {
6130 smsLog(pMac, LOGP, FL("No profile specified"));
6131 return eHAL_STATUS_FAILURE;
6132 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006133 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006135 if( CSR_IS_WDS( pProfile ) &&
6136 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6137 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006138 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006139 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 return status;
6141 }
6142 csrRoamCancelRoaming(pMac, sessionId);
6143 csrScanRemoveFreshScanCommand(pMac, sessionId);
6144 csrScanCancelIdleScan(pMac);
6145 //Only abort the scan if it is not used for other roam/connect purpose
6146 csrScanAbortMacScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006147 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6148 {
6149 csrScanDisable(pMac);
6150 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6152 //Check whether ssid changes
6153 if(csrIsConnStateConnected(pMac, sessionId))
6154 {
6155 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6156 {
6157 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6158 }
6159 }
6160#ifdef FEATURE_WLAN_BTAMP_UT_RF
6161 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6162#endif
6163 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6164 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006165 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006166 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6167 if(pRoamId)
6168 {
6169 roamId = *pRoamId;
6170 }
6171 if(!HAL_STATUS_SUCCESS(status))
6172 {
6173 fCallCallback = eANI_BOOLEAN_TRUE;
6174 }
6175 }
6176 else
6177 {
6178 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6179 if(HAL_STATUS_SUCCESS(status))
6180 {
6181 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6182 //Try to connect to any BSS
6183 if(NULL == pProfile)
6184 {
6185 //No encryption
6186 pScanFilter->EncryptionType.numEntries = 1;
6187 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6188 }//we don't have a profile
6189 else
6190 {
6191 //Here is the profile we need to connect to
6192 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6193 }//We have a profile
6194 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6195 if(pRoamId)
6196 {
6197 *pRoamId = roamId;
6198 }
6199
6200 if(HAL_STATUS_SUCCESS(status))
6201 {
6202 /*Save the WPS info*/
6203 if(NULL != pProfile)
6204 {
6205 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6206 }
6207 else
6208 {
6209 pScanFilter->bWPSAssociation = 0;
6210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 do
6212 {
6213 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006214 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006215 )
6216 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006217 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6219 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6220 if(!HAL_STATUS_SUCCESS(status))
6221 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006222 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 fCallCallback = eANI_BOOLEAN_TRUE;
6224 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006225 else
6226 {
6227 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6228 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006229 break;
6230 }
6231 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006232 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 if(HAL_STATUS_SUCCESS(status))
6234 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6236 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6237 if(!HAL_STATUS_SUCCESS(status))
6238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006239 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 csrScanResultPurge(pMac, hBSSList);
6241 fCallCallback = eANI_BOOLEAN_TRUE;
6242 }
6243 }//Have scan result
6244 else if(NULL != pProfile)
6245 {
6246 //Check whether it is for start ibss
6247 if(CSR_IS_START_IBSS(pProfile))
6248 {
6249 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6250 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6251 if(!HAL_STATUS_SUCCESS(status))
6252 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006253 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006254 fCallCallback = eANI_BOOLEAN_TRUE;
6255 }
6256 }
6257 else
6258 {
6259 //scan for this SSID
6260 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
6261 if(!HAL_STATUS_SUCCESS(status))
6262 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006263 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 fCallCallback = eANI_BOOLEAN_TRUE;
6265 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006266 else
6267 {
6268 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 }
6271 }
6272 else
6273 {
6274 fCallCallback = eANI_BOOLEAN_TRUE;
6275 }
6276 } while (0);
6277 if(NULL != pProfile)
6278 {
6279 //we need to free memory for filter if profile exists
6280 csrFreeScanFilter(pMac, pScanFilter);
6281 }
6282 }//Got the scan filter from profile
6283
6284 palFreeMemory(pMac->hHdd, pScanFilter);
6285 }//allocated memory for pScanFilter
6286 }//No Bsslist coming in
6287 //tell the caller if we fail to trigger a join request
6288 if( fCallCallback )
6289 {
6290 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6291 }
6292
6293 return (status);
6294}
Jeff Johnson295189b2012-06-20 16:38:30 -07006295eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6296 tCsrRoamModifyProfileFields modProfileFields,
6297 tANI_U32 *pRoamId)
6298{
6299 eHalStatus status = eHAL_STATUS_SUCCESS;
6300 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6301 tANI_U32 roamId = 0;
6302 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 if (NULL == pProfile)
6304 {
6305 smsLog(pMac, LOGP, FL("No profile specified"));
6306 return eHAL_STATUS_FAILURE;
6307 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006308 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 -07006309 csrRoamCancelRoaming(pMac, sessionId);
6310 csrScanRemoveFreshScanCommand(pMac, sessionId);
6311 csrScanCancelIdleScan(pMac);
6312 csrScanAbortMacScanNotForConnect(pMac);
6313 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006314 if(csrIsConnStateConnected(pMac, sessionId))
6315 {
6316 if(pProfile)
6317 {
6318 if(pProfile->SSIDs.numOfSSIDs &&
6319 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6320 {
6321 fCallCallback = eANI_BOOLEAN_FALSE;
6322 }
6323 else
6324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006325 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 }
6327 }
6328 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
6329 &pSession->connectedProfile.modifyProfileFields,
6330 sizeof(tCsrRoamModifyProfileFields)))
6331 {
6332 fCallCallback = eANI_BOOLEAN_FALSE;
6333 }
6334 else
6335 {
6336 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006337 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 }
6339 }
6340 else
6341 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006342 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006344 if(!fCallCallback)
6345 {
6346 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6347 if(pRoamId)
6348 {
6349 *pRoamId = roamId;
6350 }
6351
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6353 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006354 }
6355 else
6356 {
6357 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6358 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 return status;
6361}
Jeff Johnson295189b2012-06-20 16:38:30 -07006362eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6363{
6364 eHalStatus status = eHAL_STATUS_FAILURE;
6365 tScanResultHandle hBSSList = NULL;
6366 tCsrScanResultFilter *pScanFilter = NULL;
6367 tANI_U32 roamId;
6368 tCsrRoamProfile *pProfile = NULL;
6369 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006370
6371 if(!pSession)
6372 {
6373 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6374 return eHAL_STATUS_FAILURE;
6375 }
6376
Jeff Johnson295189b2012-06-20 16:38:30 -07006377 do
6378 {
6379 if(pSession->pCurRoamProfile)
6380 {
6381 csrScanCancelIdleScan(pMac);
6382 csrScanAbortMacScanNotForConnect(pMac);
6383 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6384 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6385 if(!HAL_STATUS_SUCCESS(status))
6386 break;
6387 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6388 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6389 if(!HAL_STATUS_SUCCESS(status))
6390 break;
6391 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6392 if(!HAL_STATUS_SUCCESS(status))
6393 {
6394 break;
6395 }
6396 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6397 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6398 if(!HAL_STATUS_SUCCESS(status))
6399 {
6400 break;
6401 }
6402 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6403 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6404 if(HAL_STATUS_SUCCESS(status))
6405 {
6406 //we want to put the last connected BSS to the very beginning, if possible
6407 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6408 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6409 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6410 if(!HAL_STATUS_SUCCESS(status))
6411 {
6412 csrScanResultPurge(pMac, hBSSList);
6413 break;
6414 }
6415 }
6416 else
6417 {
6418 //Do a scan on this profile
6419 //scan for this SSID only in case the AP suppresses SSID
6420 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
6421 if(!HAL_STATUS_SUCCESS(status))
6422 {
6423 break;
6424 }
6425 }
6426 }//We have a profile
6427 else
6428 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006429 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006430 break;
6431 }
6432 }while(0);
6433 if(pScanFilter)
6434 {
6435 csrFreeScanFilter(pMac, pScanFilter);
6436 palFreeMemory(pMac->hHdd, pScanFilter);
6437 }
6438 if(NULL != pProfile)
6439 {
6440 csrReleaseProfile(pMac, pProfile);
6441 palFreeMemory(pMac->hHdd, pProfile);
6442 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006443 return (status);
6444}
Jeff Johnson295189b2012-06-20 16:38:30 -07006445eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6446{
6447 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006448 if(csrIsConnStateConnected(pMac, sessionId))
6449 {
6450 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6451 if(HAL_STATUS_SUCCESS(status))
6452 {
6453 status = csrRoamJoinLastProfile(pMac, sessionId);
6454 }
6455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006456 return (status);
6457}
6458
Jeff Johnson295189b2012-06-20 16:38:30 -07006459eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6460{
6461 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006462 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006463 csrRoamCancelRoaming(pMac, sessionId);
6464 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6465 if(csrIsConnStateDisconnected(pMac, sessionId))
6466 {
6467 status = csrRoamJoinLastProfile(pMac, sessionId);
6468 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006469 return (status);
6470}
6471
Jeff Johnson295189b2012-06-20 16:38:30 -07006472eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6473{
6474 eHalStatus status = eHAL_STATUS_SUCCESS;
6475 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6476 eCsrRoamSubState NewSubstate;
6477 tANI_U32 sessionId = pCommand->sessionId;
6478
6479 // change state to 'Roaming'...
6480 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6481
6482 if ( csrIsConnStateIbss( pMac, sessionId ) )
6483 {
6484 // If we are in an IBSS, then stop the IBSS...
6485 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6486 fComplete = (!HAL_STATUS_SUCCESS(status));
6487 }
6488 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6489 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006490 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 -07006491 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6492 //Restore AC weight in case we change it
6493 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6494 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6495 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6496 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6497 {
6498 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6499 }
6500 if( fDisassoc )
6501 {
6502 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6503 }
6504 else
6505 {
6506 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6507 }
6508 fComplete = (!HAL_STATUS_SUCCESS(status));
6509 }
6510 else if ( csrIsConnStateWds( pMac, sessionId ) )
6511 {
6512 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6513 {
6514 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6515 fComplete = (!HAL_STATUS_SUCCESS(status));
6516 }
6517 //This has to be WDS station
6518 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6519 {
6520
6521 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6522 if( fDisassoc )
6523 {
6524 status = csrRoamIssueDisassociate( pMac, sessionId,
6525 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6526 fComplete = (!HAL_STATUS_SUCCESS(status));
6527 }
6528 }
6529 } else {
6530 // we got a dis-assoc request while not connected to any peer
6531 // just complete the command
6532 fComplete = eANI_BOOLEAN_TRUE;
6533 status = eHAL_STATUS_FAILURE;
6534 }
6535 if(fComplete)
6536 {
6537 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6538 }
6539
6540 if(HAL_STATUS_SUCCESS(status))
6541 {
6542 if ( csrIsConnStateInfra( pMac, sessionId ) )
6543 {
6544 //Set the state to disconnect here
6545 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6546 }
6547 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006548 else
6549 {
6550 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006552 return (status);
6553}
6554
Jeff Johnson295189b2012-06-20 16:38:30 -07006555/* This is been removed from latest code base */
6556/*
6557static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6558{
6559 eHalStatus status;
6560 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6562 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006563 return ( status );
6564}
6565*/
6566
Jeff Johnson295189b2012-06-20 16:38:30 -07006567eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6568{
6569 eHalStatus status = eHAL_STATUS_SUCCESS;
6570 tSmeCmd *pCommand;
6571 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006572 do
6573 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006574 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006575 pCommand = csrGetCommandBuffer( pMac );
6576 if ( !pCommand )
6577 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006578 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006579 status = eHAL_STATUS_RESOURCES;
6580 break;
6581 }
6582 //Change the substate in case it is wait-for-key
6583 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6584 {
6585 csrRoamStopWaitForKeyTimer( pMac );
6586 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6587 }
6588 pCommand->command = eSmeCommandRoam;
6589 pCommand->sessionId = (tANI_U8)sessionId;
6590 switch ( reason )
6591 {
6592 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6593 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6594 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006595 case eCSR_DISCONNECT_REASON_DEAUTH:
6596 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6597 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006598 case eCSR_DISCONNECT_REASON_HANDOFF:
6599 fHighPriority = eANI_BOOLEAN_TRUE;
6600 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6601 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6603 case eCSR_DISCONNECT_REASON_DISASSOC:
6604 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6605 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6607 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6608 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6610 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6611 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006612 default:
6613 break;
6614 }
6615 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6616 if( !HAL_STATUS_SUCCESS( status ) )
6617 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006618 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006619 csrReleaseCommandRoam( pMac, pCommand );
6620 }
6621 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006622 return( status );
6623}
6624
Jeff Johnson295189b2012-06-20 16:38:30 -07006625eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6626{
6627 eHalStatus status = eHAL_STATUS_SUCCESS;
6628 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 pCommand = csrGetCommandBuffer( pMac );
6630 if ( NULL != pCommand )
6631 {
6632 //Change the substate in case it is wait-for-key
6633 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6634 {
6635 csrRoamStopWaitForKeyTimer( pMac );
6636 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6637 }
6638 pCommand->command = eSmeCommandRoam;
6639 pCommand->sessionId = (tANI_U8)sessionId;
6640 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6641 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6642 if( !HAL_STATUS_SUCCESS( status ) )
6643 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006644 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 csrReleaseCommandRoam( pMac, pCommand );
6646 }
6647 }
6648 else
6649 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006650 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006651 status = eHAL_STATUS_RESOURCES;
6652 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 return ( status );
6654}
6655
Jeff Johnson295189b2012-06-20 16:38:30 -07006656eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6657{
6658 eHalStatus status = eHAL_STATUS_SUCCESS;
6659 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006660
6661 if(!pSession)
6662 {
6663 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6664 return eHAL_STATUS_FAILURE;
6665 }
6666
Jeff Johnson295189b2012-06-20 16:38:30 -07006667#ifdef FEATURE_WLAN_BTAMP_UT_RF
6668 //Stop te retry
6669 pSession->maxRetryCount = 0;
6670 csrRoamStopJoinRetryTimer(pMac, sessionId);
6671#endif
6672 //Not to call cancel roaming here
6673 //Only issue disconnect when necessary
6674 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6675 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6676 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6677
6678 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006679 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006682 return (status);
6683}
6684
Jeff Johnson295189b2012-06-20 16:38:30 -07006685eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6686{
6687 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006688
6689 if(!pSession)
6690 {
6691 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6692 return eHAL_STATUS_FAILURE;
6693 }
6694
Jeff Johnson295189b2012-06-20 16:38:30 -07006695 csrRoamCancelRoaming(pMac, sessionId);
6696 pSession->ibss_join_pending = FALSE;
6697 csrRoamStopIbssJoinTimer(pMac, sessionId);
6698 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6699
6700 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6701}
6702
Jeff Johnson295189b2012-06-20 16:38:30 -07006703eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6704 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6705{
6706 eHalStatus status = eHAL_STATUS_SUCCESS;
6707 tDot11fBeaconIEs *pIesTemp = pIes;
6708 tANI_U8 index;
6709 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6710 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
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 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006717
6718 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6719 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6720 pConnectProfile->AuthInfo = pProfile->AuthType;
6721 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6722 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6723 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6724 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6725 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6726 pConnectProfile->BSSType = pProfile->BSSType;
6727 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6728 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006729 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6730
Jeff Johnson295189b2012-06-20 16:38:30 -07006731 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006732 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6733 if(pProfile->nAddIEAssocLength)
6734 {
6735 status = palAllocateMemory(pMac->hHdd,
6736 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6737 if(!HAL_STATUS_SUCCESS(status))
6738 {
6739 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6740 return eHAL_STATUS_FAILURE;
6741 }
6742 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6743 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6744 pProfile->nAddIEAssocLength);
6745 }
6746
Jeff Johnson295189b2012-06-20 16:38:30 -07006747 //Save bssid
6748 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6749#ifdef WLAN_FEATURE_VOWIFI_11R
6750 if (pSirBssDesc->mdiePresent)
6751 {
6752 pConnectProfile->MDID.mdiePresent = 1;
6753 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6754 }
6755#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07006756 if( NULL == pIesTemp )
6757 {
6758 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6759 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006760#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006761 if ((csrIsProfileCCX(pProfile) ||
6762 ((pIesTemp->CCXVersion.present)
6763 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6764 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6765 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6766 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07006767#ifdef WLAN_FEATURE_11W
6768 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
6769#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05306770 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006771 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 {
6773 pConnectProfile->isCCXAssoc = 1;
6774 }
6775#endif
6776 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07006777 if(HAL_STATUS_SUCCESS(status))
6778 {
6779 if(pIesTemp->SSID.present)
6780 {
6781 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6782 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6783 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6784 }
6785
6786 //Save the bss desc
6787 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306788
6789 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006790 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306791 //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 -07006792 pConnectProfile->qap = TRUE;
6793 }
6794 else
6795 {
6796 pConnectProfile->qap = FALSE;
6797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006798 if ( NULL == pIes )
6799 {
6800 //Free memory if it allocated locally
6801 palFreeMemory(pMac->hHdd, pIesTemp);
6802 }
6803 }
6804 //Save Qos connection
6805 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6806
6807 if(!HAL_STATUS_SUCCESS(status))
6808 {
6809 csrFreeConnectBssDesc(pMac, sessionId);
6810 }
6811 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6812 {
6813 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6814 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6815 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6816 {
6817 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6818 break;
6819 }
6820 pConnectProfile->handoffPermitted = FALSE;
6821 }
6822
6823 return (status);
6824}
6825
Jeff Johnson295189b2012-06-20 16:38:30 -07006826static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6827{
6828 tListElem *pEntry = NULL;
6829 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006830 //The head of the active list is the request we sent
6831 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6832 if(pEntry)
6833 {
6834 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6835 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006836 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6837 {
6838 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6839 {
6840#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6841 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6842#endif
6843 }
6844 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6845 }
6846 else
6847 {
6848 tANI_U32 roamId = 0;
6849 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006850 if(!pSession)
6851 {
6852 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6853 return;
6854 }
6855
Jeff Johnson295189b2012-06-20 16:38:30 -07006856
6857 //The head of the active list is the request we sent
6858 //Try to get back the same profile and roam again
6859 if(pCommand)
6860 {
6861 roamId = pCommand->u.roamCmd.roamId;
6862 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6864 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006865 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07006866#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6867 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6868 if (csrRoamIsHandoffInProgress(pMac))
6869 {
6870 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6871 /* Should indicate neighbor roam algorithm about the connect failure here */
6872 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
6873 }
6874#endif
6875 if (pCommand)
6876 {
6877 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
6878 {
6879 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6880 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
6881 csrRoamReissueRoamCommand(pMac);
6882 }
6883 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
6884 {
6885 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6886 }
6887 else
6888 {
6889 csrRoam(pMac, pCommand);
6890 }
6891 }
6892 else
6893 {
6894 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6895 }
6896 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
6897}
6898
Jeff Johnson295189b2012-06-20 16:38:30 -07006899eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6900 tDot11fBeaconIEs *pIes,
6901 tCsrRoamProfile *pProfile, tANI_U32 roamId )
6902{
6903 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006904 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006905 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
6906 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
6907
6908 // Set the roaming substate to 'join attempt'...
6909 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006910 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006911 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006912 return (status);
6913}
6914
Jeff Johnson295189b2012-06-20 16:38:30 -07006915static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6916 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
6917{
6918 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006919 // Set the roaming substate to 'join attempt'...
6920 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
6921
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006922 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006923
6924 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006925 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07006926}
6927
Jeff Johnson295189b2012-06-20 16:38:30 -07006928void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
6929{
6930 tListElem *pEntry;
6931 tSmeCmd *pCommand;
6932 tCsrRoamInfo roamInfo;
6933 tANI_U32 sessionId;
6934 tCsrRoamSession *pSession;
6935
6936 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6937 if(pEntry)
6938 {
6939 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6940 if ( eSmeCommandRoam == pCommand->command )
6941 {
6942 sessionId = pCommand->sessionId;
6943 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006944
6945 if(!pSession)
6946 {
6947 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6948 return;
6949 }
6950
Jeff Johnson295189b2012-06-20 16:38:30 -07006951 if( pCommand->u.roamCmd.fStopWds )
6952 {
6953 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
6954 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6955 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6956 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07006957 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07006958 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6959 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6960 eCSR_ROAM_WDS_IND,
6961 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07006962 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
6963 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6964 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6965 eCSR_ROAM_INFRA_IND,
6966 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
6967 }
6968
Jeff Johnson295189b2012-06-20 16:38:30 -07006969
Jeff Johnson295189b2012-06-20 16:38:30 -07006970 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
6971 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006972 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07006973 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6974 }
6975 }
6976 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
6977 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006978 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07006979 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6980 }
6981 }
6982 else
6983 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006984 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07006985 }
6986 }
6987 else
6988 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006989 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07006990 }
6991}
6992
Jeff Johnson295189b2012-06-20 16:38:30 -07006993tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
6994{
6995 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6996 tListElem *pEntry;
6997 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006998 //alwasy lock active list before locking pending list
6999 csrLLLock( &pMac->sme.smeCmdActiveList );
7000 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7001 if(pEntry)
7002 {
7003 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7004 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7005 {
7006 fRet = eANI_BOOLEAN_TRUE;
7007 }
7008 }
7009 if(eANI_BOOLEAN_FALSE == fRet)
7010 {
7011 csrLLLock(&pMac->sme.smeCmdPendingList);
7012 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7013 while(pEntry)
7014 {
7015 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7016 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7017 {
7018 fRet = eANI_BOOLEAN_TRUE;
7019 break;
7020 }
7021 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7022 }
7023 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7024 }
7025 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007026 return (fRet);
7027}
7028
Jeff Johnson295189b2012-06-20 16:38:30 -07007029tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7030{
7031 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7032 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007033 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7034 {
7035 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7036 {
7037 break;
7038 }
7039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007040 return ( fRet );
7041}
7042
Jeff Johnson295189b2012-06-20 16:38:30 -07007043tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7044{
7045 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007046 //alwasy lock active list before locking pending list
7047 csrLLLock( &pMac->sme.smeCmdActiveList );
7048 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7049 if(eANI_BOOLEAN_FALSE == fRet)
7050 {
7051 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7052 }
7053 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007054 return (fRet);
7055}
7056
Jeff Johnson295189b2012-06-20 16:38:30 -07007057tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7058{
7059 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7060 tListElem *pEntry;
7061 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007062 //alwasy lock active list before locking pending list
7063 csrLLLock( &pMac->sme.smeCmdActiveList );
7064 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7065 if( pEntry )
7066 {
7067 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7068 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7069 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7070 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7071 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7072 {
7073 fRet = eANI_BOOLEAN_TRUE;
7074 }
7075 }
7076 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007077 return (fRet);
7078}
Jeff Johnson295189b2012-06-20 16:38:30 -07007079eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7080{
7081 eHalStatus status = eHAL_STATUS_SUCCESS;
7082 tSmeCmd *pCommand = NULL;
7083 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7084 tANI_BOOLEAN fRemoveCmd = FALSE;
7085 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007086 // Delete the old assoc command. All is setup for reassoc to be serialized
7087 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7088 if ( pEntry )
7089 {
7090 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7091 if ( !pCommand )
7092 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007093 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007094 return eHAL_STATUS_RESOURCES;
7095 }
7096 if ( eSmeCommandRoam == pCommand->command )
7097 {
7098 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7099 {
7100 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7101 }
7102 else
7103 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007104 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007105 }
7106 if (fRemoveCmd == FALSE)
7107 {
7108 // Implies we did not get the serialized assoc command we
7109 // were expecting
7110 pCommand = NULL;
7111 }
7112 }
7113 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007114 if(NULL == pCommand)
7115 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007116 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007117 return eHAL_STATUS_RESOURCES;
7118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 do
7120 {
7121 //Change the substate in case it is wait-for-key
7122 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7123 {
7124 csrRoamStopWaitForKeyTimer( pMac );
7125 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7126 }
7127 pCommand->command = eSmeCommandRoam;
7128 pCommand->sessionId = (tANI_U8)sessionId;
7129 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007130 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7131 if( !HAL_STATUS_SUCCESS( status ) )
7132 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007133 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007134 csrReleaseCommandRoam( pMac, pCommand );
7135 }
7136 } while( 0 );
7137
Jeff Johnson295189b2012-06-20 16:38:30 -07007138 return( status );
7139}
7140static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7141{
7142 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7143 tCsrScanResult *pScanResult = NULL;
7144 tSirBssDescription *pBssDesc = NULL;
7145 tSmeCmd *pCommand = NULL;
7146 tANI_U32 sessionId;
7147 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007148 if(NULL == pEntry)
7149 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007150 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007151 return;
7152 }
7153 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7154 sessionId = pCommand->sessionId;
7155 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007156
7157 if(!pSession)
7158 {
7159 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7160 return;
7161 }
7162
Jeff Johnson295189b2012-06-20 16:38:30 -07007163 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7164 {
7165 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007166 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7168 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007169 /* If the roaming has stopped, not to continue the roaming command*/
7170 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7171 {
7172 //No need to complete roaming here as it already completes
7173 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7174 pCommand->u.roamCmd.roamReason);
7175 csrSetAbortRoamingCommand( pMac, pCommand );
7176 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7177 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007178 else
7179 {
7180 if ( CCM_IS_RESULT_SUCCESS(result) )
7181 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007182 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007183 // Successfully set the configuration parameters for the new Bss. Attempt to
7184 // join the roaming Bss.
7185 if(pCommand->u.roamCmd.pRoamBssEntry)
7186 {
7187 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7188 pBssDesc = &pScanResult->Result.BssDescriptor;
7189 }
7190 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7191 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007193 )
7194 {
7195 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7196 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7197 pBssDesc, pCommand->u.roamCmd.roamId )))
7198 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007199 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007200 //We need to complete the command
7201 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7202 }
7203 }
7204 else
7205 {
7206 if (!pCommand->u.roamCmd.pRoamBssEntry)
7207 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007208 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 //We need to complete the command
7210 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7211 return;
7212 }
7213 // If we are roaming TO an Infrastructure BSS...
7214 VOS_ASSERT(pScanResult != NULL);
7215 if ( csrIsInfraBssDesc( pBssDesc ) )
7216 {
7217 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7219 {
7220 // ..and currently in an Infrastructure connection....
7221 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7222 {
7223 // ...and the SSIDs are equal, then we Reassoc.
7224 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7225 pIesLocal ) )
7226 // ..and currently in an infrastructure connection
7227 {
7228 // then issue a Reassoc.
7229 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7230 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7231 &pCommand->u.roamCmd.roamProfile );
7232 }
7233 else
7234 {
7235
7236 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7237 // previously associated AP.
7238 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7239 pIesLocal,
7240 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7241 {
7242 //try something else
7243 csrRoam( pMac, pCommand );
7244 }
7245 }
7246 }
7247 else
7248 {
7249 eHalStatus status = eHAL_STATUS_SUCCESS;
7250
7251 /* We need to come with other way to figure out that this is because of HO in BMP
7252 The below API will be only available for Android as it uses a different HO algorithm */
7253 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7254 * use join request */
7255#ifdef WLAN_FEATURE_VOWIFI_11R
7256 if (csrRoamIsHandoffInProgress(pMac) &&
7257 csrRoamIs11rAssoc(pMac))
7258 {
7259 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7260 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7261 }
7262 else
7263#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007264#ifdef FEATURE_WLAN_CCX
7265 if (csrRoamIsHandoffInProgress(pMac) &&
7266 csrRoamIsCCXAssoc(pMac))
7267 {
7268 // Now serialize the reassoc command.
7269 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7270 }
7271 else
7272#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007273#ifdef FEATURE_WLAN_LFR
7274 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307275 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007276 {
7277 // Now serialize the reassoc command.
7278 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7279 }
7280 else
7281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007282 // else we are not connected and attempting to Join. Issue the
7283 // Join request.
7284 {
7285 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7286 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7287 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7288 }
7289 if(!HAL_STATUS_SUCCESS(status))
7290 {
7291 //try something else
7292 csrRoam( pMac, pCommand );
7293 }
7294 }
7295 if( !pScanResult->Result.pvIes )
7296 {
7297 //Locally allocated
7298 palFreeMemory(pMac->hHdd, pIesLocal);
7299 }
7300 }
7301 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7302 else
7303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007304 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007305 }
7306 }//else
7307 }//if ( WNI_CFG_SUCCESS == result )
7308 else
7309 {
7310 // In the event the configuration failed, for infra let the roam processor
7311 //attempt to join something else...
7312 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7313 {
7314 csrRoam(pMac, pCommand);
7315 }
7316 else
7317 {
7318 //We need to complete the command
7319 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7320 {
7321 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7322 }
7323 else
7324 {
7325 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7326 }
7327 }
7328 }
7329 }//we have active entry
7330}
7331
Jeff Johnson295189b2012-06-20 16:38:30 -07007332static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7333{
7334 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007335 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7337 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007338 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007339 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7340 // join the new one...
7341 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007342 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7343 }
7344 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007345 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007346 /***profHandleLostLinkAfterReset(pAdapter);
7347 // In the event the authenticate fails, let the roam processor attempt to join something else...
7348 roamRoam( pAdapter );***/
7349 }
7350}
7351
Jeff Johnson295189b2012-06-20 16:38:30 -07007352static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7353{
7354 eCsrRoamCompleteResult result;
7355 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7356 tCsrRoamInfo roamInfo;
7357 tANI_U32 roamId = 0;
7358
7359 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7360 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007361 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007362 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007363 /* Defeaturize this part later if needed */
7364#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7365 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7366 * we need the response contents while processing the result in csrRoamProcessResults() */
7367 if (csrRoamIsHandoffInProgress(pMac))
7368 {
7369 /* Need to dig more on indicating events to SME QoS module */
7370 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7371 csrRoamComplete( pMac, result, pSmeJoinRsp);
7372 }
7373 else
7374#endif
7375 {
7376 csrRoamComplete( pMac, result, NULL );
7377 }
7378 }
7379 /* Should we handle this similar to handling the join failure? Is it ok
7380 * to call csrRoamComplete() with state as CsrJoinFailure */
7381 else
7382 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007383 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007384 result = eCsrReassocFailure;
7385#ifdef WLAN_FEATURE_VOWIFI_11R
7386 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7387 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7388 {
7389 // Inform HDD to turn off FT flag in HDD
7390 if (pNeighborRoamInfo)
7391 {
7392 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7393 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7394 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007395 /*
7396 * Since the above callback sends a disconnect
7397 * to HDD, we should clean-up our state
7398 * machine as well to be in sync with the upper
7399 * layers. There is no need to send a disassoc
7400 * since: 1) we will never reassoc to the current
7401 * AP in LFR, and 2) there is no need to issue a
7402 * disassoc to the AP with which we were trying
7403 * to reassoc.
7404 */
7405 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7406 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007407 }
7408 }
7409#endif
7410 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7411 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7412 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7413 //The disassoc rsp message will remove the command from active list
7414 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7415 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7416 {
7417 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7418 }
7419 }
7420}
7421
Jeff Johnson295189b2012-06-20 16:38:30 -07007422static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7423{
Jeff Johnson295189b2012-06-20 16:38:30 -07007424#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7425 {
7426 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007427 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7428 if(pIbssLog)
7429 {
7430 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7431 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7432 {
7433 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7434 }
7435 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7436 }
7437 }
7438#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007439 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7440 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7441 {
7442 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7443 }
7444 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7445 {
7446 csrRoamReissueRoamCommand(pMac);
7447 }
7448}
7449
Jeff Johnson295189b2012-06-20 16:38:30 -07007450void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7451{
7452 tSirResultCodes statusCode;
7453#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7454 tScanResultHandle hBSSList;
7455 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7456 eHalStatus status;
7457 tCsrRoamInfo roamInfo;
7458 tCsrScanResultFilter *pScanFilter = NULL;
7459 tANI_U32 roamId = 0;
7460 tCsrRoamProfile *pCurRoamProfile = NULL;
7461 tListElem *pEntry = NULL;
7462 tSmeCmd *pCommand = NULL;
7463#endif
7464 tANI_U32 sessionId;
7465 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007466
Jeff Johnson295189b2012-06-20 16:38:30 -07007467 tSirSmeDisassocRsp SmeDisassocRsp;
7468
7469 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7470 sessionId = SmeDisassocRsp.sessionId;
7471 statusCode = SmeDisassocRsp.statusCode;
7472
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007473 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007474
7475 if ( csrIsConnStateInfra( pMac, sessionId ) )
7476 {
7477 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007479 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007480
7481 if(!pSession)
7482 {
7483 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7484 return;
7485 }
7486
Jeff Johnson295189b2012-06-20 16:38:30 -07007487 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7488 {
7489 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7490 }
7491 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7492 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7493 {
7494 if ( eSIR_SME_SUCCESS == statusCode )
7495 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007496 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7498 }
7499 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7502 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007503 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007504#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007505 /*
7506 * First ensure if the roam profile is in the scan cache.
7507 * If not, post a reassoc failure and disconnect.
7508 */
7509 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7510 if(HAL_STATUS_SUCCESS(status))
7511 {
7512 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7513 status = csrRoamPrepareFilterFromProfile(pMac,
7514 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7515 if(!HAL_STATUS_SUCCESS(status))
7516 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007517 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007518 __func__, status);
7519 goto POST_ROAM_FAILURE;
7520 }
7521 else
7522 {
7523 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7524 if (!HAL_STATUS_SUCCESS(status))
7525 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007526 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007527 __func__, status);
7528 goto POST_ROAM_FAILURE;
7529 }
7530 }
7531 }
7532 else
7533 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007534 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007535 __func__, status);
7536 goto POST_ROAM_FAILURE;
7537 }
7538
7539 /*
7540 * After ensuring that the roam profile is in the scan result list,
7541 * dequeue the command from the active list.
7542 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007543 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7544 if ( pEntry )
7545 {
7546 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007547 /* If the head of the queue is Active and it is a ROAM command, remove
7548 * and put this on the Free queue.
7549 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007550 if ( eSmeCommandRoam == pCommand->command )
7551 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007552
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007553 /*
7554 * we need to process the result first before removing it from active list
7555 * because state changes still happening insides roamQProcessRoamResults so
7556 * no other roam command should be issued.
7557 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007558 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7559 if(pCommand->u.roamCmd.fReleaseProfile)
7560 {
7561 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7562 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007564 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007565 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007566 else
7567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007568 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007569 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007570 }
7571 }
7572 else
7573 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007574 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007575 }
7576 }
7577 else
7578 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007579 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007580 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007581
7582 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007583 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7584
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007585 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7586 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7587 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007588
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007589 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7590 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007591
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007592 /* Copy the connected profile to apply the same for this connection as well */
7593 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7594 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007595 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007596 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7597 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7598 //make sure to put it at the head of the cmd queue
7599 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7600 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7601 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7602
Jeff Johnson295189b2012-06-20 16:38:30 -07007603 if(!HAL_STATUS_SUCCESS(status))
7604 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007605 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007606 __func__, status);
7607 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007608 }
7609
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007610 /* Notify sub-modules like QoS etc. that handoff happening */
7611 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007612 csrReleaseProfile(pMac, pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007613 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007614 csrFreeScanFilter(pMac, pScanFilter);
7615 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007616 return;
7617 }
7618
7619POST_ROAM_FAILURE:
7620 if (pScanFilter)
7621 {
7622 csrFreeScanFilter(pMac, pScanFilter);
7623 palFreeMemory( pMac->hHdd, pScanFilter );
7624 }
7625 if (pCurRoamProfile)
7626 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7627
7628 /* Inform the upper layers that the reassoc failed */
7629 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7630 csrRoamCallCallback(pMac, sessionId,
7631 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7632
7633 /*
7634 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7635 * Upon success, we would re-enter this routine after receiving the disassoc
7636 * response and will fall into the reassoc fail sub-state. And, eventually
7637 * call csrRoamComplete which would remove the roam command from SME active
7638 * queue.
7639 */
7640 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7641 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7642 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007643 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007644 __func__, status);
7645 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007646 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007647#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007648
Jeff Johnson295189b2012-06-20 16:38:30 -07007649 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7650 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7651 {
7652 // Disassoc due to Reassoc failure falls into this codepath....
7653 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7654 }
7655 else
7656 {
7657 if ( eSIR_SME_SUCCESS == statusCode )
7658 {
7659 // Successfully disassociated from the 'old' Bss...
7660 //
7661 // We get Disassociate response in three conditions.
7662 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7663 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7664 // Infrastructure network.
7665 // - Third is where we are doing an Infra to Infra roam between networks with different
7666 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7667
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007668 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007669 }
7670 else
7671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007672 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007673 }
7674 //We are not done yet. Get the data and continue roaming
7675 csrRoamReissueRoamCommand(pMac);
7676 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007677}
7678
Jeff Johnson295189b2012-06-20 16:38:30 -07007679static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7680{
7681 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007683 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007684 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7685 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7686 {
7687 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7688 }
7689 else
7690 {
7691 if ( eSIR_SME_SUCCESS == statusCode )
7692 {
7693 // Successfully deauth from the 'old' Bss...
7694 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007695 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007696 }
7697 else
7698 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007699 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007700 }
7701 //We are not done yet. Get the data and continue roaming
7702 csrRoamReissueRoamCommand(pMac);
7703 }
7704}
7705
Jeff Johnson295189b2012-06-20 16:38:30 -07007706static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7707{
7708 eCsrRoamCompleteResult result;
7709
7710 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7711 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007712 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007713 result = eCsrStartBssSuccess;
7714 }
7715 else
7716 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007717 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 //Let csrRoamComplete decide what to do
7719 result = eCsrStartBssFailure;
7720 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007721 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007722}
7723
Jeff Johnson295189b2012-06-20 16:38:30 -07007724/*
7725 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7726 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7727 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7728 For the messages where sender allocates memory for specific structures, then it can be
7729 cast accordingly.
7730*/
7731void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7732{
7733 tSirSmeRsp *pSmeRsp;
7734 tSmeIbssPeerInd *pIbssPeerInd;
7735 tCsrRoamInfo roamInfo;
7736 // TODO Session Id need to be acquired in this function
7737 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007738 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007739 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007740 pSmeRsp->messageType, pSmeRsp->messageType,
7741 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07007742 pSmeRsp->messageType = (pSmeRsp->messageType);
7743 pSmeRsp->length = (pSmeRsp->length);
7744 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007745 switch (pSmeRsp->messageType)
7746 {
7747
7748 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7749 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7750 {
7751 //We sent a JOIN_REQ
7752 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7753 }
7754 break;
7755
7756 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7757 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7758 {
7759 //We sent a AUTH_REQ
7760 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7761 }
7762 break;
7763
7764 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7765 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7766 {
7767 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7768 }
7769 break;
7770
7771 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7772 {
7773 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7774 }
7775 break;
7776
7777 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7778 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7779 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7780 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7781 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7782 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7783//HO
7784 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7785 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007786 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007787 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7788 }
7789 break;
7790
7791 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7792 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7793 {
7794 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7795 }
7796 break;
7797
7798 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7799 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7800 {
7801 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7802 }
7803 break;
7804
7805 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7806 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7807 {
7808 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007811 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7812 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7813 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007814 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Jeff Johnson295189b2012-06-20 16:38:30 -07007815 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7816 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7817 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7818 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7819 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7820 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7821 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7822 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7823 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007824 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007825 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007826 pSmeRsp->messageType, pSmeRsp->messageType,
7827 pMac->roam.curSubState[pSmeRsp->sessionId] );
7828
7829 //If we are connected, check the link status change
7830 if(!csrIsConnStateDisconnected(pMac, sessionId))
7831 {
7832 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7833 }
7834 break;
7835 }
7836}
7837
Jeff Johnson295189b2012-06-20 16:38:30 -07007838void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7839{
7840 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007841 switch (pSirMsg->messageType)
7842 {
7843 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007844 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 csrRoamStatsRspProcessor( pMac, pSirMsg );
7846 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007847 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7848 {
7849 tCsrRoamSession *pSession;
7850 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7851 tCsrRoamInfo roamInfo;
7852 tCsrRoamInfo *pRoamInfo = NULL;
7853 tANI_U32 sessionId;
7854 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007855 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Jeff Johnson295189b2012-06-20 16:38:30 -07007856 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7857 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007858 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7859 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7860 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007861
7862 if(!pSession)
7863 {
7864 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7865 return;
7866 }
7867
Jeff Johnson295189b2012-06-20 16:38:30 -07007868 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
7869 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07007870 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
7871 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
7872 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
7874 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007875 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
7876 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07007877 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07007878 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
7879 {
7880 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
7881 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
7882 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
7883 }
7884 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
7885 {
7886 vos_sleep( 100 );
7887 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
7888 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
7889 }
7890
Jeff Johnson295189b2012-06-20 16:38:30 -07007891 }
7892 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007893 default:
7894 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
7895 break;
7896 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007897}
7898
Jeff Johnson295189b2012-06-20 16:38:30 -07007899eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
7900 tSirBssDescription *pBssDescription,
7901 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
7902 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
7903 tANI_U8 keyId, tANI_U16 keyLength,
7904 tANI_U8 *pKey, tANI_U8 paeRole )
7905{
7906 eHalStatus status = eHAL_STATUS_SUCCESS;
7907 tAniEdType edType;
7908
7909 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
7910 {
7911 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
7912 }
7913
7914 edType = csrTranslateEncryptTypeToEdType( EncryptType );
7915
7916 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
7917 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
7918 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
7919 addKey )
7920 {
7921 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07007922 setKey.encType = EncryptType;
7923 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
7924 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
7925 setKey.paeRole = paeRole; //0 for supplicant
7926 setKey.keyId = keyId; // Kye index
7927 setKey.keyLength = keyLength;
7928 if( keyLength )
7929 {
7930 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
7931 }
7932 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
7933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007934 return (status);
7935}
7936
Jeff Johnson295189b2012-06-20 16:38:30 -07007937static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7938 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7939{
7940 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7941 tSmeCmd *pCommand = NULL;
7942#ifdef FEATURE_WLAN_CCX
7943 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7944#endif /* FEATURE_WLAN_CCX */
7945
7946 do
7947 {
7948 pCommand = csrGetCommandBuffer(pMac);
7949 if(NULL == pCommand)
7950 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007951 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007952 status = eHAL_STATUS_RESOURCES;
7953 break;
7954 }
7955 pCommand->command = eSmeCommandSetKey;
7956 pCommand->sessionId = (tANI_U8)sessionId;
7957 // validate the key length, Adjust if too long...
7958 // for static WEP the keys are not set thru' SetContextReq
7959 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
7960 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
7961 {
7962 //KeyLength maybe 0 for static WEP
7963 if( pSetKey->keyLength )
7964 {
7965 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
7966 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007967 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07007968 break;
7969 }
7970
7971 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
7972 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
7973 }
7974 }
7975 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
7976 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
7977 {
7978 //KeyLength maybe 0 for static WEP
7979 if( pSetKey->keyLength )
7980 {
7981 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
7982 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007983 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07007984 break;
7985 }
7986
7987 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
7988 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
7989 }
7990 }
7991 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
7992 {
7993 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
7994 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007995 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07007996 break;
7997 }
7998 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
7999 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
8000 }
8001 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8002 {
8003 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8004 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008005 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008006 break;
8007 }
8008 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
8009 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
8010 }
8011#ifdef FEATURE_WLAN_WAPI
8012 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8013 {
8014 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8015 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008016 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 break;
8018 }
8019 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
8020 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
8021 }
8022#endif /* FEATURE_WLAN_WAPI */
8023#ifdef FEATURE_WLAN_CCX
8024 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8025 {
8026 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8027 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008028 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008029 break;
8030 }
8031 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
8032 pSession->ccxCckmInfo.reassoc_req_num=1;
8033 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8034 status = eHAL_STATUS_SUCCESS;
8035 break;
8036 }
8037#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008038
Jeff Johnson295189b2012-06-20 16:38:30 -07008039#ifdef WLAN_FEATURE_11W
8040 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008041 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008042 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008043 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008044 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008045 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008046 break;
8047 }
8048 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Chet Lanctot186b5732013-03-18 10:26:30 -07008049 palCopyMemory(pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008050 }
8051#endif
8052 status = eHAL_STATUS_SUCCESS;
8053 pCommand->u.setKeyCmd.roamId = roamId;
8054 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8055 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
8056 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
8057 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8058 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
8059 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
8060 //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
8061
8062 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8063 if( !HAL_STATUS_SUCCESS( status ) )
8064 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008065 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008066 }
8067 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008068 // Free the command if there has been a failure, or it is a
8069 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008070 if ( ( NULL != pCommand ) &&
8071 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008072#ifdef FEATURE_WLAN_CCX
8073 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8074#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008075 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008076 {
8077 csrReleaseCommandSetKey( pMac, pCommand );
8078 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008079 return( status );
8080}
8081
Jeff Johnson295189b2012-06-20 16:38:30 -07008082eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8083 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8084{
8085 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8086 tSmeCmd *pCommand = NULL;
8087 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008088 do
8089 {
8090 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8091 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008092 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 status = eHAL_STATUS_CSR_WRONG_STATE;
8094 break;
8095 }
8096 pCommand = csrGetCommandBuffer(pMac);
8097 if(NULL == pCommand)
8098 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008099 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008100 status = eHAL_STATUS_RESOURCES;
8101 break;
8102 }
8103 pCommand->command = eSmeCommandRemoveKey;
8104 pCommand->sessionId = (tANI_U8)sessionId;
8105 pCommand->u.removeKeyCmd.roamId = roamId;
8106 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
8107 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
8108 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8109 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8110 {
8111 //in this case, put it to the end of the Q incase there is a set key pending.
8112 fImediate = eANI_BOOLEAN_FALSE;
8113 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008114 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008115 pRemoveKey->encType, pRemoveKey->keyId,
8116 pCommand->u.removeKeyCmd.peerMac[0],
8117 pCommand->u.removeKeyCmd.peerMac[1],
8118 pCommand->u.removeKeyCmd.peerMac[2],
8119 pCommand->u.removeKeyCmd.peerMac[3],
8120 pCommand->u.removeKeyCmd.peerMac[4],
8121 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008122 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8123 if( !HAL_STATUS_SUCCESS( status ) )
8124 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008125 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008126 break;
8127 }
8128 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008129 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8130 {
8131 csrReleaseCommandRemoveKey( pMac, pCommand );
8132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008133 return (status );
8134}
8135
Jeff Johnson295189b2012-06-20 16:38:30 -07008136eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8137{
8138 eHalStatus status;
8139 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8140 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8141 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8142 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008143#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8144 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8145 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008146 if(eCSR_ENCRYPT_TYPE_NONE != edType)
8147 {
8148 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8149 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8150 {
8151 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8152 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8153 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8154 }
8155 else
8156 {
8157 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8158 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8159 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8160 }
8161 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8162 if(CSR_IS_ENC_TYPE_STATIC(edType))
8163 {
8164 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008165 //It has to be static WEP here
8166 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8167 {
8168 setKeyEvent.keyId = (v_U8_t)defKeyId;
8169 }
8170 }
8171 else
8172 {
8173 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8174 }
8175 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8176 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8177 }
8178#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008179 if( csrIsSetKeyAllowed(pMac, sessionId) )
8180 {
8181 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8182 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8183 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8184 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8185 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8186 pCommand->u.setKeyCmd.keyRsc);
8187 }
8188 else
8189 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008190 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008191 //Set this status so the error handling take care of the case.
8192 status = eHAL_STATUS_CSR_WRONG_STATE;
8193 }
8194 if( !HAL_STATUS_SUCCESS(status) )
8195 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008196 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008197 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008198#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8199 if(eCSR_ENCRYPT_TYPE_NONE != edType)
8200 {
8201 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8202 {
8203 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8204 }
8205 else
8206 {
8207 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8208 }
8209 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8210 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8211 }
8212#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008214 return ( status );
8215}
8216
Jeff Johnson295189b2012-06-20 16:38:30 -07008217eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8218{
8219 eHalStatus status;
8220 tpSirSmeRemoveKeyReq pMsg = NULL;
8221 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8222 tANI_U8 *p;
8223 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008224#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8225 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8226 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008227 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8228 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8229 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8230 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8231 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8232 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8233 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8234 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8235#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008236 if( csrIsSetKeyAllowed(pMac, sessionId) )
8237 {
8238 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
8239 }
8240 else
8241 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008242 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 //Set the error status so error handling kicks in below
8244 status = eHAL_STATUS_CSR_WRONG_STATE;
8245 }
8246 if( HAL_STATUS_SUCCESS( status ) )
8247 {
8248 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
8249 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8250 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008251 pMsg->sessionId = (tANI_U8)sessionId;
8252 pMsg->transactionId = 0;
8253 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8254 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8255 // bssId - copy from session Info
8256 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
8257 p += sizeof(tSirMacAddr);
8258 // peerMacAddr
8259 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
8260 p += sizeof(tSirMacAddr);
8261 // edType
8262 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8263 p++;
8264 // weptype
8265 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8266 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8267 {
8268 *p = (tANI_U8)eSIR_WEP_STATIC;
8269 }
8270 else
8271 {
8272 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8273 }
8274 p++;
8275 //keyid
8276 *p = pCommand->u.removeKeyCmd.keyId;
8277 p++;
8278 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008279 status = palSendMBMessage(pMac->hHdd, pMsg);
8280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008281 if( !HAL_STATUS_SUCCESS( status ) )
8282 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008283 smsLog( pMac, LOGE, FL(" error status "), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008284#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8285 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008286 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008287 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8288#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008289 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008291 return ( status );
8292}
8293
Jeff Johnson295189b2012-06-20 16:38:30 -07008294eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8295{
8296 eHalStatus status;
8297
8298 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8299 {
8300 status = eHAL_STATUS_CSR_WRONG_STATE;
8301 }
8302 else
8303 {
8304 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008306 return ( status );
8307}
8308
Jeff Johnson295189b2012-06-20 16:38:30 -07008309/*
8310 Prepare a filter base on a profile for parsing the scan results.
8311 Upon successful return, caller MUST call csrFreeScanFilter on
8312 pScanFilter when it is done with the filter.
8313*/
8314eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8315 tCsrScanResultFilter *pScanFilter)
8316{
8317 eHalStatus status = eHAL_STATUS_SUCCESS;
8318 tANI_U32 size = 0;
8319 tANI_U8 index = 0;
8320
8321 do
8322 {
8323 if(pProfile->BSSIDs.numOfBSSIDs)
8324 {
8325 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
8326 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
8327 if(!HAL_STATUS_SUCCESS(status))
8328 {
8329 break;
8330 }
8331 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
8332 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
8333 }
8334 if(pProfile->SSIDs.numOfSSIDs)
8335 {
8336 if( !CSR_IS_WDS_STA( pProfile ) )
8337 {
8338 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8339 }
8340 else
8341 {
8342 //For WDS station
8343 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8344 pScanFilter->SSIDs.numOfSSIDs = 1;
8345 }
8346 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8347 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8348 if(!HAL_STATUS_SUCCESS(status))
8349 {
8350 break;
8351 }
8352 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8353 }
8354 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8355 {
8356 pScanFilter->ChannelInfo.numOfChannels = 0;
8357 pScanFilter->ChannelInfo.ChannelList = NULL;
8358 }
8359 else if(pProfile->ChannelInfo.numOfChannels)
8360 {
8361 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8362 pScanFilter->ChannelInfo.numOfChannels = 0;
8363 if(HAL_STATUS_SUCCESS(status))
8364 {
8365 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8366 {
8367 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8368 {
8369 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8370 = pProfile->ChannelInfo.ChannelList[index];
8371 pScanFilter->ChannelInfo.numOfChannels++;
8372 }
8373 else
8374 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008375 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008377 }
8378 }
8379 else
8380 {
8381 break;
8382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008383 }
8384 else
8385 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008386 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008387 status = eHAL_STATUS_FAILURE;
8388 break;
8389 }
8390 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8391 pScanFilter->authType = pProfile->AuthType;
8392 pScanFilter->EncryptionType = pProfile->EncryptionType;
8393 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8394 pScanFilter->BSSType = pProfile->BSSType;
8395 pScanFilter->phyMode = pProfile->phyMode;
8396#ifdef FEATURE_WLAN_WAPI
8397 //check if user asked for WAPI with 11n or auto mode, in that case modify
8398 //the phymode to 11g
8399 if(csrIsProfileWapi(pProfile))
8400 {
8401 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8402 {
8403 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8404 }
8405 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8406 {
8407 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8408 }
8409 if(!pScanFilter->phyMode)
8410 {
8411 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8412 }
8413 }
8414#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008415 /*Save the WPS info*/
8416 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008417 if( pProfile->countryCode[0] )
8418 {
8419 //This causes the matching function to use countryCode as one of the criteria.
8420 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8421 WNI_CFG_COUNTRY_CODE_LEN );
8422 }
8423#ifdef WLAN_FEATURE_VOWIFI_11R
8424 if (pProfile->MDID.mdiePresent)
8425 {
8426 pScanFilter->MDID.mdiePresent = 1;
8427 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8428 }
8429#endif
8430
8431 }while(0);
8432
8433 if(!HAL_STATUS_SUCCESS(status))
8434 {
8435 csrFreeScanFilter(pMac, pScanFilter);
8436 }
8437
8438 return(status);
8439}
8440
Jeff Johnson295189b2012-06-20 16:38:30 -07008441tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8442 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8443{
8444 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8445 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008446 do
8447 {
8448 // Validate the type is ok...
8449 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8450 pCommand = csrGetCommandBuffer( pMac );
8451 if ( !pCommand )
8452 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008453 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 break;
8455 }
8456 //Change the substate in case it is waiting for key
8457 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8458 {
8459 csrRoamStopWaitForKeyTimer( pMac );
8460 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8461 }
8462 pCommand->command = eSmeCommandWmStatusChange;
8463 pCommand->sessionId = (tANI_U8)sessionId;
8464 pCommand->u.wmStatusChangeCmd.Type = Type;
8465 if ( eCsrDisassociated == Type )
8466 {
8467 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8468 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8469 }
8470 else
8471 {
8472 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8473 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8474 }
8475 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8476 {
8477 fCommandQueued = eANI_BOOLEAN_TRUE;
8478 }
8479 else
8480 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008481 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 csrReleaseCommandWmStatusChange( pMac, pCommand );
8483 }
8484
Jeff Johnson295189b2012-06-20 16:38:30 -07008485 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8486 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008487 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008488 return( fCommandQueued );
8489}
8490
Jeff Johnson295189b2012-06-20 16:38:30 -07008491static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8492{
8493 v_S7_t rssi = 0;
8494 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8495 if(pGetRssiReq)
8496 {
8497 if(NULL != pGetRssiReq->pVosContext)
8498 {
8499 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8500 }
8501 else
8502 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008503 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008504 return;
8505 }
8506
8507 if(NULL != pGetRssiReq->rssiCallback)
8508 {
8509 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8510 }
8511 else
8512 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008513 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008514 return;
8515 }
8516 }
8517 else
8518 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008519 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008520 }
8521 return;
8522}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008523#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8524void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8525{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008526 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8527
Jeff Johnson36d483b2013-04-08 11:08:53 -07008528 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008529 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008530 /* Get roam Rssi request is backed up and passed back to the response,
8531 Extract the request message to fetch callback */
8532 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8533 v_S7_t rssi = pRoamRssiRsp->rssi;
8534
8535 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008536 {
8537 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8538 reqBkp->rssiCallback = NULL;
8539 vos_mem_free(reqBkp);
8540 }
8541 else
8542 {
8543 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8544 if (NULL != reqBkp)
8545 {
8546 vos_mem_free(reqBkp);
8547 }
8548 }
8549 }
8550 else
8551 {
8552 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8553 }
8554 return;
8555}
8556#endif
8557
Jeff Johnsone7245742012-09-05 17:12:55 -07008558static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8559{
8560 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8561 if(pTlRssiInd)
8562 {
8563 if(NULL != pTlRssiInd->tlCallback)
8564 {
8565 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08008566 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008567 }
8568 else
8569 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008570 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008571 }
8572 }
8573 else
8574 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008575 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008576 }
8577 return;
8578}
Jeff Johnson295189b2012-06-20 16:38:30 -07008579
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05308580eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
8581{
8582 tpSirResetAPCapsChange pMsg;
8583 tANI_U16 len;
8584 eHalStatus status = eHAL_STATUS_SUCCESS;
8585
8586 /* Create the message and send to lim */
8587 len = sizeof(tSirResetAPCapsChange);
8588 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
8589 if (HAL_STATUS_SUCCESS(status))
8590 {
8591 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirResetAPCapsChange) );
8592 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
8593 pMsg->length = len;
8594 palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr) );
8595 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= %02x-%02x-%02x-%02x-%02x-%02x"),
8596 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
8597 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ]);
8598 status = palSendMBMessage(pMac->hHdd, pMsg);
8599 }
8600 else
8601 {
8602 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
8603 }
8604 return status;
8605}
8606
Jeff Johnson295189b2012-06-20 16:38:30 -07008607void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8608{
8609 tSirSmeAssocInd *pAssocInd;
8610 tSirSmeDisassocInd *pDisassocInd;
8611 tSirSmeDeauthInd *pDeauthInd;
8612 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8613 tSirSmeNewBssInfo *pNewBss;
8614 tSmeIbssPeerInd *pIbssPeerInd;
8615 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8616 tSirSmeApNewCaps *pApNewCaps;
8617 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8618 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8619 tCsrRoamInfo *pRoamInfo = NULL;
8620 tCsrRoamInfo roamInfo;
8621 eHalStatus status;
8622 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8623 tCsrRoamSession *pSession = NULL;
8624 tpSirSmeSwitchChannelInd pSwitchChnInd;
8625 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008626 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008627 pSirMsg->messageType = (pSirMsg->messageType);
8628 pSirMsg->length = (pSirMsg->length);
8629 pSirMsg->statusCode = (pSirMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008630 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008631 switch( pSirMsg->messageType )
8632 {
8633 case eWNI_SME_ASSOC_IND:
8634 {
8635 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008636 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008637 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8638 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8639 if( HAL_STATUS_SUCCESS( status ) )
8640 {
8641 pSession = CSR_GET_SESSION(pMac, sessionId);
8642
Jeff Johnson32d95a32012-09-10 13:15:23 -07008643 if(!pSession)
8644 {
8645 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8646 return;
8647 }
8648
Jeff Johnson295189b2012-06-20 16:38:30 -07008649 pRoamInfo = &roamInfo;
8650
8651 // Required for indicating the frames to upper layer
8652 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8653 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8654
8655 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8656 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8657 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8658 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8659
8660 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8661 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8662 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8663
8664 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8665 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008666 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8667 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008668 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8669 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07008670 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07008671 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8672 {
8673 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8674 {
8675 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8676 pSession->pConnectBssDesc,
8677 &(pRoamInfo->peerMac),
8678 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8679 pRoamInfo->fAuthRequired = FALSE;
8680 }
8681 else
8682 {
8683 pRoamInfo->fAuthRequired = TRUE;
8684 }
8685 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8686 if (!HAL_STATUS_SUCCESS(status))
8687 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8688 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008689 /* Send Association completion message to PE */
8690 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8691
8692 /* send a message to CSR itself just to avoid the EAPOL frames going
8693 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008694 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8695 {
8696 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008698 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8699 {
8700 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8701 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8702 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8703 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008704 }
8705 }
8706 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008707 case eWNI_SME_DISASSOC_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008708 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008709 // Check if AP dis-associated us because of MIC failure. If so,
8710 // then we need to take action immediately and not wait till the
8711 // the WmStatusChange requests is pushed and processed
8712 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8713 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8714 if( HAL_STATUS_SUCCESS( status ) )
8715 {
8716 // If we are in neighbor preauth done state then on receiving
8717 // disassoc or deauth we dont roam instead we just disassoc
8718 // from current ap and then go to disconnected state
8719 // This happens for CCX and 11r FT connections ONLY.
8720#ifdef WLAN_FEATURE_VOWIFI_11R
8721 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8722 {
8723 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8724 }
8725#endif
8726#ifdef FEATURE_WLAN_CCX
8727 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8728 {
8729 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8730 }
8731#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008732#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308733 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008734 {
8735 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8736 }
8737#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008738 pSession = CSR_GET_SESSION( pMac, sessionId );
8739
Jeff Johnson32d95a32012-09-10 13:15:23 -07008740 if(!pSession)
8741 {
8742 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8743 return;
8744 }
8745
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 if ( csrIsConnStateInfra( pMac, sessionId ) )
8747 {
8748 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008750#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8751 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8752#endif
8753 csrRoamLinkDown(pMac, sessionId);
8754 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008755 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8756 {
8757
8758 pRoamInfo = &roamInfo;
8759
8760 pRoamInfo->statusCode = pDisassocInd->statusCode;
8761 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8762
8763 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8764
8765 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8766 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8767
8768 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008769
8770 /*
8771 * STA/P2P client got disassociated so remove any pending deauth
8772 * commands in sme pending list
8773 */
8774 pCommand.command = eSmeCommandRoam;
8775 pCommand.sessionId = (tANI_U8)sessionId;
8776 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8777 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8778 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008779 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008780 }
8781 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008782 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008783 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008784 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8785 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8786 if( HAL_STATUS_SUCCESS( status ) )
8787 {
8788 // If we are in neighbor preauth done state then on receiving
8789 // disassoc or deauth we dont roam instead we just disassoc
8790 // from current ap and then go to disconnected state
8791 // This happens for CCX and 11r FT connections ONLY.
8792#ifdef WLAN_FEATURE_VOWIFI_11R
8793 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8794 {
8795 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8796 }
8797#endif
8798#ifdef FEATURE_WLAN_CCX
8799 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8800 {
8801 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8802 }
8803#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008804#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308805 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008806 {
8807 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8808 }
8809#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008810 pSession = CSR_GET_SESSION( pMac, sessionId );
8811
Jeff Johnson32d95a32012-09-10 13:15:23 -07008812 if(!pSession)
8813 {
8814 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8815 return;
8816 }
8817
Jeff Johnson295189b2012-06-20 16:38:30 -07008818 if ( csrIsConnStateInfra( pMac, sessionId ) )
8819 {
8820 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8821 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008822#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8823 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8824#endif
8825 csrRoamLinkDown(pMac, sessionId);
8826 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008827 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8828 {
8829
8830 pRoamInfo = &roamInfo;
8831
8832 pRoamInfo->statusCode = pDeauthInd->statusCode;
8833 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8834
8835 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8836
8837 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8838 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8839
8840 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008842 }
8843 break;
8844
8845 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 -08008846 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008847 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8848 //Update with the new channel id.
8849 //The channel id is hidden in the statusCode.
8850 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8851 if( HAL_STATUS_SUCCESS( status ) )
8852 {
8853 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008854 if(!pSession)
8855 {
8856 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8857 return;
8858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008859 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8860 if(pSession->pConnectBssDesc)
8861 {
8862 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8863 }
8864 }
8865 break;
8866
8867 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008868 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008869 {
8870 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8871 sessionId = pDeauthRsp->sessionId;
8872 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8873 {
8874 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008875 if(!pSession)
8876 {
8877 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8878 return;
8879 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008880 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8881 {
8882 pRoamInfo = &roamInfo;
8883 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8884 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8885 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8886 pRoamInfo->statusCode = pDeauthRsp->statusCode;
8887 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8888 }
8889 }
8890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008891 break;
8892
8893 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07008894 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008895 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 {
8897 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8898 sessionId = pDisassocRsp->sessionId;
8899 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8900 {
8901 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008902 if(!pSession)
8903 {
8904 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8905 return;
8906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008907 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8908 {
8909 pRoamInfo = &roamInfo;
8910 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8911 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
8912 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8913 pRoamInfo->statusCode = pDisassocRsp->statusCode;
8914 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8915 }
8916 }
8917 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008918 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 case eWNI_SME_MIC_FAILURE_IND:
8920 {
8921 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
8922 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8923 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Jeff Johnson295189b2012-06-20 16:38:30 -07008924#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8925 {
8926 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008927 if(!pSession)
8928 {
8929 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8930 return;
8931 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008932 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
8933 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
8934 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
8935 secEvent.encryptionModeMulticast =
8936 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8937 secEvent.encryptionModeUnicast =
8938 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8939 secEvent.authMode =
8940 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8941 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
8942 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
8943 }
8944#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008945 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
8946 if( HAL_STATUS_SUCCESS( status ) )
8947 {
8948 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8949 roamInfo.u.pMICFailureInfo = &pMicInd->info;
8950 pRoamInfo = &roamInfo;
8951 if(pMicInd->info.multicast)
8952 {
8953 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
8954 }
8955 else
8956 {
8957 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
8958 }
8959 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
8960 }
8961 }
8962 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008963 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
8964 {
8965 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
8966 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008967 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008968
8969 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
8970 if( HAL_STATUS_SUCCESS( status ) )
8971 {
8972 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8973 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
8974 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
8975 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
8976 }
8977 }
8978 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008979
Jeff Johnson295189b2012-06-20 16:38:30 -07008980 case eWNI_SME_WM_STATUS_CHANGE_NTF:
8981 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
8982 switch( pStatusChangeMsg->statusChangeCode )
8983 {
8984 case eSIR_SME_IBSS_ACTIVE:
8985 sessionId = csrFindIbssSession( pMac );
8986 if( CSR_SESSION_ID_INVALID != sessionId )
8987 {
8988 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008989 if(!pSession)
8990 {
8991 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8992 return;
8993 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008994 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
8995 if(pSession->pConnectBssDesc)
8996 {
8997 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8998 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
8999 pRoamInfo = &roamInfo;
9000 }
9001 else
9002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009003 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009004 }
9005 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9006 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9007 }
9008 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009009 case eSIR_SME_IBSS_INACTIVE:
9010 sessionId = csrFindIbssSession( pMac );
9011 if( CSR_SESSION_ID_INVALID != sessionId )
9012 {
9013 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009014 if(!pSession)
9015 {
9016 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9017 return;
9018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009019 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9020 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9021 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9022 }
9023 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009024 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9025 sessionId = csrFindIbssSession( pMac );
9026 if( CSR_SESSION_ID_INVALID != sessionId )
9027 {
9028 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009029 if(!pSession)
9030 {
9031 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9032 return;
9033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009034 // update the connection state information
9035 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009036#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9037 {
9038 vos_log_ibss_pkt_type *pIbssLog;
9039 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009040 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9041 if(pIbssLog)
9042 {
9043 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9044 if(pNewBss)
9045 {
9046 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
9047 if(pNewBss->ssId.length)
9048 {
9049 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
9050 }
9051 pIbssLog->operatingChannel = pNewBss->channelNumber;
9052 }
9053 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9054 {
9055 //***U8 is not enough for beacon interval
9056 pIbssLog->beaconInterval = (v_U8_t)bi;
9057 }
9058 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9059 }
9060 }
9061#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009062 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
9063 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
9064 pSession->pConnectBssDesc,
9065 &Broadcastaddr,
9066 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9067 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9068 roamStatus = eCSR_ROAM_IBSS_IND;
9069 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
9070 pRoamInfo = &roamInfo;
9071 //This BSSID is th ereal BSSID, let's save it
9072 if(pSession->pConnectBssDesc)
9073 {
9074 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
9075 }
9076 // Stop the join IBSS timer in case of join, for
9077 // genuine merge do nothing
9078 if(pSession->ibss_join_pending)
9079 {
9080 pSession->ibss_join_pending = FALSE;
9081 csrRoamStopIbssJoinTimer(pMac, sessionId);
9082 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
9083 }
9084 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009085 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009086 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009087 // detection by LIM that the capabilities of the associated AP have changed.
9088 case eSIR_SME_AP_CAPS_CHANGED:
9089 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009090 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009091 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9092 if( HAL_STATUS_SUCCESS( status ) )
9093 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009094 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9095 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309096 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009097 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9098 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9099 )
9100 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309101 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9102 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009103 }
9104 else
9105 {
9106 smsLog(pMac, LOGW,
9107 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009108 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009109 pMac->roam.curState[sessionId],
9110 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309111 /* We ignore the caps change event if CSR is not in full connected state.
9112 * Send one event to PE to reset limSentCapsChangeNtf
9113 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9114 * otherwise lim cannot send any CAPS change events to SME */
9115 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009116 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009117 }
9118 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309119
Jeff Johnson295189b2012-06-20 16:38:30 -07009120 default:
9121 roamStatus = eCSR_ROAM_FAILED;
9122 result = eCSR_ROAM_RESULT_NONE;
9123 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009124 } // end switch on statusChangeCode
9125 if(eCSR_ROAM_RESULT_NONE != result)
9126 {
9127 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9128 }
9129 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009130 case eWNI_SME_IBSS_NEW_PEER_IND:
9131 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009132#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9133 {
9134 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009135 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9136 if(pIbssLog)
9137 {
9138 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
9139 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9140 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9141 }
9142 }
9143#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009144 sessionId = csrFindIbssSession( pMac );
9145 if( CSR_SESSION_ID_INVALID != sessionId )
9146 {
9147 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009148
9149 if(!pSession)
9150 {
9151 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9152 return;
9153 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009154 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9155 if(pSession->pConnectBssDesc)
9156 {
9157 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9158 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9159 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9160 {
9161 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
9162 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
9163 if(HAL_STATUS_SUCCESS(status))
9164 {
9165 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
9166 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9167 roamInfo.nBeaconLength);
9168 }
9169 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9170 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9171 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9172 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
9173 pSession->pConnectBssDesc->length);
9174 if(HAL_STATUS_SUCCESS(status))
9175 {
9176 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
9177 pSession->pConnectBssDesc->length);
9178 }
9179 if(HAL_STATUS_SUCCESS(status))
9180 {
9181 pRoamInfo = &roamInfo;
9182 }
9183 else
9184 {
9185 if(roamInfo.pbFrames)
9186 {
9187 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9188 }
9189 if(roamInfo.pBssDesc)
9190 {
9191 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9192 }
9193 }
9194 }
9195 else
9196 {
9197 pRoamInfo = &roamInfo;
9198 }
9199 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
9200 pSession->pConnectBssDesc,
9201 &(pIbssPeerInd->peerAddr),
9202 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9203 }
9204 else
9205 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009206 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009207 }
9208 //send up the sec type for the new peer
9209 if (pRoamInfo)
9210 {
9211 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9212 }
9213 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9214 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9215 if(pRoamInfo)
9216 {
9217 if(roamInfo.pbFrames)
9218 {
9219 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9220 }
9221 if(roamInfo.pBssDesc)
9222 {
9223 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9224 }
9225 }
9226 }
9227 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009228 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9229 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9230 sessionId = csrFindIbssSession( pMac );
9231 if( CSR_SESSION_ID_INVALID != sessionId )
9232 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009233#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9234 {
9235 vos_log_ibss_pkt_type *pIbssLog;
9236
9237 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9238 if(pIbssLog)
9239 {
9240 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9241 if(pIbssPeerInd)
9242 {
9243 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9244 }
9245 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9246 }
9247 }
9248#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009249 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009250 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9251 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9252 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9253 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9254 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9255 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9256 }
9257 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009258 case eWNI_SME_SETCONTEXT_RSP:
9259 {
9260 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9261 tListElem *pEntry;
9262 tSmeCmd *pCommand;
9263
9264 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9265 if ( pEntry )
9266 {
9267 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9268 if ( eSmeCommandSetKey == pCommand->command )
9269 {
9270 sessionId = pCommand->sessionId;
9271 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009272
9273 if(!pSession)
9274 {
9275 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9276 return;
9277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009278
9279#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9280 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9281 {
9282 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
9283 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9284 if( pRsp->peerMacAddr[0] & 0x01 )
9285 {
9286 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9287 }
9288 else
9289 {
9290 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9291 }
9292 setKeyEvent.encryptionModeMulticast =
9293 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9294 setKeyEvent.encryptionModeUnicast =
9295 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9296 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9297 setKeyEvent.authMode =
9298 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9299 if( eSIR_SUCCESS != pRsp->statusCode )
9300 {
9301 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9302 }
9303 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9304 }
9305#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9306 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9307 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009308 csrRoamStopWaitForKeyTimer( pMac );
9309
Jeff Johnson295189b2012-06-20 16:38:30 -07009310 //We are done with authentication, whethere succeed or not
9311 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009312 //We do it here because this linkup function is not called after association
9313 //when a key needs to be set.
9314 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9315 {
9316 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9317 }
9318 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009319 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009320 {
9321 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07009322 //Make sure we install the GTK before indicating to HDD as authenticated
9323 //This is to prevent broadcast packets go out after PTK and before GTK.
9324 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
9325 sizeof(tSirMacAddr) ) )
9326 {
Yathish9f22e662012-12-10 14:21:35 -08009327#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9328 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9329 {
9330 tpSirSetActiveModeSetBncFilterReq pMsg;
9331 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
9332 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9333 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9334 pMsg->seesionId = sessionId;
9335 status = palSendMBMessage(pMac->hHdd, pMsg );
9336 }
9337#endif
9338 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009339 }
9340 else
9341 {
9342 result = eCSR_ROAM_RESULT_NONE;
9343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009344 pRoamInfo = &roamInfo;
9345 }
9346 else
9347 {
9348 result = eCSR_ROAM_RESULT_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009349 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...",
Jeff Johnson295189b2012-06-20 16:38:30 -07009350 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9351 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9352 }
9353 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9354 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009355 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9356 // can go ahead and initiate the TSPEC if any are pending
9357 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009358#ifdef FEATURE_WLAN_CCX
9359 //Send Adjacent AP repot to new AP.
9360 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9361 pSession->isPrevApInfoValid &&
9362 pSession->connectedProfile.isCCXAssoc)
9363 {
9364#ifdef WLAN_FEATURE_VOWIFI
9365 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9366#endif
9367 pSession->isPrevApInfoValid = FALSE;
9368 }
9369#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009370 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9371 {
9372 csrReleaseCommandSetKey( pMac, pCommand );
9373 }
9374 }
9375 else
9376 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009377 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009378 }
9379 }
9380 else
9381 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009382 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009383 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009384 smeProcessPendingQueue( pMac );
9385 }
9386 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009387 case eWNI_SME_REMOVEKEY_RSP:
9388 {
9389 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9390 tListElem *pEntry;
9391 tSmeCmd *pCommand;
9392
9393 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9394 if ( pEntry )
9395 {
9396 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9397 if ( eSmeCommandRemoveKey == pCommand->command )
9398 {
9399 sessionId = pCommand->sessionId;
9400 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009401
9402 if(!pSession)
9403 {
9404 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9405 return;
9406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009407#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9408 {
9409 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9410 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9411 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9412 removeKeyEvent.encryptionModeMulticast =
9413 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9414 removeKeyEvent.encryptionModeUnicast =
9415 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9416 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9417 removeKeyEvent.authMode =
9418 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9419 if( eSIR_SUCCESS != pRsp->statusCode )
9420 {
9421 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9422 }
9423 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9424 }
9425#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009426 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009427 {
9428 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9429 result = eCSR_ROAM_RESULT_NONE;
9430 pRoamInfo = &roamInfo;
9431 }
9432 else
9433 {
9434 result = eCSR_ROAM_RESULT_FAILURE;
9435 }
9436 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9437 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9438 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9439 {
9440 csrReleaseCommandRemoveKey( pMac, pCommand );
9441 }
9442 }
9443 else
9444 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009445 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009446 }
9447 }
9448 else
9449 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009450 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009452 smeProcessPendingQueue( pMac );
9453 }
9454 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009455 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009456 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009457 csrRoamStatsRspProcessor( pMac, pSirMsg );
9458 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009459#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9460 case eWNI_SME_GET_ROAM_RSSI_RSP:
9461 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9462 csrRoamRssiRspProcessor( pMac, pSirMsg );
9463 break;
9464#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009465 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009466 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 csrUpdateRssi( pMac, pSirMsg );
9468 break;
9469
Jeff Johnson295189b2012-06-20 16:38:30 -07009470#ifdef WLAN_FEATURE_VOWIFI_11R
9471 case eWNI_SME_FT_PRE_AUTH_RSP:
9472 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9473 break;
9474#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009475 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9476 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009477 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 -07009478 sessionId = pSmeMaxAssocInd->sessionId;
9479 roamInfo.sessionId = sessionId;
9480 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9481 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9482 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9483 break;
9484
9485 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009486 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009487 btampEstablishLogLinkHdlr( pSirMsg );
9488 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009489 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009490 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009491 csrRoamRssiIndHdlr( pMac, pSirMsg );
9492 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009493#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9494 case eWNI_SME_CANDIDATE_FOUND_IND:
9495 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
9496 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
9497 break;
9498#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009499
9500 default:
9501 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009502 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009503}
9504
Jeff Johnson295189b2012-06-20 16:38:30 -07009505void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9506 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9507{
9508 if(pSession)
9509 {
9510 if(pSession->bRefAssocStartCnt)
9511 {
9512 pSession->bRefAssocStartCnt--;
9513 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9514 //Need to call association_completion because there is an assoc_start pending.
9515 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9516 eCSR_ROAM_ASSOCIATION_COMPLETION,
9517 eCSR_ROAM_RESULT_FAILURE);
9518 }
9519 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9520 }
9521 else
9522 {
9523 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9524 }
9525}
9526
9527
9528eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9529{
9530 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009531 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9532 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9533 {
9534 status = csrScanRequestLostLink1( pMac, sessionId );
9535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009536 return(status);
9537}
9538
Jeff Johnson295189b2012-06-20 16:38:30 -07009539//return a boolean to indicate whether roaming completed or continue.
9540tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9541 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9542{
9543 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9544 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9545 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9546 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009547 if(!pSession)
9548 {
9549 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9550 return eANI_BOOLEAN_FALSE;
9551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009552 //Check whether time is up
9553 if(pSession->fCancelRoaming || fForce ||
9554 ((curTime - pSession->roamingStartTime) > roamTime) ||
9555 eCsrReassocRoaming == pSession->roamingReason ||
9556 eCsrDynamicRoaming == pSession->roamingReason)
9557 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009558 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009559 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9560 {
9561 //roaming is cancelled, tell HDD to indicate disconnect
9562 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9563 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9564 //to be eSIR_BEACON_MISSED
9565 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9566 {
9567 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9568 }
9569 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9570 {
9571 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9572 }
9573 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9574 {
9575 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9576 }
9577 else
9578 {
9579 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9580 }
9581 }
9582 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9583 pSession->roamingReason = eCsrNotRoaming;
9584 }
9585 else
9586 {
9587 pSession->roamResult = roamResult;
9588 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9589 {
9590 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9591 pSession->roamingReason = eCsrNotRoaming;
9592 }
9593 else
9594 {
9595 fCompleted = eANI_BOOLEAN_FALSE;
9596 }
9597 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009598 return(fCompleted);
9599}
9600
Jeff Johnson295189b2012-06-20 16:38:30 -07009601void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9602{
9603 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009604
9605 if(!pSession)
9606 {
9607 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9608 return;
9609 }
9610
Jeff Johnson295189b2012-06-20 16:38:30 -07009611 if(CSR_IS_ROAMING(pSession))
9612 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009613 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -07009614 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9615 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9616 {
9617 //No need to do anything in here because the handler takes care of it
9618 }
9619 else
9620 {
9621 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9622 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9623 //Roaming is stopped after here
9624 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9625 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
9626 csrScanAbortMacScan(pMac);
9627 csrRoamStopRoamingTimer(pMac, sessionId);
9628 }
9629 }
9630}
9631
Jeff Johnson295189b2012-06-20 16:38:30 -07009632void csrRoamRoamingTimerHandler(void *pv)
9633{
9634 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9635 tpAniSirGlobal pMac = pInfo->pMac;
9636 tANI_U32 sessionId = pInfo->sessionId;
9637 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009638
9639 if(!pSession)
9640 {
9641 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9642 return;
9643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009644
9645 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9646 {
9647 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9648 {
9649 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9650 pSession->roamingReason = eCsrNotRoaming;
9651 }
9652 }
9653}
9654
Jeff Johnson295189b2012-06-20 16:38:30 -07009655eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9656{
9657 eHalStatus status;
9658 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009659
9660 if(!pSession)
9661 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009662 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009663 return eHAL_STATUS_FAILURE;
9664 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009665
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009666 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
9668 status = palTimerStart(pMac->hHdd, pSession->hTimerRoaming, interval, eANI_BOOLEAN_FALSE);
9669
9670 return (status);
9671}
9672
Jeff Johnson295189b2012-06-20 16:38:30 -07009673eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9674{
9675 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerRoaming));
9676}
9677
Jeff Johnson295189b2012-06-20 16:38:30 -07009678void csrRoamWaitForKeyTimeOutHandler(void *pv)
9679{
9680 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9681 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009682 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9683
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009684 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009685 pMac->roam.neighborRoamInfo.neighborRoamState,
9686 pMac->roam.curSubState[pInfo->sessionId]);
9687
Jeff Johnson295189b2012-06-20 16:38:30 -07009688 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9689 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009690#ifdef FEATURE_WLAN_LFR
9691 if (csrNeighborRoamIsHandoffInProgress(pMac))
9692 {
9693 /*
9694 * Enable heartbeat timer when hand-off is in progress
9695 * and Key Wait timer expired.
9696 */
9697 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009698 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009699 pMac->roam.configParam.HeartbeatThresh24);
9700 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9701 pMac->roam.configParam.HeartbeatThresh24,
9702 NULL, eANI_BOOLEAN_FALSE);
9703 }
9704#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009705 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Jeff Johnson295189b2012-06-20 16:38:30 -07009706 //Change the substate so command queue is unblocked.
9707 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009708 if (pSession)
9709 {
9710 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9711 {
9712 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9713 smeProcessPendingQueue(pMac);
9714 }
9715 else
9716 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009717 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009718 __func__);
9719 }
9720 }
9721 else
9722 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009723 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 }
9726
9727}
9728
Jeff Johnson295189b2012-06-20 16:38:30 -07009729eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9730{
9731 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009732#ifdef FEATURE_WLAN_LFR
9733 if (csrNeighborRoamIsHandoffInProgress(pMac))
9734 {
9735 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009736 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009737 __func__,
9738 pMac->roam.neighborRoamInfo.neighborRoamState,
9739 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9740 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9741 }
9742#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009743 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009744 status = palTimerStart(pMac->hHdd, pMac->roam.hTimerWaitForKey, interval, eANI_BOOLEAN_FALSE);
9745
9746 return (status);
9747}
9748
Jeff Johnson295189b2012-06-20 16:38:30 -07009749eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9750{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009751 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009752 pMac->roam.neighborRoamInfo.neighborRoamState,
9753 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9754#ifdef FEATURE_WLAN_LFR
9755 if (csrNeighborRoamIsHandoffInProgress(pMac))
9756 {
9757 /*
9758 * Enable heartbeat timer when hand-off is in progress
9759 * and Key Wait timer got stopped for some reason
9760 */
9761 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009762 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009763 pMac->roam.configParam.HeartbeatThresh24);
9764 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9765 pMac->roam.configParam.HeartbeatThresh24,
9766 NULL, eANI_BOOLEAN_FALSE);
9767 }
9768#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009769 return (palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey));
9770}
9771
Jeff Johnson295189b2012-06-20 16:38:30 -07009772void csrRoamIbssJoinTimerHandler(void *pv)
9773{
9774 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9775 tpAniSirGlobal pMac = pInfo->pMac;
9776 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9777 tANI_U32 sessionId = pInfo->sessionId;
9778 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009779
9780 if(!pSession)
9781 {
9782 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9783 return;
9784 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009785
9786 pSession->ibss_join_pending = FALSE;
9787 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9788 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9789 // Send an IBSS stop request to PE
9790 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009791}
Jeff Johnson295189b2012-06-20 16:38:30 -07009792eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9793{
9794 eHalStatus status;
9795 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009796
9797 if(!pSession)
9798 {
9799 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9800 return eHAL_STATUS_FAILURE;
9801 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009802
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009803 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009804 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
9805 status = palTimerStart(pMac->hHdd, pSession->hTimerIbssJoining, interval, eANI_BOOLEAN_FALSE);
9806
9807 return (status);
9808}
Jeff Johnson295189b2012-06-20 16:38:30 -07009809eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9810{
9811 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerIbssJoining));
9812}
Jeff Johnson295189b2012-06-20 16:38:30 -07009813void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9814 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9815{
9816 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9817 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009818 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9819 /* To silence the KW tool Null chaeck is added */
9820 if(!pSession)
9821 {
9822 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9823 return;
9824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009825
9826 if(pCommand)
9827 {
9828 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009829 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009831 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9832 {
9833 //if success, force roaming completion
9834 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9835 }
9836 else
9837 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009838 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009839 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07009840 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9841 }
9842}
9843
Jeff Johnson295189b2012-06-20 16:38:30 -07009844eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9845{
9846 eHalStatus status = eHAL_STATUS_SUCCESS;
9847 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9848 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9849 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9850 tCsrRoamInfo *pRoamInfo = NULL;
9851 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009852 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07009853 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009854 /* To silence the KW tool Null chaeck is added */
9855 if(!pSession)
9856 {
9857 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9858 return eHAL_STATUS_FAILURE;
9859 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009860 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009861 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07009862 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9863 if ( eWNI_SME_DISASSOC_IND == type )
9864 {
9865 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9866 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9867 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009868 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009869 }
9870 else if ( eWNI_SME_DEAUTH_IND == type )
9871 {
9872 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9873 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9874 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -08009875 /* Convert into proper reason code */
9876 pSession->joinFailStatusCode.reasonCode =
9877 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +05309878 0 : pDeauthIndMsg->reasonCode;
9879 /* cfg layer expects 0 as reason code if
9880 the driver dosent know the reason code
9881 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 }
9883 else
9884 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009885 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009886 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009887 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009888 }
9889
9890 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -07009891 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009892 {
9893 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
9894 }
9895
9896 if ( eWNI_SME_DISASSOC_IND == type )
9897 {
9898 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
9899 }
9900 else if ( eWNI_SME_DEAUTH_IND == type )
9901 {
9902 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
9903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009904 if(!HAL_STATUS_SUCCESS(status))
9905 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009906 //If fail to send confirmation to PE, not to trigger roaming
9907 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009908 }
9909
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009910 //prepare to tell HDD to disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -07009911 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9912 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9913 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009914 if( eWNI_SME_DISASSOC_IND == type)
9915 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009916 //staMacAddr
9917 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9918 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9919 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009920 else if( eWNI_SME_DEAUTH_IND == type )
9921 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009922 //staMacAddr
9923 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9924 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9925 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009926 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009927
9928 /* See if we can possibly roam. If so, start the roaming process and notify HDD
9929 that we are roaming. But if we cannot possibly roam, or if we are unable to
9930 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -07009931 if(fToRoam)
9932 {
9933 //Only remove the connected BSS in infrastructure mode
9934 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9935 //Not to do anying for lostlink with WDS
9936 if( pMac->roam.configParam.nRoamingTime )
9937 {
9938 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
9939 ( eWNI_SME_DEAUTH_IND == type ) ?
9940 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
9941 {
9942 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9943 //For IBSS, we need to give some more info to HDD
9944 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
9945 {
9946 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9947 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9948 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
9949 }
9950 else
9951 {
9952 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
9953 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009954 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009955 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
9956 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
9957 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9958 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
9959 }
9960 else
9961 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009962 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009963 fToRoam = eANI_BOOLEAN_FALSE;
9964 }
9965 }
9966 else
9967 {
9968 //We are told not to roam, indicate lostlink
9969 fToRoam = eANI_BOOLEAN_FALSE;
9970 }
9971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009972 if(!fToRoam)
9973 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -07009974 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009975 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009976 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009977 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
9978 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
9979 * csrRoamCheckForLinkStatusChange API.
9980 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009981 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
9982 }
9983
9984 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -07009985 Still enable idle scan for polling in case concurrent sessions are running */
9986 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
9987 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009988 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07009989 }
9990 }
9991
9992 return (status);
9993}
9994
Jeff Johnson295189b2012-06-20 16:38:30 -07009995eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
9996{
9997 eHalStatus status = eHAL_STATUS_SUCCESS;
9998 tListElem *pEntry = NULL;
9999 tSmeCmd *pCommand = NULL;
10000 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010001
10002 if(!pSession)
10003 {
10004 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10005 return eHAL_STATUS_FAILURE;
10006 }
10007
Jeff Johnson295189b2012-06-20 16:38:30 -070010008 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010009 //Only remove the connected BSS in infrastructure mode
10010 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10011 if(pMac->roam.configParam.nRoamingTime)
10012 {
10013 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10014 {
10015 //before starting the lost link logic release the roam command for handoff
10016 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10017 if(pEntry)
10018 {
10019 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10020 }
10021 if(pCommand)
10022 {
10023 if (( eSmeCommandRoam == pCommand->command ) &&
10024 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10025 {
10026 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10027 {
10028 csrReleaseCommandRoam( pMac, pCommand );
10029 }
10030 }
10031 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010032 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 }
10034 }
10035 else
10036 {
10037 //We are told not to roam, indicate lostlink
10038 status = eHAL_STATUS_FAILURE;
10039 }
10040
10041 return (status);
10042}
Jeff Johnson295189b2012-06-20 16:38:30 -070010043void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10044{
10045 tListElem *pEntry;
10046 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010047 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10048 if ( pEntry )
10049 {
10050 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10051 if ( eSmeCommandWmStatusChange == pCommand->command )
10052 {
10053 // Nothing to process in a Lost Link completion.... It just kicks off a
10054 // roaming sequence.
10055 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10056 {
10057 csrReleaseCommandWmStatusChange( pMac, pCommand );
10058 }
10059 else
10060 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010061 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010062 }
10063
10064 }
10065 else
10066 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010067 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010068 }
10069 }
10070 else
10071 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010072 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010073 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010074 smeProcessPendingQueue( pMac );
10075}
10076
Jeff Johnson295189b2012-06-20 16:38:30 -070010077void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10078{
10079 eHalStatus status = eHAL_STATUS_FAILURE;
10080 tSirSmeRsp *pSirSmeMsg;
10081 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010082
10083 if(!pSession)
10084 {
10085 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10086 return;
10087 }
10088
Jeff Johnson295189b2012-06-20 16:38:30 -070010089 switch ( pCommand->u.wmStatusChangeCmd.Type )
10090 {
10091 case eCsrDisassociated:
10092 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10093 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10094 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010095 case eCsrDeauthenticated:
10096 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10097 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10098 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010099 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010100 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010101 break;
10102 }
10103 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10104 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10105 {
10106 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10107 {
10108 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010109 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010110 }
10111 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010112 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10113 // command here since there is nothing else to do.
10114 csrRoamWmStatusChangeComplete( pMac );
10115}
10116
Jeff Johnson295189b2012-06-20 16:38:30 -070010117//This function returns band and mode information.
10118//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10119//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010120static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10121 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010122{
Jeff Johnson295189b2012-06-20 16:38:30 -070010123 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10124 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10125 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010126 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010127
Jeff Johnson295189b2012-06-20 16:38:30 -070010128 //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 -070010129 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10130 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10131 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10132 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010133 {
10134 switch( pMac->roam.configParam.uCfgDot11Mode )
10135 {
10136 case eCSR_CFG_DOT11_MODE_11A:
10137 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10138 eBand = eCSR_BAND_5G;
10139 break;
10140 case eCSR_CFG_DOT11_MODE_11B:
10141 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10142 eBand = eCSR_BAND_24;
10143 break;
10144 case eCSR_CFG_DOT11_MODE_11G:
10145 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10146 eBand = eCSR_BAND_24;
10147 break;
10148 case eCSR_CFG_DOT11_MODE_11N:
10149 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10150 eBand = eCSR_BAND_24;
10151 break;
10152 //case eCSR_CFG_DOT11_MODE_BEST:
10153 // cfgDot11Mode = eCSR_CFG_DOT11_MODE_BEST;
10154 // eBand = eCSR_BAND_24;
10155 // break;
10156 default:
10157 // Global dot11 Mode setting is 11a/b/g.
10158 // use the channel number to determine the Mode setting.
10159 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10160 {
10161 eBand = pMac->roam.configParam.eBand;
10162 if(eCSR_BAND_24 == eBand)
10163 {
10164 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10165 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10166 }
10167 else
10168 {
10169 //prefer 5GHz
10170 eBand = eCSR_BAND_5G;
10171 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10172 }
10173 }
10174 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10175 {
10176 // channel is a 2.4GHz channel. Set mode to 11g.
10177 //
10178 // !!LAC - WiFi tests require IBSS networks to start in 11b mode without any change to the
10179 // default parameter settings on the adapter. We use ACU to start an IBSS through creation
10180 // of a startIBSS profile. this startIBSS profile has Auto MACProtocol and the
10181 // adapter property setting for dot11Mode is also AUTO. So in this case, let's start
10182 // the IBSS network in 11b mode instead of 11g mode.
10183 //
10184 // so this is for Auto=profile->MacProtocol && Auto=Global.dot11Mode && profile->channel is < 14,
10185 // then start the IBSS in b mode.
10186 //
10187 // Note: we used to have this start as an 11g IBSS for best performance... now to specify that
10188 // the user will have to set the do11Mode in the property page to 11g to force it.
10189 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10190 eBand = eCSR_BAND_24;
10191 }
10192 else
10193 {
10194 // else, it's a 5.0GHz channel. Set mode to 11a.
10195 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10196 eBand = eCSR_BAND_5G;
10197 }
10198 break;
10199 }//switch
10200 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10201 else
10202 {
10203 //dot11 mode is set, lets pick the band
10204 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10205 {
10206 // channel is Auto also.
10207 eBand = pMac->roam.configParam.eBand;
10208 if(eCSR_BAND_ALL == eBand)
10209 {
10210 //prefer 5GHz
10211 eBand = eCSR_BAND_5G;
10212 }
10213 }
10214 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10215 {
10216 eBand = eCSR_BAND_24;
10217 }
10218 else
10219 {
10220 eBand = eCSR_BAND_5G;
10221 }
10222 }
10223 if(pBand)
10224 {
10225 *pBand = eBand;
10226 }
10227
10228 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010229 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010230 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10231 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010232
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010233 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10234 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 -070010235 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010236#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010237 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010238#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010239 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10240 {
10241 //We cannot do 11n here
10242 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10243 {
10244 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10245 }
10246 else
10247 {
10248 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10249 }
10250 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010251 return( cfgDot11Mode );
10252}
10253
Jeff Johnson295189b2012-06-20 16:38:30 -070010254eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10255{
10256 eHalStatus status;
10257 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010258
10259 if(!pSession)
10260 {
10261 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10262 return eHAL_STATUS_FAILURE;
10263 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010264
10265#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10266 {
10267 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010268 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10269 if(pIbssLog)
10270 {
10271 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10272 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10273 }
10274 }
10275#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010276 pSession->ibss_join_pending = FALSE;
10277 csrRoamStopIbssJoinTimer(pMac, sessionId );
10278 // Set the roaming substate to 'stop Bss request'...
10279 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10280
10281 // attempt to stop the Bss (reason code is ignored...)
10282 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010283 if(!HAL_STATUS_SUCCESS(status))
10284 {
10285 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10286 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010287 return (status);
10288}
10289
Jeff Johnson295189b2012-06-20 16:38:30 -070010290//pNumChan is a caller allocated space with the sizeof pChannels
10291eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10292{
10293
10294 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10295 (tANI_U8 *)pChannels,
10296 pNumChan));
10297}
10298
Kiran4a17ebe2013-01-31 10:43:43 -080010299tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10300{
10301 tANI_U32 cfgLength = 0;
10302 tANI_U16 cfgId = 0;
10303 tPowerdBm maxTxPwr = 0;
10304 tANI_U8 *pCountryInfo = NULL;
10305 eHalStatus status;
10306 tANI_U8 count = 0;
10307 tANI_U8 firstChannel;
10308 tANI_U8 maxChannels;
10309
10310 if (CSR_IS_CHANNEL_5GHZ(channel))
10311 {
10312 cfgId = WNI_CFG_MAX_TX_POWER_5;
10313 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10314 }
10315 else if (CSR_IS_CHANNEL_24GHZ(channel))
10316 {
10317 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10318 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10319 }
10320 else
10321 return maxTxPwr;
10322
10323 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10324 if (status != eHAL_STATUS_SUCCESS)
10325 {
10326 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10327 FL("%s: palAllocateMemory() failed, status = %d"),
10328 __FUNCTION__, status);
10329 goto error;
10330 }
10331 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10332 if (status != eHAL_STATUS_SUCCESS)
10333 {
10334 goto error;
10335 }
10336 /* Identify the channel and maxtxpower */
10337 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10338 {
10339 firstChannel = pCountryInfo[count++];
10340 maxChannels = pCountryInfo[count++];
10341 maxTxPwr = pCountryInfo[count++];
10342
10343 if ((channel >= firstChannel) &&
10344 (channel < (firstChannel + maxChannels)))
10345 {
10346 break;
10347 }
10348 }
10349
10350error:
10351 if (NULL != pCountryInfo)
10352 palFreeMemory(pMac->hHdd, pCountryInfo);
10353
10354 return maxTxPwr;
10355}
10356
10357
Jeff Johnson295189b2012-06-20 16:38:30 -070010358tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10359{
10360 tANI_BOOLEAN fValid = FALSE;
10361 tANI_U32 idxValidChannels;
10362 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10363
10364 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10365 {
10366 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10367 {
10368 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10369 {
10370 fValid = TRUE;
10371 break;
10372 }
10373 }
10374 }
10375 pMac->roam.numValidChannels = len;
10376 return fValid;
10377}
10378
Jeff Johnson295189b2012-06-20 16:38:30 -070010379tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10380{
10381 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10382 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010383 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10384 {
10385 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10386 {
10387 fValid = eANI_BOOLEAN_TRUE;
10388 break;
10389 }
10390 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010391 return (fValid);
10392}
10393
Jeff Johnson295189b2012-06-20 16:38:30 -070010394//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010395 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010396{
Jeff Johnsone7245742012-09-05 17:12:55 -070010397 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010398 tANI_U8 centerChn;
10399 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010400 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10401 {
10402 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10403 }
10404 else
10405 {
10406 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10407 }
10408 //Figure what the other side's CB mode
10409 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10410 {
10411 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10412 {
10413 if(pIes->HTInfo.present)
10414 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010415 /* This is called during INFRA STA/CLIENT and should use the merged value of
10416 * supported channel width and recommended tx width as per standard
10417 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010418 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010419 pIes->HTCaps.supportedChannelWidthSet,
10420 pIes->HTInfo.recommendedTxWidthSet,
10421 pIes->HTInfo.secondaryChannelOffset);
10422
10423 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10424 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010425 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010426 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10427 switch (eRet) {
10428 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10429 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10430 break;
10431 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10432 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10433 break;
10434 case PHY_SINGLE_CHANNEL_CENTERED:
10435 default:
10436 centerChn = primaryChn;
10437 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010438 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010439 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010440 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010441 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070010442 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010443 }
10444 }
10445 }
10446 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010447 return eRet;
10448}
Jeff Johnson295189b2012-06-20 16:38:30 -070010449tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10450{
10451 tANI_BOOLEAN fFound = FALSE;
10452 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010453 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10454 {
10455 if( pCipherList->encryptionType[idx] == encryptionType )
10456 {
10457 fFound = TRUE;
10458 break;
10459 }
10460 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010461 return fFound;
10462}
Jeff Johnson295189b2012-06-20 16:38:30 -070010463tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10464{
10465 tANI_BOOLEAN fFound = FALSE;
10466 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010467 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10468 {
10469 if( pAuthList->authType[idx] == authType )
10470 {
10471 fFound = TRUE;
10472 break;
10473 }
10474 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010475 return fFound;
10476}
Jeff Johnson295189b2012-06-20 16:38:30 -070010477tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10478{
10479 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10480 tCsrScanResultFilter *pScanFilter = NULL;
10481 eHalStatus status = eHAL_STATUS_SUCCESS;
10482
10483 if(pProfile1 && pProfile2)
10484 {
10485 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10486 if(HAL_STATUS_SUCCESS(status))
10487 {
10488 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10489 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10490 if(HAL_STATUS_SUCCESS(status))
10491 {
10492 fCheck = eANI_BOOLEAN_FALSE;
10493 do
10494 {
10495 tANI_U32 i;
10496 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10497 {
10498 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10499 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10500 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10501 if ( fCheck ) break;
10502 }
10503 if(!fCheck)
10504 {
10505 break;
10506 }
10507 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10508 || pProfile2->BSSType != pProfile1->BSSType
10509 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10510 )
10511 {
10512 fCheck = eANI_BOOLEAN_FALSE;
10513 break;
10514 }
10515#ifdef WLAN_FEATURE_VOWIFI_11R
10516 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10517 {
10518 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10519 {
10520 fCheck = eANI_BOOLEAN_FALSE;
10521 break;
10522 }
10523 }
10524#endif
10525 //Match found
10526 fCheck = eANI_BOOLEAN_TRUE;
10527 }while(0);
10528 csrFreeScanFilter(pMac, pScanFilter);
10529 }
10530 palFreeMemory(pMac->hHdd, pScanFilter);
10531 }
10532 }
10533
10534 return (fCheck);
10535}
10536
Jeff Johnson295189b2012-06-20 16:38:30 -070010537tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10538{
10539 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10540 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010541 do
10542 {
10543 //Only check for static WEP
10544 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10545 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10546 {
10547 fCheck = eANI_BOOLEAN_TRUE;
10548 break;
10549 }
10550 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10551 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10552 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10553 {
10554 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10555 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10556 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10557 {
10558 break;
10559 }
10560 }
10561 if( i == CSR_MAX_NUM_KEY)
10562 {
10563 fCheck = eANI_BOOLEAN_TRUE;
10564 }
10565 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010566 return (fCheck);
10567}
10568
Jeff Johnson295189b2012-06-20 16:38:30 -070010569//IBSS
10570
Jeff Johnson295189b2012-06-20 16:38:30 -070010571tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10572{
10573 tANI_U8 channel = 0;
10574 tANI_U32 idx;
10575 tANI_U32 idxValidChannels;
10576 tANI_BOOLEAN fFound = FALSE;
10577 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10578
10579 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10580 {
10581 channel = pMac->roam.configParam.AdHocChannel5G;
10582 if(!csrRoamIsChannelValid(pMac, channel))
10583 {
10584 channel = 0;
10585 }
10586 }
10587 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10588 {
10589 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10590 {
10591 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10592 {
10593 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10594 {
10595 fFound = TRUE;
10596 channel = csrStartIbssChannels50[ idx ];
10597 }
10598 }
10599 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010600 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10601 if (!fFound)
10602 {
10603 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10604 {
10605 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10606 {
10607 channel = csrStartIbssChannels50[ idx ];
10608 break;
10609 }
10610 }
10611 }
10612 }//if
10613
10614 return( channel );
10615}
10616
Jeff Johnson295189b2012-06-20 16:38:30 -070010617tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10618{
10619 tANI_U8 channel = 1;
10620 tANI_U32 idx;
10621 tANI_U32 idxValidChannels;
10622 tANI_BOOLEAN fFound = FALSE;
10623 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10624
10625 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10626 {
10627 channel = pMac->roam.configParam.AdHocChannel24;
10628 if(!csrRoamIsChannelValid(pMac, channel))
10629 {
10630 channel = 0;
10631 }
10632 }
10633
10634 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10635 {
10636 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10637 {
10638 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10639 {
10640 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10641 {
10642 fFound = TRUE;
10643 channel = csrStartIbssChannels24[ idx ];
10644 }
10645 }
10646 }
10647 }
10648
10649 return( channel );
10650}
10651
Jeff Johnson295189b2012-06-20 16:38:30 -070010652static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10653 tCsrRoamStartBssParams *pParam )
10654{
10655 eCsrCfgDot11Mode cfgDot11Mode;
10656 eCsrBand eBand;
10657 tANI_U8 channel = 0;
10658 tSirNwType nwType;
10659 tANI_U8 operationChannel = 0;
10660
10661 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10662 {
10663 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10664 }
10665
Jeff Johnson295189b2012-06-20 16:38:30 -070010666 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010667
Jeff Johnson295189b2012-06-20 16:38:30 -070010668 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10669 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10670 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10671 )
10672 {
10673 /* This should never happen */
10674 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010675 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010676 pProfile->csrPersona);
10677 VOS_ASSERT(0);
10678 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010679 switch( cfgDot11Mode )
10680 {
10681 case eCSR_CFG_DOT11_MODE_11G:
10682 nwType = eSIR_11G_NW_TYPE;
10683 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010684 case eCSR_CFG_DOT11_MODE_11B:
10685 nwType = eSIR_11B_NW_TYPE;
10686 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010687 case eCSR_CFG_DOT11_MODE_11A:
10688 nwType = eSIR_11A_NW_TYPE;
10689 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010690 default:
10691 case eCSR_CFG_DOT11_MODE_11N:
10692 case eCSR_CFG_DOT11_MODE_TAURUS:
10693 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10694 if(eCSR_BAND_24 == eBand)
10695 {
10696 nwType = eSIR_11G_NW_TYPE;
10697 }
10698 else
10699 {
10700 nwType = eSIR_11A_NW_TYPE;
10701 }
10702 break;
10703 }
10704
10705 pParam->extendedRateSet.numRates = 0;
10706
10707 switch ( nwType )
10708 {
10709 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010710 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070010711 case eSIR_11A_NW_TYPE:
10712
10713 pParam->operationalRateSet.numRates = 8;
10714
10715 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10716 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10717 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10718 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10719 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10720 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10721 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10722 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10723
10724 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10725 {
10726 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10727 if( 0 == channel &&
10728 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10729 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10730 )
10731 {
10732 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10733 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10734 nwType = eSIR_11B_NW_TYPE;
10735 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10736 pParam->operationalRateSet.numRates = 4;
10737 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10738 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10739 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10740 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10741 }
10742 }
10743 else
10744 {
10745 channel = operationChannel;
10746 }
10747 break;
10748
10749 case eSIR_11B_NW_TYPE:
10750 pParam->operationalRateSet.numRates = 4;
10751 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10752 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10753 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10754 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010755 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10756 {
10757 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10758 }
10759 else
10760 {
10761 channel = operationChannel;
10762 }
10763
10764 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010765 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070010766 /* For P2P Client and P2P GO, disable 11b rates */
10767 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10768 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10769 )
10770 {
10771 pParam->operationalRateSet.numRates = 8;
10772
10773 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10774 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10775 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10776 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10777 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10778 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10779 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10780 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10781 }
10782 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010783 {
10784 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010785 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10786 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10787 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10788 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10789
10790 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010791 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10792 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10793 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10794 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10795 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10796 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10797 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10798 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10799 }
10800
10801 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10802 {
10803 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10804 }
10805 else
10806 {
10807 channel = operationChannel;
10808 }
10809
10810 break;
10811 }
10812 pParam->operationChn = channel;
10813 pParam->sirNwType = nwType;
10814}
10815
Jeff Johnson295189b2012-06-20 16:38:30 -070010816static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10817 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10818{
10819
10820 if( pParam )
10821 {
10822 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070010823 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010824 pParam->operationChn = pBssDesc->channelId;
10825 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
10826
10827 if( pIes )
10828 {
10829 if(pIes->SuppRates.present)
10830 {
10831 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
10832 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
10833 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010834 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 -070010835 pIes->SuppRates.num_rates);
10836 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
10837 }
10838 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
10839 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
10840 }
10841 if( pIes->SSID.present )
10842 {
10843 pParam->ssId.length = pIes->SSID.num_ssid;
10844 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
10845 }
10846 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070010847 }
10848 else
10849 {
10850 pParam->ssId.length = 0;
10851 pParam->operationalRateSet.numRates = 0;
10852 }
10853 }
10854}
10855
Jeff Johnson295189b2012-06-20 16:38:30 -070010856static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
10857{
10858 tANI_U8 MaxRate = 0;
10859 tANI_U32 i;
10860 tANI_U8 *pRate;
10861
10862 pRate = pSirRateSet->rate;
10863 for ( i = 0; i < pSirRateSet->numRates; i++ )
10864 {
10865 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
10866 }
10867
10868 // Save the max rate in the connected state information...
10869
10870 // modify LastRates variable as well
10871
10872 return;
10873}
10874
Jeff Johnson295189b2012-06-20 16:38:30 -070010875//this function finds a valid secondary channel for channel bonding with "channel".
10876//Param: channel -- primary channel, caller must validate it
10877// cbChoice -- CB directory
10878//Return: if 0, no secondary channel is found. Otherwise a valid secondary channel.
10879static tANI_U8 csrRoamGetSecondaryChannel(tpAniSirGlobal pMac, tANI_U8 channel, eCsrCBChoice cbChoice)
10880{
10881 tANI_U8 chnUp = 0, chnDown = 0, chnRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010882 switch (cbChoice)
10883 {
10884 case eCSR_CB_OFF:
10885 chnUp = 0;
10886 chnDown = 0;
10887 break;
10888 case eCSR_CB_DOWN:
10889 chnUp = 0;
10890 chnDown = channel - CSR_CB_CHANNEL_GAP;
10891 break;
10892 case eCSR_CB_UP:
10893 chnUp = channel + CSR_CB_CHANNEL_GAP;
10894 chnDown = 0;
10895 break;
10896 case eCSR_CB_AUTO:
10897 //consider every other value means auto
10898 default:
10899 chnUp = channel + CSR_CB_CHANNEL_GAP;
10900 chnDown = channel - CSR_CB_CHANNEL_GAP;
10901 break;
10902 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010903 //if CB_UP or auto, try channel up first
10904 if(chnUp && CSR_IS_SAME_BAND_CHANNELS(chnUp, channel) && csrRoamIsChannelValid(pMac, chnUp))
10905 {
10906 //found a valid up channel for channel bonding
10907 //check whether the center channel is valid
10908 if(csrRoamIsValid40MhzChannel(pMac, channel + CSR_CB_CENTER_CHANNEL_OFFSET))
10909 {
10910 chnRet = chnUp;
10911 }
10912 }
10913 if(chnRet == 0 && chnDown && CSR_IS_SAME_BAND_CHANNELS(chnDown, channel) && csrRoamIsChannelValid(pMac, chnDown))
10914 {
10915 //found a valid down channel for channel bonding
10916 if(csrRoamIsValid40MhzChannel(pMac, channel - CSR_CB_CENTER_CHANNEL_OFFSET))
10917 {
10918 chnRet = chnDown;
10919 }
10920 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010921 return chnRet;
10922}
10923
Jeff Johnson295189b2012-06-20 16:38:30 -070010924eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
10925 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
10926{
10927 eHalStatus status = eHAL_STATUS_SUCCESS;
10928 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010929 // Set the roaming substate to 'Start BSS attempt'...
10930 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010931#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10932 //Need to figure out whether we need to log WDS???
10933 if( CSR_IS_IBSS( pProfile ) )
10934 {
10935 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010936 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10937 if(pIbssLog)
10938 {
10939 if(pBssDesc)
10940 {
10941 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
10942 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
10943 }
10944 else
10945 {
10946 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
10947 }
10948 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
10949 pParam->ssId.length);
10950 if(pProfile->ChannelInfo.numOfChannels == 0)
10951 {
10952 pIbssLog->channelSetting = AUTO_PICK;
10953 }
10954 else
10955 {
10956 pIbssLog->channelSetting = SPECIFIED;
10957 }
10958 pIbssLog->operatingChannel = pParam->operationChn;
10959 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10960 }
10961 }
10962#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10963 //Put RSN information in for Starting BSS
10964 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
10965 pParam->pRSNIE = pProfile->pRSNReqIE;
10966
Jeff Johnson295189b2012-06-20 16:38:30 -070010967 pParam->privacy = pProfile->privacy;
10968 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
10969 pParam->authType = pProfile->csr80211AuthType;
10970 pParam->beaconInterval = pProfile->beaconInterval;
10971 pParam->dtimPeriod = pProfile->dtimPeriod;
10972 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
10973 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
10974 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
10975 {
10976 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
10977 {
10978 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
10979 }
10980 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010981 pParam->protEnabled = pProfile->protEnabled;
10982 pParam->obssProtEnabled = pProfile->obssProtEnabled;
10983 pParam->ht_protection = pProfile->cfg_protection;
10984 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080010985
Jeff Johnson295189b2012-06-20 16:38:30 -070010986 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
10987 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070010988 pParam->bssPersona = pProfile->csrPersona;
10989 // When starting an IBSS, start on the channel from the Profile.
10990 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070010991 return (status);
10992}
10993
Jeff Johnson295189b2012-06-20 16:38:30 -070010994static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070010995 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010996{
10997 tANI_U8 Channel, SecondChn;
Jeff Johnsone7245742012-09-05 17:12:55 -070010998 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010999 eCsrCBChoice cbChoice;
11000 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011001
11002 if(!pSession)
11003 {
11004 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11005 return;
11006 }
11007
Jeff Johnson295189b2012-06-20 16:38:30 -070011008 if( pBssDesc )
11009 {
11010 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11011 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11012 //The following code has to be do after that.
11013 //For WDS station, use selfMac as the self BSSID
11014 if( CSR_IS_WDS_STA( pProfile ) )
11015 {
11016 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11017 }
11018 }
11019 else
11020 {
11021 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011022 //Use the first SSID
11023 if(pProfile->SSIDs.numOfSSIDs)
11024 {
11025 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
11026 }
11027 //For WDS station, use selfMac as the self BSSID
11028 if( CSR_IS_WDS_STA( pProfile ) )
11029 {
11030 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11031 }
11032 //Use the first BSSID
11033 else if( pProfile->BSSIDs.numOfBSSIDs )
11034 {
11035 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
11036 }
11037 else
11038 {
11039 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
11040 }
11041 }
11042 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011043 //Set operating channel in pProfile which will be used
11044 //in csrRoamSetBssConfigCfg() to determine channel bonding
11045 //mode and will be configured in CFG later
11046 pProfile->operationChannel = Channel;
11047
11048 if(Channel == 0)
11049 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011050 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011051 }
11052 else
11053 {
11054
11055 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Jeff Johnsone7245742012-09-05 17:12:55 -070011056 if (CSR_IS_INFRA_AP(pProfile))
11057 {
11058 if(CSR_IS_CHANNEL_24GHZ(Channel))
11059 {
11060 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11061 }
11062 else
11063 {
11064 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11065 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011066 smsLog(pMac, LOG1, "##softap cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011067 pBssConfig->cbMode = cbMode;
11068 pSession->bssParams.cbMode = cbMode;
11069 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011070
11071 if( CSR_IS_START_IBSS( pProfile ) )
11072 {
11073 //TBH: channel bonding is not supported for Libra
11074 if( pProfile->ChannelInfo.ChannelList && eCSR_OPERATING_CHANNEL_AUTO != pProfile->ChannelInfo.ChannelList[0] )
11075 {
11076 Channel = pProfile->ChannelInfo.ChannelList[0];
11077 cbChoice = pProfile->CBMode;
11078 }
11079 else {
11080 cbChoice = pMac->roam.configParam.cbChoice;
11081 }
11082 pSession->bssParams.operationChn = Channel;
11083 //make sure channel is valid
11084 if(!csrRoamIsChannelValid(pMac, Channel))
11085 {
11086 //set Channel to 0 to let lim know this is invalid
11087 //We still send this request down to lim even though we know the channel is wrong because
11088 //lim will response with error and hdd's eWNI_SME_START_BSS_RSP handler will roam other profile (if any)
11089 Channel = 0;
11090 pSession->bssParams.operationChn = 0;
11091 }
11092 else {
11093 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011094 if(CSR_IS_CHANNEL_24GHZ(Channel))
11095 {
11096 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11097 }
11098 else
11099 {
11100 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11101 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011102 //now we have a valid channel
11103 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11104 {
11105 //let's pick a secondard channel
11106 SecondChn = csrRoamGetSecondaryChannel(pMac, Channel, cbChoice);
Jeff Johnson295189b2012-06-20 16:38:30 -070011107 if(SecondChn > Channel)
11108 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011109 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070011110 }
11111 else if(SecondChn && SecondChn < Channel)
11112 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011113 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070011114 }
11115 else
11116 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011117 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011118 }
11119 pSession->bssParams.cbMode = cbMode;
11120 }
11121 else
11122 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011123 pSession->bssParams.cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011124 }
11125 }
11126 }
11127 }
11128}
11129
Jeff Johnson295189b2012-06-20 16:38:30 -070011130static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11131 tANI_BOOLEAN *pfSameIbss )
11132{
11133 eHalStatus status = eHAL_STATUS_SUCCESS;
11134 tANI_BOOLEAN fSameIbss = FALSE;
11135
11136 if ( csrIsConnStateIbss( pMac, sessionId ) )
11137 {
11138 // Check if any profile parameter has changed ? If any profile parameter
11139 // has changed then stop old BSS and start a new one with new parameters
11140 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11141 {
11142 fSameIbss = TRUE;
11143 }
11144 else
11145 {
11146 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11147 }
11148 }
11149 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11150 {
11151 // Disassociate from the connected Infrastructure network...
11152 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11153 }
11154 else
11155 {
11156 tBssConfigParam *pBssConfig;
11157
11158 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
11159 if(HAL_STATUS_SUCCESS(status))
11160 {
11161 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
11162 // there is no Bss description before we start an IBSS so we need to adopt
11163 // all Bss configuration parameters from the Profile.
11164 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11165 if(HAL_STATUS_SUCCESS(status))
11166 {
11167 //save dotMode
11168 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11169 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011170 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011171 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
11172 }
11173
11174 palFreeMemory(pMac->hHdd, pBssConfig);
11175 }//Allocate memory
11176 }
11177
11178 if(pfSameIbss)
11179 {
11180 *pfSameIbss = fSameIbss;
11181 }
11182 return( status );
11183}
11184
Jeff Johnson295189b2012-06-20 16:38:30 -070011185static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11186 tSirSmeNewBssInfo *pNewBss )
11187{
11188 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011189
11190 if(!pSession)
11191 {
11192 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11193 return;
11194 }
11195
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 if( pNewBss )
11197 {
11198 // Set the operating channel.
11199 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11200 // move the BSSId from the BSS description into the connected state information.
11201 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
11202 &(pNewBss->bssId), sizeof( tCsrBssid ) );
11203 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011204 return;
11205}
11206
Jeff Johnson295189b2012-06-20 16:38:30 -070011207#ifdef FEATURE_WLAN_WAPI
11208eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11209 tANI_U32 numItems )
11210{
11211 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11212 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011213 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11214 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011215 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011216 return status;
11217 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011218 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011219 pSession = CSR_GET_SESSION( pMac, sessionId );
11220 if(numItems <= CSR_MAX_BKID_ALLOWED)
11221 {
11222 status = eHAL_STATUS_SUCCESS;
11223 //numItems may be 0 to clear the cache
11224 pSession->NumBkidCache = (tANI_U16)numItems;
11225 if(numItems && pBKIDCache)
11226 {
11227 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
11228 sizeof(tBkidCacheInfo) * numItems );
11229 }
11230 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011231 return (status);
11232}
Jeff Johnson295189b2012-06-20 16:38:30 -070011233eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11234 tBkidCacheInfo *pBkidCache)
11235{
11236 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11237 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011238 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11239 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011240 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011241 return status;
11242 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011243 pSession = CSR_GET_SESSION( pMac, sessionId );
11244 if(pNum && pBkidCache)
11245 {
11246 if(pSession->NumBkidCache == 0)
11247 {
11248 *pNum = 0;
11249 status = eHAL_STATUS_SUCCESS;
11250 }
11251 else if(*pNum >= pSession->NumBkidCache)
11252 {
11253 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11254 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011255 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 -070011256 pSession->NumBkidCache);
11257 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11258 }
11259 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
11260 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
11261 *pNum = pSession->NumBkidCache;
11262 status = eHAL_STATUS_SUCCESS;
11263 }
11264 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011265 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011266}
Jeff Johnson295189b2012-06-20 16:38:30 -070011267tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11268{
11269 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011270}
11271#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011272eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11273 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11274{
11275 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11276 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011277
11278 if(!pSession)
11279 {
11280 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11281 return eHAL_STATUS_FAILURE;
11282 }
11283
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011284 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011285 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11286 {
11287#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11288 {
11289 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11290 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11291 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11292 secEvent.encryptionModeMulticast =
11293 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11294 secEvent.encryptionModeUnicast =
11295 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11296 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11297 secEvent.authMode =
11298 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11299 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11300 }
11301#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011302 status = eHAL_STATUS_SUCCESS;
11303 //numItems may be 0 to clear the cache
11304 pSession->NumPmkidCache = (tANI_U16)numItems;
11305 if(numItems && pPMKIDCache)
11306 {
11307 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11308 sizeof(tPmkidCacheInfo) * numItems );
11309 }
11310 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011311 return (status);
11312}
11313
Jeff Johnson295189b2012-06-20 16:38:30 -070011314tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11315{
11316 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11317}
11318
Jeff Johnson295189b2012-06-20 16:38:30 -070011319eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11320{
11321 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11322 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011323
11324 if(!pSession)
11325 {
11326 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11327 return eHAL_STATUS_FAILURE;
11328 }
11329
Jeff Johnson295189b2012-06-20 16:38:30 -070011330 if(pNum && pPmkidCache)
11331 {
11332 if(pSession->NumPmkidCache == 0)
11333 {
11334 *pNum = 0;
11335 status = eHAL_STATUS_SUCCESS;
11336 }
11337 else if(*pNum >= pSession->NumPmkidCache)
11338 {
11339 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11340 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011341 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 -070011342 pSession->NumPmkidCache);
11343 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11344 }
11345 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11346 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11347 *pNum = pSession->NumPmkidCache;
11348 status = eHAL_STATUS_SUCCESS;
11349 }
11350 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011351 return (status);
11352}
11353
Jeff Johnson295189b2012-06-20 16:38:30 -070011354eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11355{
11356 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11357 tANI_U32 len;
11358 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011359
11360 if(!pSession)
11361 {
11362 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11363 return eHAL_STATUS_FAILURE;
11364 }
11365
Jeff Johnson295189b2012-06-20 16:38:30 -070011366 if(pLen)
11367 {
11368 len = *pLen;
11369 *pLen = pSession->nWpaRsnReqIeLength;
11370 if(pBuf)
11371 {
11372 if(len >= pSession->nWpaRsnReqIeLength)
11373 {
11374 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11375 }
11376 }
11377 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011378 return (status);
11379}
11380
Jeff Johnson295189b2012-06-20 16:38:30 -070011381eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11382{
11383 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11384 tANI_U32 len;
11385 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011386
11387 if(!pSession)
11388 {
11389 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11390 return eHAL_STATUS_FAILURE;
11391 }
11392
Jeff Johnson295189b2012-06-20 16:38:30 -070011393 if(pLen)
11394 {
11395 len = *pLen;
11396 *pLen = pSession->nWpaRsnRspIeLength;
11397 if(pBuf)
11398 {
11399 if(len >= pSession->nWpaRsnRspIeLength)
11400 {
11401 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11402 }
11403 }
11404 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011405 return (status);
11406}
Jeff Johnson295189b2012-06-20 16:38:30 -070011407#ifdef FEATURE_WLAN_WAPI
11408eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11409{
11410 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11411 tANI_U32 len;
11412 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011413
11414 if(!pSession)
11415 {
11416 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11417 return eHAL_STATUS_FAILURE;
11418 }
11419
Jeff Johnson295189b2012-06-20 16:38:30 -070011420 if(pLen)
11421 {
11422 len = *pLen;
11423 *pLen = pSession->nWapiReqIeLength;
11424 if(pBuf)
11425 {
11426 if(len >= pSession->nWapiReqIeLength)
11427 {
11428 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11429 }
11430 }
11431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011432 return (status);
11433}
Jeff Johnson295189b2012-06-20 16:38:30 -070011434eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11435{
11436 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11437 tANI_U32 len;
11438 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011439
11440 if(!pSession)
11441 {
11442 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11443 return eHAL_STATUS_FAILURE;
11444 }
11445
Jeff Johnson295189b2012-06-20 16:38:30 -070011446 if(pLen)
11447 {
11448 len = *pLen;
11449 *pLen = pSession->nWapiRspIeLength;
11450 if(pBuf)
11451 {
11452 if(len >= pSession->nWapiRspIeLength)
11453 {
11454 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11455 }
11456 }
11457 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011458 return (status);
11459}
11460#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011461eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11462{
11463 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11464 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011465
11466 if(!pSession)
11467 {
11468 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11469 return (retStatus);
11470 }
11471
Jeff Johnson295189b2012-06-20 16:38:30 -070011472 if(CSR_IS_ROAMING(pSession))
11473 {
11474 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11475 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11476 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011477 return (retStatus);
11478}
11479
Jeff Johnson295189b2012-06-20 16:38:30 -070011480//This function remove the connected BSS from te cached scan result
11481eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11482 tCsrRoamConnectedProfile *pConnProfile)
11483{
11484 eHalStatus status = eHAL_STATUS_FAILURE;
11485 tCsrScanResultFilter *pScanFilter = NULL;
11486 tListElem *pEntry;
11487 tCsrScanResult *pResult;
11488 tDot11fBeaconIEs *pIes;
11489 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011490 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11491 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11492 {
11493 do
11494 {
11495 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11496 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11497 if(!HAL_STATUS_SUCCESS(status)) break;
11498 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11499 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11500 if(!HAL_STATUS_SUCCESS(status)) break;
11501 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11502 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11503 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11504 {
11505 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11506 if(!HAL_STATUS_SUCCESS(status)) break;
11507 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11508 }
11509 pScanFilter->authType.numEntries = 1;
11510 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11511 pScanFilter->BSSType = pConnProfile->BSSType;
11512 pScanFilter->EncryptionType.numEntries = 1;
11513 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11514 pScanFilter->mcEncryptionType.numEntries = 1;
11515 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11516 //We ignore the channel for now, BSSID should be enough
11517 pScanFilter->ChannelInfo.numOfChannels = 0;
11518 //Also ignore the following fields
11519 pScanFilter->uapsd_mask = 0;
11520 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11521 pScanFilter->countryCode[0] = 0;
11522 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011523 csrLLLock(&pMac->scan.scanResultList);
11524 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11525 while( pEntry )
11526 {
11527 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11528 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11529 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11530 pScanFilter, NULL, NULL, NULL, &pIes);
11531 //Release the IEs allocated by csrMatchBSS is needed
11532 if( !pResult->Result.pvIes )
11533 {
11534 //need to free the IEs since it is allocated by csrMatchBSS
11535 palFreeMemory(pMac->hHdd, pIes);
11536 }
11537 if(fMatch)
11538 {
11539 //We found the one
11540 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11541 {
11542 //Free the memory
11543 csrFreeScanResultEntry( pMac, pResult );
11544 }
11545 break;
11546 }
11547 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11548 }//while
11549 csrLLUnlock(&pMac->scan.scanResultList);
11550 }while(0);
11551 if(pScanFilter)
11552 {
11553 csrFreeScanFilter(pMac, pScanFilter);
11554 palFreeMemory(pMac->hHdd, pScanFilter);
11555 }
11556 }
11557 return (status);
11558}
11559
Jeff Johnson295189b2012-06-20 16:38:30 -070011560//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011561eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11562{
11563 eHalStatus status = eHAL_STATUS_SUCCESS;
11564 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011565 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11566 {
11567 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11568 {
11569 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11570 {
11571 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011572 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011573 status = eHAL_STATUS_CSR_WRONG_STATE;
11574 break;
11575 }
11576 if( csrIsConnStateInfra( pMac, sessionId ) )
11577 {
11578 if( chnId &&
11579 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11580 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011581 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011582 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11583 status = eHAL_STATUS_CSR_WRONG_STATE;
11584 break;
11585 }
11586 }
11587 }
11588 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011589 return ( status );
11590}
11591
Jeff Johnson295189b2012-06-20 16:38:30 -070011592static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11593{
11594 eHalStatus status = eHAL_STATUS_SUCCESS;
11595 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11596 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011597
11598 if(!pSession)
11599 {
11600 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11601 return eHAL_STATUS_FAILURE;
11602 }
11603
Jeff Johnson295189b2012-06-20 16:38:30 -070011604 if ( csrIsConnStateIbss( pMac, sessionId ) )
11605 {
11606 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11607 }
11608 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11609 {
11610 // Disassociate from the connected Infrastructure network...
11611 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11612 }
11613 else
11614 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011615 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11616 //Otherwise we need to add code to handle the
11617 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11618 //send stop_bss to PE, before we can continue.
11619 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011620 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11621 /* Assume HDD provide bssid in profile */
11622 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11623 // there is no Bss description before we start an WDS so we need
11624 // to adopt all Bss configuration parameters from the Profile.
11625 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11626 if(HAL_STATUS_SUCCESS(status))
11627 {
11628 //Save profile for late use
11629 csrFreeRoamProfile( pMac, sessionId );
11630 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
11631 (void **)&pSession->pCurRoamProfile,
11632 sizeof(tCsrRoamProfile))))
11633 {
11634 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11635 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11636 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011637 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011638 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011639 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
11640 }
11641 }
11642
11643 return( status );
11644}
11645
Jeff Johnson295189b2012-06-20 16:38:30 -070011646////////////////////Mail box
11647
Jeff Johnson295189b2012-06-20 16:38:30 -070011648//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11649//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11650static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11651 tSirBssDescription *pBssDescription,
11652 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11653{
11654 tCsrChannelSet channelGroup;
11655 tSirMacCapabilityInfo *pAP_capabilityInfo;
11656 tAniBool fTmp;
11657 tANI_BOOLEAN found = FALSE;
11658 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011659 tANI_S8 pwrLimit = 0;
11660 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011661 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11662 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11663 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11664 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011665 // 802.11h
11666 //We can do this because it is in HOST CPU order for now.
11667 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080011668 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11669 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11670 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011671 fTmp = (tAniBool)pal_cpu_to_be32(1);
11672 }
11673 else
11674 fTmp = (tAniBool)0;
11675
11676 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11677 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11678 pBuf += sizeof(tAniBool);
11679 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011680 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011681 // This is required for 11k test VoWiFi Ent: Test 2.
11682 // We need the power capabilities for Assoc Req.
11683 // This macro is provided by the halPhyCfg.h. We pick our
11684 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080011685 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11686 if (0 != pwrLimit)
11687 {
11688 *pBuf++ = pwrLimit;
11689 }
11690 else
11691 {
11692 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11693 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011694 size = sizeof(pMac->roam.validChannelList);
11695 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11696 {
11697 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11698 for ( i = 0; i < size; i++)
11699 {
11700 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11701
11702 }
11703 }
11704 else
11705 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011706 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011707 *pBuf++ = 0; //tSirSupChnl->numChnl
11708 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011709 //Check whether it is ok to enter UAPSD
11710#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11711 if( btcIsReadyForUapsd(pMac) )
11712#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11713 {
11714 *pBuf++ = uapsdMask;
11715 }
11716#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11717 else
11718 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011719 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070011720 *pBuf++ = 0;
11721 }
11722#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11723
Jeff Johnson295189b2012-06-20 16:38:30 -070011724 // move the entire BssDescription into the join request.
11725 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11726 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011727 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11728}
11729
Jeff Johnson295189b2012-06-20 16:38:30 -070011730/*
11731 * The communication between HDD and LIM is thru mailbox (MB).
11732 * Both sides will access the data structure "tSirSmeJoinReq".
11733 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11734 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11735 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11736 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11737 */
11738eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011739 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011740{
11741 eHalStatus status = eHAL_STATUS_SUCCESS;
11742 tSirSmeJoinReq *pMsg;
11743 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011744 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011745 tANI_U16 msgLen, wTmp, ieLen;
11746 tSirMacRateSet OpRateSet;
11747 tSirMacRateSet ExRateSet;
11748 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11749 tANI_U32 dwTmp;
11750 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Jeff Johnson32d95a32012-09-10 13:15:23 -070011751
11752 if(!pSession)
11753 {
11754 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11755 return eHAL_STATUS_FAILURE;
11756 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011757 /* To satisfy klockworks */
11758 if (NULL == pBssDescription)
11759 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011760 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011761 return eHAL_STATUS_FAILURE;
11762 }
11763
Jeff Johnson295189b2012-06-20 16:38:30 -070011764 do {
11765 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11766 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070011767 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070011768 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11769 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11770 // IE fields, but the length field in the bssDescription needs to be interpreted to
11771 // determine length of the IE fields.
11772 //
11773 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11774 // add in the length from the bssDescription (then add the size of the 'length' field
11775 // itself because that is NOT included in the length field).
11776 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11777 pBssDescription->length + sizeof( pBssDescription->length ) +
11778 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 -070011779 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11780 if ( !HAL_STATUS_SUCCESS(status) ) break;
11781 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011782 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011783 pMsg->length = pal_cpu_to_be16(msgLen);
11784 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011785 // sessionId
11786 *pBuf = (tANI_U8)sessionId;
11787 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011788 // transactionId
11789 *pBuf = 0;
11790 *( pBuf + 1 ) = 0;
11791 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011792 // ssId
11793 if( pIes->SSID.present && pIes->SSID.num_ssid )
11794 {
11795 // ssId len
11796 *pBuf = pIes->SSID.num_ssid;
11797 pBuf++;
11798 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11799 pBuf += pIes->SSID.num_ssid;
11800 }
11801 else
11802 {
11803 *pBuf = 0;
11804 pBuf++;
11805 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011806 // selfMacAddr
11807 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11808 pBuf += sizeof(tSirMacAddr);
11809 // bsstype
11810 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11811 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11812 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11813 pBuf += sizeof(tSirBssType);
11814 // dot11mode
11815 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11816 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011817 //Persona
11818 *pBuf = (tANI_U8)pProfile->csrPersona;
11819 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011820 //CBMode
11821 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11822 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011823
11824 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011825 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11826
Jeff Johnson295189b2012-06-20 16:38:30 -070011827 // uapsdPerAcBitmask
11828 *pBuf = pProfile->uapsd_mask;
11829 pBuf++;
11830
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011831
11832
Jeff Johnson295189b2012-06-20 16:38:30 -070011833 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011834 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011835 {
11836 // OperationalRateSet
11837 if (OpRateSet.numRates) {
11838 *pBuf++ = OpRateSet.numRates;
11839 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11840 pBuf += OpRateSet.numRates;
11841 } else *pBuf++ = 0;
11842 // ExtendedRateSet
11843 if (ExRateSet.numRates) {
11844 *pBuf++ = ExRateSet.numRates;
11845 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11846 pBuf += ExRateSet.numRates;
11847 } else *pBuf++ = 0;
11848 }
11849 else
11850 {
11851 *pBuf++ = 0;
11852 *pBuf++ = 0;
11853 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011854 // rsnIE
11855 if ( csrIsProfileWpa( pProfile ) )
11856 {
11857 // Insert the Wpa IE into the join request
11858 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11859 (tCsrWpaIe *)( wpaRsnIE ) );
11860 }
11861 else if( csrIsProfileRSN( pProfile ) )
11862 {
11863 // Insert the RSN IE into the join request
11864 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11865 (tCsrRSNIe *)( wpaRsnIE ) );
11866 }
11867#ifdef FEATURE_WLAN_WAPI
11868 else if( csrIsProfileWapi( pProfile ) )
11869 {
11870 // Insert the WAPI IE into the join request
11871 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11872 (tCsrWapiIe *)( wpaRsnIE ) );
11873 }
11874#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011875 else
11876 {
11877 ieLen = 0;
11878 }
11879 //remember the IE for future use
11880 if( ieLen )
11881 {
11882 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11883 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011884 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 -070011885 ieLen = DOT11F_IE_RSN_MAX_LEN;
11886 }
11887#ifdef FEATURE_WLAN_WAPI
11888 if( csrIsProfileWapi( pProfile ) )
11889 {
11890 //Check whether we need to allocate more memory
11891 if(ieLen > pSession->nWapiReqIeLength)
11892 {
11893 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11894 {
11895 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11896 }
11897 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11898 if(!HAL_STATUS_SUCCESS(status)) break;
11899 }
11900 pSession->nWapiReqIeLength = ieLen;
11901 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11902 wTmp = pal_cpu_to_be16( ieLen );
11903 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11904 pBuf += sizeof(tANI_U16);
11905 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11906 pBuf += ieLen;
11907 }
11908 else//should be WPA/WPA2 otherwise
11909#endif /* FEATURE_WLAN_WAPI */
11910 {
11911 //Check whether we need to allocate more memory
11912 if(ieLen > pSession->nWpaRsnReqIeLength)
11913 {
11914 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11915 {
11916 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11917 }
11918 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
11919 if(!HAL_STATUS_SUCCESS(status)) break;
11920 }
11921 pSession->nWpaRsnReqIeLength = ieLen;
11922 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
11923 wTmp = pal_cpu_to_be16( ieLen );
11924 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11925 pBuf += sizeof(tANI_U16);
11926 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11927 pBuf += ieLen;
11928 }
11929 }
11930 else
11931 {
11932 //free whatever old info
11933 pSession->nWpaRsnReqIeLength = 0;
11934 if(pSession->pWpaRsnReqIE)
11935 {
11936 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11937 pSession->pWpaRsnReqIE = NULL;
11938 }
11939#ifdef FEATURE_WLAN_WAPI
11940 pSession->nWapiReqIeLength = 0;
11941 if(pSession->pWapiReqIE)
11942 {
11943 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11944 pSession->pWapiReqIE = NULL;
11945 }
11946#endif /* FEATURE_WLAN_WAPI */
11947 //length is two bytes
11948 *pBuf = 0;
11949 *(pBuf + 1) = 0;
11950 pBuf += 2;
11951 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011952#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011953 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011954 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011955 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070011956 //length is two bytes
11957 *pBuf = 0;
11958 *(pBuf + 1) = 0;
11959 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011960 }
11961 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011962 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011963 // cckmIE
11964 if( csrIsProfileCCX( pProfile ) )
11965 {
11966 // Insert the CCKM IE into the join request
11967 ieLen = csrConstructCcxCckmIe( pMac,
11968 pSession,
11969 pProfile,
11970 pBssDescription,
11971 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070011972 pSession->nWpaRsnReqIeLength,
11973 (void *)( wpaRsnIE ) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011974 }
11975 else
11976 {
11977 ieLen = 0;
11978 }
11979 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
11980 if( ieLen )
11981 {
11982 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
11983 wTmp = pal_cpu_to_be16( ieLen );
11984 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11985 pBuf += sizeof(tANI_U16);
11986 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11987 pBuf += ieLen;
11988 }
11989 else
11990 {
11991 //Indicate you have no CCKM IE
11992 //length is two bytes
11993 *pBuf = 0;
11994 *(pBuf + 1) = 0;
11995 pBuf += 2;
11996 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011997 }
11998#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070011999 // addIEScan
12000 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
12001 {
12002 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012003 if(ieLen > pSession->nAddIEScanLength)
12004 {
12005 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
12006 {
12007 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12008 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012009 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012010 (void **)&pSession->pAddIEScan, ieLen);
12011 if(!HAL_STATUS_SUCCESS(status)) break;
12012 }
12013 pSession->nAddIEScanLength = ieLen;
12014 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
12015 pProfile->pAddIEScan, ieLen);
12016 wTmp = pal_cpu_to_be16( ieLen );
12017 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12018 pBuf += sizeof(tANI_U16);
12019 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
12020 pBuf += ieLen;
12021 }
12022 else
12023 {
12024 pSession->nAddIEScanLength = 0;
12025 if(pSession->pAddIEScan)
12026 {
12027 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12028 pSession->pAddIEScan = NULL;
12029 }
12030 *pBuf = 0;
12031 *(pBuf + 1) = 0;
12032 pBuf += 2;
12033 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012034 // addIEAssoc
12035 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12036 {
12037 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012038 if(ieLen > pSession->nAddIEAssocLength)
12039 {
12040 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
12041 {
12042 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12043 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012044 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012045 (void **)&pSession->pAddIEAssoc, ieLen);
12046 if(!HAL_STATUS_SUCCESS(status)) break;
12047 }
12048 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012049 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070012050 pProfile->pAddIEAssoc, ieLen);
12051 wTmp = pal_cpu_to_be16( ieLen );
12052 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12053 pBuf += sizeof(tANI_U16);
12054 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
12055 pBuf += ieLen;
12056 }
12057 else
12058 {
12059 pSession->nAddIEAssocLength = 0;
12060 if(pSession->pAddIEAssoc)
12061 {
12062 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12063 pSession->pAddIEAssoc = NULL;
12064 }
12065 *pBuf = 0;
12066 *(pBuf + 1) = 0;
12067 pBuf += 2;
12068 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012069
12070 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012071 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012072 //Unmask any AC in reassoc that is ACM-set
12073 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12074 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012075 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012076 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12077 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012078#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012079 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012080#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012081 uapsd_mask &= ~(acm_mask);
12082 }
12083 else
12084 {
12085 uapsd_mask = 0;
12086 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012087 }
12088 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012089
Jeff Johnson295189b2012-06-20 16:38:30 -070012090 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
12091 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012092 pBuf += sizeof(tANI_U32);
12093
Jeff Johnson295189b2012-06-20 16:38:30 -070012094 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
12095 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012096 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012097#ifdef WLAN_FEATURE_11W
12098 //MgmtEncryption
12099 if (pProfile->MFPEnabled)
12100 {
12101 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12102 }
12103 else
12104 {
12105 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12106 }
12107 palCopyMemory(pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32));
12108 pBuf += sizeof(tANI_U32);
12109#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012110#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012111 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012112 if (csrIsProfile11r( pProfile )
12113#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012114 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12115 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012116#endif
12117 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012118 {
12119 // is11Rconnection;
12120 dwTmp = pal_cpu_to_be32(TRUE);
12121 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12122 pBuf += sizeof(tAniBool);
12123 }
12124 else
12125 {
12126 // is11Rconnection;
12127 dwTmp = pal_cpu_to_be32(FALSE);
12128 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12129 pBuf += sizeof(tAniBool);
12130 }
12131#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012132#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012133 /* A profile can not be both CCX and 11R. But an 802.11R AP
12134 * may be advertising support for CCX as well. So if we are
12135 * associating Open or explicitly CCX then we will get CCX.
12136 * If we are associating explictly 11R only then we will get
12137 * 11R.
12138 */
12139 if ((csrIsProfileCCX(pProfile) ||
12140 ((pIes->CCXVersion.present)
12141 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012142 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12143 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12144 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012145#ifdef WLAN_FEATURE_11W
12146 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12147#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012148 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012149 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12150 {
12151 // isCCXconnection;
12152 dwTmp = pal_cpu_to_be32(TRUE);
12153 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12154 pBuf += sizeof(tAniBool);
12155 }
12156 else
12157 {
12158 //isCCXconnection;
12159 dwTmp = pal_cpu_to_be32(FALSE);
12160 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12161 pBuf += sizeof(tAniBool);
12162 }
12163
12164 if (eWNI_SME_JOIN_REQ == messageType)
12165 {
12166 tCCXTspecInfo ccxTspec;
12167 // CCX-Tspec IEs in the ASSOC request is presently not supported
12168 // so nullify the TSPEC parameters
12169 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12170 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12171 pBuf += sizeof(tCCXTspecInfo);
12172 }
12173 else if (eWNI_SME_REASSOC_REQ == messageType)
12174 {
12175 if ((csrIsProfileCCX(pProfile) ||
12176 ((pIes->CCXVersion.present)
12177 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012178 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12179 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12180 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012181#ifdef WLAN_FEATURE_11W
12182 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12183#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012184 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012185 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012186 {
12187 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012188 // CCX Tspec information
12189 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12190 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12191 *pBuf = ccxTspec.numTspecs;
12192 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012193 // Copy the TSPEC information only if present
12194 if (ccxTspec.numTspecs) {
12195 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
12196 }
12197 pBuf += sizeof(ccxTspec.tspec);
12198 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012199 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012200 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012201 tCCXTspecInfo ccxTspec;
12202 // CCX-Tspec IEs in the ASSOC request is presently not supported
12203 // so nullify the TSPEC parameters
12204 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12205 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12206 pBuf += sizeof(tCCXTspecInfo);
12207 }
12208 }
12209#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012210#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012211 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012212 if (pMac->roam.configParam.isFastTransitionEnabled
12213#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012214 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012215#endif
12216 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012217 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012218 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012219 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012220 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012221 }
12222 else
12223 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012224 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012225 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012226 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012227 }
12228#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012229#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012230 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012231 {
12232 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012233 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012234 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012235 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012236 }
12237 else
12238 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012239 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012240 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012241 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012242 }
12243#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012244
12245 // txLdpcIniFeatureEnabled
12246 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12247 pBuf++;
12248
Kiran4a17ebe2013-01-31 10:43:43 -080012249 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12250 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12251 {
12252 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12253 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12254 csrApplyPower2Current(pMac);
12255 }
12256
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012257#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012258 // txBFIniFeatureEnabled
12259 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12260 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012261
12262 // txBFCsnValue
12263 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12264 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012265#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012266 //BssDesc
12267 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12268 (tANI_U8)pProfile->uapsd_mask);
12269 status = palSendMBMessage(pMac->hHdd, pMsg );
12270 if(!HAL_STATUS_SUCCESS(status))
12271 {
12272 break;
12273 }
12274 else
12275 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012276#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012277 if (eWNI_SME_JOIN_REQ == messageType)
12278 {
12279 //Tush-QoS: notify QoS module that join happening
12280 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12281 }
12282 else if (eWNI_SME_REASSOC_REQ == messageType)
12283 {
12284 //Tush-QoS: notify QoS module that reassoc happening
12285 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12286 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012287#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012288 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012289 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012290 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012291}
12292
Jeff Johnson295189b2012-06-20 16:38:30 -070012293//
12294eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12295{
12296 eHalStatus status = eHAL_STATUS_SUCCESS;
12297 tSirSmeDisassocReq *pMsg;
12298 tANI_U8 *pBuf;
12299 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012300 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12301 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12302 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012303 do {
12304 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12305 if ( !HAL_STATUS_SUCCESS(status) ) break;
12306 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12307 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12308 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012309 pBuf = &pMsg->sessionId;
12310 // sessionId
12311 *pBuf++ = (tANI_U8)sessionId;
12312 // transactionId
12313 *pBuf = 0;
12314 *( pBuf + 1 ) = 0;
12315 pBuf += sizeof(tANI_U16);
12316
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012317 if ( (pSession->pCurRoamProfile != NULL) &&
12318 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12319 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012320 {
12321 // Set the bssid address before sending the message to LIM
12322 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12323 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012324 // Set the peer MAC address before sending the message to LIM
12325 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12326 pBuf = pBuf + sizeof ( tSirMacAddr );
12327 }
12328 else
12329 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012330 // Set the peer MAC address before sending the message to LIM
12331 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12332 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012333 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12334 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012336 if(!HAL_STATUS_SUCCESS(status))
12337 {
12338 palFreeMemory(pMac->hHdd, pMsg);
12339 break;
12340 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012341 // reasonCode
12342 wTmp = pal_cpu_to_be16(reasonCode);
12343 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12344 if(!HAL_STATUS_SUCCESS(status))
12345 {
12346 palFreeMemory(pMac->hHdd, pMsg);
12347 break;
12348 }
12349 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012350 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12351 Here we should not send the disassoc over the air to the AP */
12352 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12353#ifdef WLAN_FEATURE_VOWIFI_11R
12354 && csrRoamIs11rAssoc(pMac)
12355#endif
12356 )
12357 {
12358 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12359 }
12360 pBuf += sizeof(tANI_U8);
12361 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012362 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012363 return( status );
12364}
Jeff Johnson295189b2012-06-20 16:38:30 -070012365eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12366{
12367 eHalStatus status = eHAL_STATUS_SUCCESS;
12368 tSirSmeTkipCntrMeasReq *pMsg;
12369 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012370 do
12371 {
12372 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12373 if ( !HAL_STATUS_SUCCESS(status) ) break;
12374 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12375 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12376 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012377 pBuf = &pMsg->sessionId;
12378 // sessionId
12379 *pBuf++ = (tANI_U8)sessionId;
12380 // transactionId
12381 *pBuf = 0;
12382 *( pBuf + 1 ) = 0;
12383 pBuf += sizeof(tANI_U16);
12384 // bssid
12385 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12386 pBuf = pBuf + sizeof ( tSirMacAddr );
12387 // bEnable
12388 *pBuf = (tANI_BOOLEAN)bEnable;
12389 if(!HAL_STATUS_SUCCESS(status))
12390 {
12391 palFreeMemory(pMac->hHdd, pMsg);
12392 break;
12393 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012395 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012396 return( status );
12397}
Jeff Johnson295189b2012-06-20 16:38:30 -070012398eHalStatus
12399csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12400 VOS_MODULE_ID modId, tSirMacAddr bssId,
12401 void *pUsrContext, void *pfnSapEventCallback,
12402 tANI_U8 *pAssocStasBuf )
12403{
12404 eHalStatus status = eHAL_STATUS_SUCCESS;
12405 tSirSmeGetAssocSTAsReq *pMsg;
12406 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12407 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012408 do
12409 {
12410 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12411 if (!HAL_STATUS_SUCCESS(status)) break;
12412 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12413 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012414 pBuf = (tANI_U8 *)&pMsg->bssId;
12415 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012416 // bssId
12417 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12418 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012419 // modId
12420 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12421 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12422 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012423 // pUsrContext
12424 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12425 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12426 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012427 // pfnSapEventCallback
12428 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12429 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12430 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012431 // pAssocStasBuf
12432 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12433 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12434 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012435 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012436 status = palSendMBMessage( pMac->hHdd, pMsg );
12437 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012438 return( status );
12439 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012440eHalStatus
12441csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12442 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12443 {
12444 eHalStatus status = eHAL_STATUS_SUCCESS;
12445 tSirSmeGetWPSPBCSessionsReq *pMsg;
12446 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12447 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012448 do
12449 {
12450 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12451 if (!HAL_STATUS_SUCCESS(status)) break;
12452 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12453 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012454 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
12455 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012456 // pUsrContext
12457 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12458 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12459 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012460 // pSapEventCallback
12461 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12462 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12463 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012464 // bssId
12465 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12466 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012467 // MAC Address of STA in WPS session
12468 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12469 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012470 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012471 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012472 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012473 return( status );
12474}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012475
12476eHalStatus
12477csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12478{
12479 tpSirChangeBIParams pMsg;
12480 tANI_U16 len = 0;
12481 eHalStatus status = eHAL_STATUS_SUCCESS;
12482 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12483
12484 if(!pSession)
12485 {
12486 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12487 return eHAL_STATUS_FAILURE;
12488 }
12489
12490 //NO need to update the Beacon Params if update beacon parameter flag is not set
12491 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12492 return eHAL_STATUS_SUCCESS;
12493
12494 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12495
12496 /* Create the message and send to lim */
12497 len = sizeof(tSirChangeBIParams);
12498 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12499 if(HAL_STATUS_SUCCESS(status))
12500 {
12501 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12502 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12503 pMsg->length = len;
12504
12505 // bssId
12506 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012507 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 -080012508 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12509 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12510 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012511 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012512 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12513 status = palSendMBMessage(pMac->hHdd, pMsg);
12514 }
12515 return status;
12516}
12517
Jeff Johnson295189b2012-06-20 16:38:30 -070012518eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12519{
12520 eHalStatus status = eHAL_STATUS_SUCCESS;
12521 tSirSmeDeauthReq *pMsg;
12522 tANI_U8 *pBuf;
12523 tANI_U16 wTmp;
12524 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12525 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12526 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012527 do {
12528 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12529 if ( !HAL_STATUS_SUCCESS(status) ) break;
12530 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12531 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12532 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12533 //sessionId
12534 pBuf = &pMsg->sessionId;
12535 *pBuf++ = (tANI_U8)sessionId;
12536
12537 //tansactionId
12538 *pBuf = 0;
12539 *(pBuf + 1 ) = 0;
12540 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012541 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012542 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012543 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12544 // Set the BSSID before sending the message to LIM
12545 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12546 pBuf = pBuf + sizeof(tSirMacAddr);
12547 }
12548 else
12549 {
12550 // Set the BSSID before sending the message to LIM
12551 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12552 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 }
12554 if(!HAL_STATUS_SUCCESS(status))
12555 {
12556 palFreeMemory(pMac->hHdd, pMsg);
12557 break;
12558 }
12559 // Set the peer MAC address before sending the message to LIM
12560 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12561 pBuf = pBuf + sizeof(tSirMacAddr);
12562 if(!HAL_STATUS_SUCCESS(status))
12563 {
12564 palFreeMemory(pMac->hHdd, pMsg);
12565 break;
12566 }
12567 wTmp = pal_cpu_to_be16(reasonCode);
12568 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12569 if(!HAL_STATUS_SUCCESS(status))
12570 {
12571 palFreeMemory(pMac->hHdd, pMsg);
12572 break;
12573 }
12574 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012575 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 return( status );
12577}
12578
Jeff Johnson295189b2012-06-20 16:38:30 -070012579eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12580{
12581 eHalStatus status = eHAL_STATUS_SUCCESS;
12582 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012583 do {
12584 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12585 if ( !HAL_STATUS_SUCCESS(status) ) break;
12586 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12587 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12588 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12589 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12590 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12591 if(!HAL_STATUS_SUCCESS(status))
12592 {
12593 palFreeMemory(pMac->hHdd, pMsg);
12594 break;
12595 }
12596//To test reconn
12597 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12598 if(!HAL_STATUS_SUCCESS(status))
12599 {
12600 palFreeMemory(pMac->hHdd, pMsg);
12601 break;
12602 }
12603//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012604 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012606 return( status );
12607}
12608
Jeff Johnson295189b2012-06-20 16:38:30 -070012609eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12610{
12611 eHalStatus status = eHAL_STATUS_SUCCESS;
12612 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012613 do {
12614 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12615 if ( !HAL_STATUS_SUCCESS(status) ) break;
12616 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12617 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12618 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12619 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12620 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12621 if(!HAL_STATUS_SUCCESS(status))
12622 {
12623 palFreeMemory(pMac->hHdd, pMsg);
12624 break;
12625 }
12626 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12627 if(!HAL_STATUS_SUCCESS(status))
12628 {
12629 palFreeMemory(pMac->hHdd, pMsg);
12630 break;
12631 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012632 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012633 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 return( status );
12635}
Jeff Johnson295189b2012-06-20 16:38:30 -070012636eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12637{
12638 eHalStatus status = eHAL_STATUS_SUCCESS;
12639 tSirSmeAssocCnf *pMsg;
12640 tANI_U8 *pBuf;
12641 tSirResultCodes statusCode;
12642 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012643 do {
12644 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12645 if ( !HAL_STATUS_SUCCESS(status) ) break;
12646 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12647 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12648 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012649 pBuf = (tANI_U8 *)&pMsg->statusCode;
12650 if(HAL_STATUS_SUCCESS(Halstatus))
12651 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12652 else
12653 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12654 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12655 pBuf += sizeof(tSirResultCodes);
12656 // bssId
12657 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12658 pBuf += sizeof (tSirMacAddr);
12659 // peerMacAddr
12660 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12661 pBuf += sizeof (tSirMacAddr);
12662 // aid
12663 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12664 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12665 pBuf += sizeof (tANI_U16);
12666 // alternateBssId
12667 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12668 pBuf += sizeof (tSirMacAddr);
12669 // alternateChannelId
12670 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012671 status = palSendMBMessage( pMac->hHdd, pMsg );
12672 if(!HAL_STATUS_SUCCESS(status))
12673 {
12674 //pMsg is freed by palSendMBMessage
12675 break;
12676 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012677 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012678 return( status );
12679}
Jeff Johnson295189b2012-06-20 16:38:30 -070012680eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12681 tpSirSmeAssocInd pAssocInd,
12682 eHalStatus Halstatus,
12683 tANI_U8 sessionId)
12684{
12685 tSirMsgQ msgQ;
12686 eHalStatus status = eHAL_STATUS_SUCCESS;
12687 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12688 tANI_U8 *pBuf;
12689 tSirResultCodes statusCode;
12690 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012691 do {
12692 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12693 if ( !HAL_STATUS_SUCCESS(status) ) break;
12694 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012695
Jeff Johnson295189b2012-06-20 16:38:30 -070012696 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12697 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12698
12699 pMsg->sessionId = sessionId;
12700
12701 pBuf = (tANI_U8 *)&pMsg->statusCode;
12702 if(HAL_STATUS_SUCCESS(Halstatus))
12703 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12704 else
12705 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12706 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12707 pBuf += sizeof(tSirResultCodes);
12708 // bssId
12709 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12710 pBuf += sizeof (tSirMacAddr);
12711 // peerMacAddr
12712 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12713 pBuf += sizeof (tSirMacAddr);
12714 // StaId
12715 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12716 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12717 pBuf += sizeof (tANI_U16);
12718 // alternateBssId
12719 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12720 pBuf += sizeof (tSirMacAddr);
12721 // alternateChannelId
12722 *pBuf = 11;
12723 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012724 // Instead of copying roam Info, we just copy only WmmEnabled , RsnIE information
12725 //Wmm
12726 *pBuf = pAssocInd->wmmEnabledSta;
12727 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012728 //RSN IE
12729 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12730 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012731 //Additional IE
12732 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12733 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012734 //reassocReq
12735 *pBuf = pAssocInd->reassocReq;
12736 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012737 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12738 msgQ.bodyptr = pMsg;
12739 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012740 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012742 return( status );
12743}
Jeff Johnson295189b2012-06-20 16:38:30 -070012744
Jeff Johnson295189b2012-06-20 16:38:30 -070012745eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId ,
12746 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12747 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12748 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12749 tANI_U8 *pKeyRsc )
12750{
12751 tSirSmeSetContextReq *pMsg;
12752 tANI_U16 msgLen;
12753 eHalStatus status = eHAL_STATUS_FAILURE;
12754 tAniEdType tmpEdType;
12755 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053012756 tANI_U8 *pBuf = NULL;
12757 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012758 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012759 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012760 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012761 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12762 // key set. Since we only support upto one key, we always allocate memory for 1 key
12763 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12764 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12765 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12766 ( sizeof( pMsg->keyMaterial.key ) );
12767
12768 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12769 if ( !HAL_STATUS_SUCCESS(status) ) break;
12770 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12771 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12772 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012773 //sessionId
12774 pBuf = &pMsg->sessionId;
12775 *pBuf = (tANI_U8)sessionId;
12776 pBuf++;
12777 // transactionId
12778 *pBuf = 0;
12779 *(pBuf + 1) = 0;
12780 pBuf += sizeof(tANI_U16);
12781 // peerMacAddr
12782 palCopyMemory( pMac->hHdd, pBuf,
12783 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12784
12785 pBuf += sizeof(tSirMacAddr);
12786
12787 // bssId
12788 palCopyMemory( pMac->hHdd, pBuf,
12789 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12790
12791 pBuf += sizeof(tSirMacAddr);
12792
12793 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012794 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12795 // in the tSirKeyMaterial keyMaterial; field).
12796 //
12797 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12798 // shorter than this max size. Is LIM interpreting this ok ?
12799 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 -070012800 // set pMsg->keyMaterial.edType
12801 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12802 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12803 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012804 // set the pMsg->keyMaterial.numKeys field
12805 *p = numKeys;
12806 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012807 // set pSirKey->keyId = keyId;
12808 *p = keyId;
12809 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012810 // set pSirKey->unicast = (tANI_U8)fUnicast;
12811 *p = (tANI_U8)fUnicast;
12812 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012813 // set pSirKey->keyDirection = aniKeyDirection;
12814 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12815 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12816 p += sizeof(tAniKeyDirection);
12817 // pSirKey->keyRsc = ;;
12818 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12819 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012820 // set pSirKey->paeRole
12821 *p = paeRole; // 0 is Supplicant
12822 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012823 // set pSirKey->keyLength = keyLength;
12824 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012825 if ( keyLength && pKey )
12826 {
12827 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12828 if(keyLength == 16)
12829 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012830 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 -070012831 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12832 pKey[5], pKey[6], pKey[7], pKey[8],
12833 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12834 }
12835 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012836 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012837 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 return( status );
12839}
12840
Jeff Johnson295189b2012-06-20 16:38:30 -070012841eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12842 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12843{
12844 eHalStatus status;
12845 tSirSmeStartBssReq *pMsg;
12846 tANI_U8 *pBuf = NULL;
12847 tANI_U8 *wTmpBuf = NULL;
12848 tANI_U16 msgLen, wTmp;
12849 tANI_U32 dwTmp;
12850 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012851 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012852 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012853 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012854
12855 if(!pSession)
12856 {
12857 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12858 return eHAL_STATUS_FAILURE;
12859 }
12860
Jeff Johnson295189b2012-06-20 16:38:30 -070012861 do {
12862 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12863 pSession->joinFailStatusCode.reasonCode = 0;
12864 msgLen = sizeof(tSirSmeStartBssReq);
12865 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12866 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012867 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12868 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012870 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012871 //sessionId
12872 *pBuf = (tANI_U8)sessionId;
12873 pBuf++;
12874 // transactionId
12875 *pBuf = 0;
12876 *(pBuf + 1) = 0;
12877 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012878 // bssid
12879 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12880 pBuf += sizeof(tSirMacAddr);
12881 // selfMacAddr
12882 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12883 pBuf += sizeof(tSirMacAddr);
12884 // beaconInterval
12885 if( pBssDesc && pBssDesc->beaconInterval )
12886 {
12887 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12888 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012889 else if(pParam->beaconInterval)
12890 {
12891 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12892 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012893 else
12894 {
12895 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
12896 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070012897 if(csrIsconcurrentsessionValid (pMac, sessionId,
12898 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070012899 == eHAL_STATUS_SUCCESS )
12900 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012901 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070012902 pParam->bssPersona);
12903 //Update the beacon Interval
12904 pParam->beaconInterval = wTmp;
12905 }
12906 else
12907 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012908 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070012909 status = eHAL_STATUS_FAILURE;
Gopichand Nakkala114718f2013-03-25 19:19:46 -070012910 palFreeMemory( pMac->hHdd, pMsg );
Jeff Johnsone7245742012-09-05 17:12:55 -070012911 return status;
12912 }
12913
Jeff Johnson295189b2012-06-20 16:38:30 -070012914 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12915 pBuf += sizeof(tANI_U16);
12916 // dot11mode
12917 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
12918 pBuf += 1;
12919 // bssType
12920 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
12921 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
12922 pBuf += sizeof(tSirBssType);
12923 // ssId
12924 if( pParam->ssId.length )
12925 {
12926 // ssId len
12927 *pBuf = pParam->ssId.length;
12928 pBuf++;
12929 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
12930 pBuf += pParam->ssId.length;
12931 }
12932 else
12933 {
12934 *pBuf = 0;
12935 pBuf++;
12936 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012937 // set the channel Id
12938 *pBuf = pParam->operationChn;
12939 pBuf++;
12940 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070012941 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
12942 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
12943 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070012944
Jeff Johnson295189b2012-06-20 16:38:30 -070012945 // Set privacy
12946 *pBuf = pParam->privacy;
12947 pBuf++;
12948
12949 //Set Uapsd
12950 *pBuf = pParam->ApUapsdEnable;
12951 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012952 //Set SSID hidden
12953 *pBuf = pParam->ssidHidden;
12954 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012955 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
12956 pBuf++;
12957
12958 //Ht protection Enable/Disable
12959 *pBuf = (tANI_U8)pParam->protEnabled;
12960 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012961 //Enable Beacons to Receive for OBSS protection Enable/Disable
12962 *pBuf = (tANI_U8)pParam->obssProtEnabled;
12963 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012964 //set cfg related to protection
12965 wTmp = pal_cpu_to_be16( pParam->ht_protection );
12966 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12967 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012968 // Set Auth type
12969 authType = pal_cpu_to_be32(pParam->authType);
12970 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
12971 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012972 // Set DTIM
12973 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
12974 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12975 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012976 // Set wps_state
12977 *pBuf = pParam->wps_state;
12978 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012979 //Persona
12980 *pBuf = (tANI_U8)pParam->bssPersona;
12981 pBuf++;
12982
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080012983 //txLdpcIniFeatureEnabled
12984 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
12985 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012986
Jeff Johnson295189b2012-06-20 16:38:30 -070012987
12988 // set RSN IE
12989 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
12990 {
12991 status = eHAL_STATUS_INVALID_PARAMETER;
12992 palFreeMemory( pMac->hHdd, pMsg );
12993 break;
12994 }
12995 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
12996 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12997 pBuf += sizeof(tANI_U16);
12998 if( wTmp )
12999 {
13000 wTmp = pParam->nRSNIELength;
13001 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
13002 pBuf += wTmp;
13003 }
13004 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
13005 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
13006 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013007 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13008 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013009 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
13010 pBuf += pParam->operationalRateSet.numRates ;
13011 *pBuf++ = pParam->extendedRateSet.numRates;
13012 if(0 != pParam->extendedRateSet.numRates)
13013 {
13014 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
13015 pBuf += pParam->extendedRateSet.numRates;
13016 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013017 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13018 pMsg->length = pal_cpu_to_be16(msgLen);
13019
13020 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013022 return( status );
13023}
13024
Jeff Johnson295189b2012-06-20 16:38:30 -070013025eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13026{
13027 eHalStatus status = eHAL_STATUS_FAILURE;
13028 tSirSmeStopBssReq *pMsg;
13029 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13030 tANI_U8 *pBuf;
13031 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013032
13033 if(!pSession)
13034 {
13035 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13036 return eHAL_STATUS_FAILURE;
13037 }
13038
Jeff Johnson295189b2012-06-20 16:38:30 -070013039 do {
13040 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13041 if ( !HAL_STATUS_SUCCESS(status) ) break;
13042 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13043 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13044 pBuf = &pMsg->sessionId;
13045 //sessionId
13046 *pBuf = (tANI_U8)sessionId;
13047 pBuf++;
13048 // transactionId
13049 *pBuf = 0;
13050 pBuf += sizeof(tANI_U16);
13051 //reason code
13052 *pBuf = 0;
13053 pBuf += sizeof(tSirResultCodes);
13054 // bssid
13055 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13056 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13057 {
13058 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
13059 }
13060 else
13061 {
13062 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
13063 }
13064 pBuf += sizeof(tSirMacAddr);
13065 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13066 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013067 status = palSendMBMessage( pMac->hHdd, pMsg );
13068#if 0
13069 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13070 if ( !HAL_STATUS_SUCCESS(status) ) break;
13071 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13072 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13073 pMsg->reasonCode = 0;
13074 // bssid
13075 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13076 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13077 {
13078 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13079 }
13080 else
13081 {
13082 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13083 }
13084 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
13085 pMsg->transactionId = 0;
13086 pMsg->sessionId = (tANI_U8)sessionId;
13087 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13088 status = palSendMBMessage( pMac->hHdd, pMsg );
13089#endif
13090 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013091 return( status );
13092}
13093
Jeff Johnson295189b2012-06-20 16:38:30 -070013094eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13095 tCsrRoamModifyProfileFields *pModProfileFields,
13096 tANI_U32 *pRoamId, v_BOOL_t fForce)
13097{
Jeff Johnson295189b2012-06-20 16:38:30 -070013098 eHalStatus status = eHAL_STATUS_FAILURE;
13099 tANI_U32 roamId = 0;
13100 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013101 if((csrIsConnStateConnected(pMac, sessionId)) &&
13102 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
13103 &pSession->connectedProfile.modifyProfileFields,
13104 sizeof(tCsrRoamModifyProfileFields)))) )
13105 {
13106 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13107 if(pRoamId)
13108 {
13109 *pRoamId = roamId;
13110 }
13111
Jeff Johnson295189b2012-06-20 16:38:30 -070013112 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13113 eCsrSmeIssuedReassocToSameAP, roamId,
13114 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013115 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013116 return status;
13117}
Jeff Johnson295189b2012-06-20 16:38:30 -070013118static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13119{
13120 eHalStatus status = eHAL_STATUS_SUCCESS;
13121 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070013122 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
13123 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13124 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13125 return (status);
13126}
Jeff Johnson295189b2012-06-20 16:38:30 -070013127eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13128{
13129 eHalStatus status = eHAL_STATUS_SUCCESS;
13130 tListElem *pEntry = NULL;
13131 tSmeCmd *pCommand = NULL;
13132 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013133 do
13134 {
13135 if(pMsg == NULL)
13136 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013137 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013138 status = eHAL_STATUS_FAILURE;
13139 break;
13140 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013141 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13142 if(pEntry)
13143 {
13144 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13145 if(eSmeCommandAddStaSession == pCommand->command)
13146 {
13147 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013148 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013149 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013150 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013151 //Remove this command out of the active list
13152 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13153 {
13154 //Now put this command back on the avilable command list
13155 csrReleaseCommand(pMac, pCommand);
13156 }
13157 smeProcessPendingQueue( pMac );
13158 }
13159 else
13160 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013161 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 -070013162 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013163 status = eHAL_STATUS_FAILURE;
13164 break;
13165 }
13166 }
13167 else
13168 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013169 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 -070013170 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013171 status = eHAL_STATUS_FAILURE;
13172 break;
13173 }
13174 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013175 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013176}
Jeff Johnson295189b2012-06-20 16:38:30 -070013177eHalStatus csrSendMBAddSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13178{
13179 tSirSmeAddStaSelfReq *pMsg;
13180 tANI_U16 msgLen;
13181 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013182 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013183 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13184 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013185 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13186 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013187 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013188 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13189 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013190 // self station address
13191 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013192 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070013193 pMsg->selfMacAddr[0],
13194 pMsg->selfMacAddr[1],
13195 pMsg->selfMacAddr[2],
13196 pMsg->selfMacAddr[3],
13197 pMsg->selfMacAddr[4],
13198 pMsg->selfMacAddr[5]);
13199 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013200 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013201 return( status );
13202}
Jeff Johnson295189b2012-06-20 16:38:30 -070013203eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr sessionMacAddr)
13204{
13205 eHalStatus status = eHAL_STATUS_SUCCESS;
13206 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013207 pCommand = csrGetCommandBuffer(pMac);
13208 if(NULL == pCommand)
13209 {
13210 status = eHAL_STATUS_RESOURCES;
13211 }
13212 else
13213 {
13214 pCommand->command = eSmeCommandAddStaSession;
13215 pCommand->sessionId = (tANI_U8)sessionId;
13216 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013217 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13218 if( !HAL_STATUS_SUCCESS( status ) )
13219 {
13220 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013221 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 }
13223 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013224 return (status);
13225}
Jeff Johnson295189b2012-06-20 16:38:30 -070013226eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13227{
13228 return csrSendMBAddSelfStaReqMsg( pMac,
13229 pCommand->u.addStaSessionCmd.selfMacAddr );
13230}
Jeff Johnson295189b2012-06-20 16:38:30 -070013231eHalStatus csrRoamOpenSession( tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext,
13232 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId )
13233{
13234 eHalStatus status = eHAL_STATUS_SUCCESS;
13235 tANI_U32 i;
13236 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 *pbSessionId = CSR_SESSION_ID_INVALID;
13238 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13239 {
13240 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13241 {
13242 pSession = CSR_GET_SESSION( pMac, i );
13243 status = eHAL_STATUS_SUCCESS;
13244 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13245 pSession->sessionId = (tANI_U8)i;
13246 pSession->callback = callback;
13247 pSession->pContext = pContext;
13248 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
13249 *pbSessionId = (tANI_U8)i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013250 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerRoaming, csrRoamRoamingTimerHandler,
13251 &pSession->roamingTimerInfo);
13252 if(!HAL_STATUS_SUCCESS(status))
13253 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013254 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013255 break;
13256 }
13257#ifdef FEATURE_WLAN_BTAMP_UT_RF
13258 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerJoinRetry, csrRoamJoinRetryTimerHandler,
13259 &pSession->joinRetryTimerInfo);
13260 if(!HAL_STATUS_SUCCESS(status))
13261 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013262 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013263 break;
13264 }
13265#endif
13266 pSession->ibssJoinTimerInfo.pMac = pMac;
13267 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -070013268 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerIbssJoining, csrRoamIbssJoinTimerHandler,
13269 &pSession->ibssJoinTimerInfo);
13270 if(!HAL_STATUS_SUCCESS(status))
13271 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013272 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013273 break;
13274 }
13275 status = csrIssueAddStaForSessionReq ( pMac, i, pSelfMacAddr );
13276 break;
13277 }
13278 }
13279 if( CSR_ROAM_SESSION_MAX == i )
13280 {
13281 //No session is available
13282 status = eHAL_STATUS_RESOURCES;
13283 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013284 return ( status );
13285}
Jeff Johnson295189b2012-06-20 16:38:30 -070013286eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13287{
13288 eHalStatus status = eHAL_STATUS_SUCCESS;
13289 tListElem *pEntry = NULL;
13290 tSmeCmd *pCommand = NULL;
13291 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013292 do
13293 {
13294 if(pMsg == NULL)
13295 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013296 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013297 status = eHAL_STATUS_FAILURE;
13298 break;
13299 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013300 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13301 if(pEntry)
13302 {
13303 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13304 if(eSmeCommandDelStaSession == pCommand->command)
13305 {
13306 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013307 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013308 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013309 //This session is done.
13310 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013311 if(pCommand->u.delStaSessionCmd.callback)
13312 {
13313
13314 status = sme_ReleaseGlobalLock( &pMac->sme );
13315 if ( HAL_STATUS_SUCCESS( status ) )
13316 {
13317 pCommand->u.delStaSessionCmd.callback(
13318 pCommand->u.delStaSessionCmd.pContext);
13319 status = sme_AcquireGlobalLock( &pMac->sme );
13320 if (! HAL_STATUS_SUCCESS( status ) )
13321 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013322 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 return status;
13324 }
13325 }
13326 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013327 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013328 }
13329 }
13330
13331 //Remove this command out of the active list
13332 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13333 {
13334 //Now put this command back on the avilable command list
13335 csrReleaseCommand(pMac, pCommand);
13336 }
13337 smeProcessPendingQueue( pMac );
13338 }
13339 else
13340 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013341 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 -070013342 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013343 status = eHAL_STATUS_FAILURE;
13344 break;
13345 }
13346 }
13347 else
13348 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013349 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 -070013350 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013351 status = eHAL_STATUS_FAILURE;
13352 break;
13353 }
13354 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013355 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013356}
Jeff Johnson295189b2012-06-20 16:38:30 -070013357eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13358{
13359 tSirSmeDelStaSelfReq *pMsg;
13360 tANI_U16 msgLen;
13361 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013362 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013363 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13364 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013365 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13366 if ( !HAL_STATUS_SUCCESS(status) ) break;
13367
13368 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013369 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13370 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013371 // self station address
13372 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013373 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013374 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013375 return( status );
13376}
Jeff Johnson295189b2012-06-20 16:38:30 -070013377eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13378 tSirMacAddr sessionMacAddr,
13379 csrRoamSessionCloseCallback callback,
13380 void *pContext)
13381{
13382 eHalStatus status = eHAL_STATUS_SUCCESS;
13383 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013384 pCommand = csrGetCommandBuffer(pMac);
13385 if(NULL == pCommand)
13386 {
13387 status = eHAL_STATUS_RESOURCES;
13388 }
13389 else
13390 {
13391 pCommand->command = eSmeCommandDelStaSession;
13392 pCommand->sessionId = (tANI_U8)sessionId;
13393 pCommand->u.delStaSessionCmd.callback = callback;
13394 pCommand->u.delStaSessionCmd.pContext = pContext;
13395 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013396 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13397 if( !HAL_STATUS_SUCCESS( status ) )
13398 {
13399 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013400 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013401 }
13402 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013403 return (status);
13404}
Jeff Johnson295189b2012-06-20 16:38:30 -070013405eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13406{
13407 return csrSendMBDelSelfStaReqMsg( pMac,
13408 pCommand->u.delStaSessionCmd.selfMacAddr );
13409}
Jeff Johnson295189b2012-06-20 16:38:30 -070013410static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13411{
13412 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13413 tListElem *pEntry, *pNext;
13414 tSmeCmd *pCommand;
13415 tDblLinkList localList;
13416
13417 vos_mem_zero(&localList, sizeof(tDblLinkList));
13418 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13419 {
13420 smsLog(pMac, LOGE, FL(" failed to open list"));
13421 return;
13422 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013423 csrLLLock(pList);
13424 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13425 while(pEntry != NULL)
13426 {
13427 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13428 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13429 if(pCommand->sessionId == sessionId)
13430 {
13431 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13432 {
13433 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13434 }
13435 }
13436 pEntry = pNext;
13437 }
13438 csrLLUnlock(pList);
13439
13440 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13441 {
13442 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13443 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13444 }
13445 csrLLClose(&localList);
13446}
13447
Jeff Johnson295189b2012-06-20 16:38:30 -070013448void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13449{
13450 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13451 {
13452 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013453 csrRoamStop(pMac, sessionId);
13454 csrFreeConnectBssDesc(pMac, sessionId);
13455 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13456 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
13457 palTimerFree(pMac->hHdd, pSession->hTimerRoaming);
13458#ifdef FEATURE_WLAN_BTAMP_UT_RF
13459 palTimerFree(pMac->hHdd, pSession->hTimerJoinRetry);
13460#endif
13461 palTimerFree(pMac->hHdd, pSession->hTimerIbssJoining);
13462 purgeSmeSessionCmdList(pMac, sessionId);
13463 purgeCsrSessionCmdList(pMac, sessionId);
13464 csrInitSession(pMac, sessionId);
13465 }
13466}
13467
Jeff Johnson295189b2012-06-20 16:38:30 -070013468eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13469 tANI_BOOLEAN fSync,
13470 csrRoamSessionCloseCallback callback,
13471 void *pContext )
13472{
13473 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013474 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13475 {
13476 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13477 if(fSync)
13478 {
13479 csrCleanupSession(pMac, sessionId);
13480 }
13481 else
13482 {
13483 purgeSmeSessionCmdList(pMac, sessionId);
13484 purgeCsrSessionCmdList(pMac, sessionId);
13485 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13486 pSession->selfMacAddr, callback, pContext);
13487 }
13488 }
13489 else
13490 {
13491 status = eHAL_STATUS_INVALID_PARAMETER;
13492 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013493 return ( status );
13494}
13495
Jeff Johnson295189b2012-06-20 16:38:30 -070013496static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13497{
13498 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013499
13500 if(!pSession)
13501 {
13502 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13503 return;
13504 }
13505
Jeff Johnson295189b2012-06-20 16:38:30 -070013506 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13507 pSession->sessionId = CSR_SESSION_ID_INVALID;
13508 pSession->callback = NULL;
13509 pSession->pContext = NULL;
13510 pSession->ibss_join_pending = FALSE;
13511 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13512 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13513 csrFreeRoamProfile( pMac, sessionId );
13514 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13515 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13516 csrFreeConnectBssDesc(pMac, sessionId);
13517 csrScanEnable(pMac);
13518 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13519 if(pSession->pWpaRsnReqIE)
13520 {
13521 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13522 pSession->pWpaRsnReqIE = NULL;
13523 }
13524 pSession->nWpaRsnReqIeLength = 0;
13525 if(pSession->pWpaRsnRspIE)
13526 {
13527 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13528 pSession->pWpaRsnRspIE = NULL;
13529 }
13530 pSession->nWpaRsnRspIeLength = 0;
13531#ifdef FEATURE_WLAN_WAPI
13532 if(pSession->pWapiReqIE)
13533 {
13534 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13535 pSession->pWapiReqIE = NULL;
13536 }
13537 pSession->nWapiReqIeLength = 0;
13538 if(pSession->pWapiRspIE)
13539 {
13540 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13541 pSession->pWapiRspIE = NULL;
13542 }
13543 pSession->nWapiRspIeLength = 0;
13544#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013545 if(pSession->pAddIEScan)
13546 {
13547 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13548 pSession->pAddIEScan = NULL;
13549 }
13550 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013551 if(pSession->pAddIEAssoc)
13552 {
13553 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13554 pSession->pAddIEAssoc = NULL;
13555}
13556 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013557}
13558
Jeff Johnson295189b2012-06-20 16:38:30 -070013559eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13560{
13561 eHalStatus status = eHAL_STATUS_FAILURE;
13562 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013563 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13564 {
13565 if( CSR_IS_SESSION_VALID( pMac, i ) )
13566 {
13567 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13568 {
13569 //Found it
13570 status = eHAL_STATUS_SUCCESS;
13571 *pSessionId = i;
13572 break;
13573 }
13574 }
13575 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013576 return( status );
13577}
13578
Jeff Johnson295189b2012-06-20 16:38:30 -070013579//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13580//session because for IBSS, the bssid changes.
13581static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13582{
13583 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13584 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013585 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13586 {
13587 if( CSR_IS_SESSION_VALID( pMac, i ) )
13588 {
13589 pSession = CSR_GET_SESSION( pMac, i );
13590 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13591 {
13592 //Found it
13593 nRet = i;
13594 break;
13595 }
13596 }
13597 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013598 return (nRet);
13599}
Jeff Johnson295189b2012-06-20 16:38:30 -070013600static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13601{
13602 /* Update the current BSS info in ho control block based on connected
13603 profile info from pmac global structure */
13604
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013605 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013606 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13607 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013608 /* Check for user misconfig of RSSI trigger threshold */
13609 pMac->roam.configParam.vccRssiThreshold =
13610 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13611 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13612 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013613 /* Check for user misconfig of UL MAC Loss trigger threshold */
13614 pMac->roam.configParam.vccUlMacLossThreshold =
13615 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13616 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013617#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13618 {
13619 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 /* Indicate the neighbor roal algorithm about the connect indication */
13621 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13622 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13623 }
13624#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013625}
13626
Jeff Johnson295189b2012-06-20 16:38:30 -070013627static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13628{
13629 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013630
13631 if(!pSession)
13632 {
13633 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13634 return;
13635 }
13636
Jeff Johnson295189b2012-06-20 16:38:30 -070013637 //Only to handle the case for Handover on infra link
13638 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13639 {
13640 return;
13641 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013642 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13643 csrRoamDeregStatisticsReq(pMac);
13644 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13645#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13646 /* Indicate the neighbor roal algorithm about the disconnect indication */
13647 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13648#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013649
13650 //Remove this code once SLM_Sessionization is supported
13651 //BMPS_WORKAROUND_NOT_NEEDED
13652 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013653 csrIsInfraApStarted( pMac ) &&
13654 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013655 {
13656 pMac->roam.configParam.doBMPSWorkaround = 0;
13657 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013658}
13659
Jeff Johnson295189b2012-06-20 16:38:30 -070013660void csrRoamTlStatsTimerHandler(void *pv)
13661{
13662 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13663 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013664 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13665
Jeff Johnsone7245742012-09-05 17:12:55 -070013666 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13667
Jeff Johnson295189b2012-06-20 16:38:30 -070013668#if 0
13669 // TODO Persession .???
13670 //req TL for stats
13671 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13672 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013673 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 }
13675 else
13676 {
13677 //save in SME
13678 csrRoamSaveStatsFromTl(pMac, tlStats);
13679 }
13680#endif
13681 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13682 {
13683 if(pMac->roam.tlStatsReqInfo.periodicity)
13684 {
13685 //start timer
13686 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13687 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
13688 if(!HAL_STATUS_SUCCESS(status))
13689 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013690 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013691 return;
13692 }
13693 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13694 }
13695 }
13696}
Jeff Johnson295189b2012-06-20 16:38:30 -070013697void csrRoamPeStatsTimerHandler(void *pv)
13698{
13699 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13700 eHalStatus status;
13701 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13702 VOS_STATUS vosStatus;
13703 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013704 pPeStatsReqListEntry->timerRunning = FALSE;
13705 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13706 {
13707 // If we entered here, meaning the timer could not be successfully
13708 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13709
13710 /* Destroy the timer */
13711 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13712 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13713 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013714 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013715 }
13716
13717 // Free the entry
13718 palFreeMemory(pMac->hHdd, pPeStatsReqListEntry);
13719 pPeStatsReqListEntry = NULL;
13720 }
13721 else
13722 {
13723 if(!pPeStatsReqListEntry->rspPending)
13724 {
13725 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13726 pPeStatsReqListEntry->staId);
13727 if(!HAL_STATUS_SUCCESS(status))
13728 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013729 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013730 }
13731 else
13732 {
13733 pPeStatsReqListEntry->rspPending = TRUE;
13734 }
13735 }
13736
13737 //send down a req
13738 if(pPeStatsReqListEntry->periodicity &&
13739 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13740 {
13741 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13742 if(ePMC_FULL_POWER == powerState)
13743 {
13744 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13745 {
13746 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13747 }
13748 }
13749 else
13750 {
13751 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13752 {
13753 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13754 }
13755 }
13756 //start timer
13757 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13758 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13759 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013760 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013761 return;
13762 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 pPeStatsReqListEntry->timerRunning = TRUE;
13764
13765 }
13766
13767 }
13768}
Jeff Johnson295189b2012-06-20 16:38:30 -070013769void csrRoamStatsClientTimerHandler(void *pv)
13770{
13771 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13773 {
13774#if 0
13775 // TODO Stats fix for multisession
13776 //start the timer
13777 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13778
13779 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13780 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013781 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 }
13783#endif
13784 }
13785#if 0
13786 //send up the stats report
13787 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13788 pStaEntry->staId, pStaEntry->pContext);
13789#endif
13790}
13791
13792
13793
Jeff Johnson295189b2012-06-20 16:38:30 -070013794eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13795{
13796 tAniGetPEStatsReq *pMsg;
13797 eHalStatus status = eHAL_STATUS_SUCCESS;
13798 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13799 if ( !HAL_STATUS_SUCCESS(status) )
13800 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013801 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013802 return status;
13803 }
13804 // need to initiate a stats request to PE
13805 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13806 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13807 pMsg->staId = staId;
13808 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013810 if(!HAL_STATUS_SUCCESS(status))
13811 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013812 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013813 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013814 return status;
13815}
Jeff Johnson295189b2012-06-20 16:38:30 -070013816void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13817{
13818 tAniGetPEStatsRsp *pSmeStatsRsp;
13819 eHalStatus status = eHAL_STATUS_FAILURE;
13820 tListElem *pEntry = NULL;
13821 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13822 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13823 tANI_U32 tempMask = 0;
13824 tANI_U8 counter = 0;
13825 tANI_U8 *pStats = NULL;
13826 tANI_U32 length = 0;
13827 v_PVOID_t pvosGCtx;
13828 v_S7_t rssi = 0;
13829 tANI_U32 *pRssi = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013830 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13831 if(pSmeStatsRsp->rc)
13832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013833 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013834 goto post_update;
13835 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 tempMask = pSmeStatsRsp->statsMask;
13837 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013838 /* subtract all statistics from this length, and after processing the entire
13839 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13840 * in this 'stats' message.
13841 */
13842 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013843 //new stats info from PE, fill up the stats strucutres in PMAC
13844 while(tempMask)
13845 {
13846 if(tempMask & 1)
13847 {
13848 switch(counter)
13849 {
13850 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013851 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013852 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13853 pStats, sizeof(tCsrSummaryStatsInfo));
13854 if(!HAL_STATUS_SUCCESS(status))
13855 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013856 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013857 }
13858 pStats += sizeof(tCsrSummaryStatsInfo);
13859 length -= sizeof(tCsrSummaryStatsInfo);
13860 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013861 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013862 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013863 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13864 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13865 if(!HAL_STATUS_SUCCESS(status))
13866 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013867 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013868 }
13869 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13870 length -= sizeof(tCsrGlobalClassAStatsInfo);
13871 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013872 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013873 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13875 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13876 if(!HAL_STATUS_SUCCESS(status))
13877 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013878 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013879 }
13880 pStats += sizeof(tCsrGlobalClassBStatsInfo);
13881 length -= sizeof(tCsrGlobalClassBStatsInfo);
13882 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013883 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013884 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013885 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
13886 pStats, sizeof(tCsrGlobalClassCStatsInfo));
13887 if(!HAL_STATUS_SUCCESS(status))
13888 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013889 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013890 }
13891 pStats += sizeof(tCsrGlobalClassCStatsInfo);
13892 length -= sizeof(tCsrGlobalClassCStatsInfo);
13893 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013894 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013895 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013896 if( CSR_MAX_STA > pSmeStatsRsp->staId )
13897 {
13898 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
13899 pStats, sizeof(tCsrPerStaStatsInfo));
13900 }
13901 else
13902 {
13903 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013904 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013905 VOS_ASSERT( 0 );
13906 }
13907 if(!HAL_STATUS_SUCCESS(status))
13908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013909 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013910 }
13911 pStats += sizeof(tCsrPerStaStatsInfo);
13912 length -= sizeof(tCsrPerStaStatsInfo);
13913 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013914 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013915 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013916 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013917 }
13918 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013919 tempMask >>=1;
13920 counter++;
13921 }
13922 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
13923 if (length != 0)
13924 {
13925 pRssi = (tANI_U32*)pStats;
13926 rssi = (v_S7_t)*pRssi;
13927 }
13928 else
13929 {
13930 /* If riva is not sending rssi, continue to use the hack */
13931 rssi = RSSI_HACK_BMPS;
13932 }
13933 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -070013934post_update:
13935 //make sure to update the pe stats req list
13936 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
13937 if(pEntry)
13938 {
13939 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
13940 pPeStaEntry->rspPending = FALSE;
13941
13942 }
13943 //check the one timer cases
13944 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
13945 if(pEntry)
13946 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013947 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013948 if(pTempStaEntry->timerExpired)
13949 {
13950 //send up the stats report
13951 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
13952 pTempStaEntry->staId, pTempStaEntry->pContext);
13953 //also remove from the client list
13954 csrRoamRemoveStatListEntry(pMac, pEntry);
13955 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 }
13957 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013958}
Jeff Johnson295189b2012-06-20 16:38:30 -070013959tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13960{
13961 tListElem *pEntry = NULL;
13962 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013963 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013964 if(!pEntry)
13965 {
13966 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013967 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070013968 return NULL;
13969 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 while( pEntry )
13971 {
13972 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013973 if(pTempStaEntry->statsMask == statsMask)
13974 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013975 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070013976 break;
13977 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013978 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
13979 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 return pEntry;
13981}
13982
Jeff Johnson295189b2012-06-20 16:38:30 -070013983tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
13984 tANI_BOOLEAN update)
13985{
13986 tListElem *pEntry;
13987 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013989 if(!pEntry)
13990 {
13991 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013992 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013993 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070013994 return NULL;
13995 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013996 while( pEntry )
13997 {
13998 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013999 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14000 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14001 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014002 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014003 if(update)
14004 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014005 pTempStaEntry->periodicity = pStaEntry->periodicity;
14006 pTempStaEntry->callback = pStaEntry->callback;
14007 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014008 }
14009 break;
14010 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014011 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14012 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 return pEntry;
14014}
Jeff Johnson295189b2012-06-20 16:38:30 -070014015tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14016{
14017 tListElem *pEntry;
14018 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014020 if(!pEntry)
14021 {
14022 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014023 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014024 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014025 return NULL;
14026 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 while( pEntry )
14028 {
14029 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014030 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14031 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014032 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014033 break;
14034 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014035 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14036 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014037 return pEntry;
14038}
Jeff Johnson295189b2012-06-20 16:38:30 -070014039eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14040 csrRoamLinkQualityIndCallback callback,
14041 void *pContext)
14042{
14043 pMac->roam.linkQualityIndInfo.callback = callback;
14044 pMac->roam.linkQualityIndInfo.context = pContext;
14045 if( NULL == callback )
14046 {
14047 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14048 }
14049 else
14050 {
14051 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014052 /* do we need to invoke the callback to notify client of initial value ?? */
14053 }
14054 return eHAL_STATUS_SUCCESS;
14055}
Jeff Johnson295189b2012-06-20 16:38:30 -070014056void csrRoamVccTrigger(tpAniSirGlobal pMac)
14057{
14058 eCsrRoamLinkQualityInd newVccLinkQuality;
14059 tANI_U32 ul_mac_loss = 0;
14060 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014061 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14062 /*-------------------------------------------------------------------------
14063 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014064 Check for a change in link quality and notify client if necessary
14065 -------------------------------------------------------------------------*/
14066 ul_mac_loss_trigger_threshold =
14067 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014069 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014070 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014071 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14072 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014073 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014074 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14075 }
14076 else
14077 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014078 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014079 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14080 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014081 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14082 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014083 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14084 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014085 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014086 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14087 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014088 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014089 newVccLinkQuality );
14090
14091 /* we now invoke the callback once to notify client of initial value */
14092 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14093 pMac->roam.linkQualityIndInfo.context );
14094 //event: EVENT_WLAN_VCC
14095 }
14096 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014097 pMac->roam.vccLinkQuality = newVccLinkQuality;
14098
Jeff Johnson295189b2012-06-20 16:38:30 -070014099}
Jeff Johnson295189b2012-06-20 16:38:30 -070014100VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14101 v_U8_t rssiNotification,
14102 void * context)
14103{
14104 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14105 eCsrRoamLinkQualityInd newVccLinkQuality;
14106 // TODO : Session info unavailable
14107 tANI_U32 sessionId = 0;
14108 VOS_STATUS status = VOS_STATUS_SUCCESS;
14109 /*-------------------------------------------------------------------------
14110 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014111 Check for a change in link quality and notify client if necessary
14112 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014113 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014114 pMac->roam.configParam.vccRssiThreshold);
14115 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14116 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014117 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014118 return VOS_STATUS_SUCCESS;
14119 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014120 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14121 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014122 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014123 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14124 }
14125 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14126 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014127 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014128 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14129 }
14130 else
14131 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014132 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014133 //Set to this so the code below won't do anything
14134 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014135 VOS_ASSERT(0);
14136 }
14137
Jeff Johnson295189b2012-06-20 16:38:30 -070014138 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14139 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014140 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014141 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14142 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014143 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014144 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014145 /* we now invoke the callback once to notify client of initial value */
14146 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14147 pMac->roam.linkQualityIndInfo.context );
14148 //event: EVENT_WLAN_VCC
14149 }
14150 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014151 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014152 return status;
14153}
Jeff Johnson295189b2012-06-20 16:38:30 -070014154tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14155 tDblLinkList *pStaList,
14156 tCsrStatsClientReqInfo *pStaEntry)
14157{
14158 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014159 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014160 //if same entity requested for same set of stats with different periodicity &
14161 // callback update it
14162 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14163 {
14164
14165 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
14166 if (!HAL_STATUS_SUCCESS(status))
14167 {
14168 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014169 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014170 return NULL;
14171 }
14172
Jeff Johnson295189b2012-06-20 16:38:30 -070014173 pNewStaEntry->callback = pStaEntry->callback;
14174 pNewStaEntry->pContext = pStaEntry->pContext;
14175 pNewStaEntry->periodicity = pStaEntry->periodicity;
14176 pNewStaEntry->requesterId = pStaEntry->requesterId;
14177 pNewStaEntry->statsMask = pStaEntry->statsMask;
14178 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14179 pNewStaEntry->pMac = pStaEntry->pMac;
14180 pNewStaEntry->staId = pStaEntry->staId;
14181 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14182
14183 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14184 }
14185 return pNewStaEntry;
14186}
14187
Jeff Johnson295189b2012-06-20 16:38:30 -070014188tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14189 tDblLinkList *pStaList,
14190 tCsrPeStatsReqInfo *pStaEntry)
14191{
14192 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014193 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014194 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
14195 if (!HAL_STATUS_SUCCESS(status))
14196 {
14197 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014198 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014199 return NULL;
14200 }
14201
Jeff Johnson295189b2012-06-20 16:38:30 -070014202 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14203 pNewStaEntry->numClient = pStaEntry->numClient;
14204 pNewStaEntry->periodicity = pStaEntry->periodicity;
14205 pNewStaEntry->statsMask = pStaEntry->statsMask;
14206 pNewStaEntry->pMac = pStaEntry->pMac;
14207 pNewStaEntry->staId = pStaEntry->staId;
14208 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14209 pNewStaEntry->rspPending = pStaEntry->rspPending;
14210
14211 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014212 return pNewStaEntry;
14213}
Jeff Johnson295189b2012-06-20 16:38:30 -070014214eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14215 tCsrRssiCallback callback,
14216 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14217{
14218 eHalStatus status = eHAL_STATUS_SUCCESS;
14219 vos_msg_t msg;
14220 tANI_U32 sessionId;
14221
14222 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014223 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014224 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14225 if ( !HAL_STATUS_SUCCESS(status) )
14226 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014227 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014228 return status;
14229 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014230 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14231
14232 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14233 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14234 pMsg->sessionId = sessionId;
14235 pMsg->staId = staId;
14236 pMsg->rssiCallback = callback;
14237 pMsg->pDevContext = pContext;
14238 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014239 msg.type = eWNI_SME_GET_RSSI_REQ;
14240 msg.bodyptr = pMsg;
14241 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014242 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14243 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014244 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014245 palFreeMemory(pMac->hHdd, (void *)pMsg);
14246 status = eHAL_STATUS_FAILURE;
14247 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014248 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014249 return status;
14250}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014251
14252#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14253eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14254 tCsrRssiCallback callback,
14255 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14256{
14257 eHalStatus status = eHAL_STATUS_SUCCESS;
14258 tAniGetRssiReq *pMsg;
14259
14260 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14261 if ( !HAL_STATUS_SUCCESS(status) )
14262 {
14263 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
14264 return status;
14265 }
14266 // need to initiate a stats request to PE
14267 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
14268 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14269 pMsg->staId = staId;
14270 pMsg->rssiCallback = callback;
14271 pMsg->pDevContext = pContext;
14272 pMsg->pVosContext = pVosContext;
14273 status = palSendMBMessage(pMac->hHdd, pMsg );
14274 if(!HAL_STATUS_SUCCESS(status))
14275 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070014276 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
14277 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014278 status = eHAL_STATUS_FAILURE;
14279 }
14280 return status;
14281}
14282#endif
14283
Jeff Johnson295189b2012-06-20 16:38:30 -070014284eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
14285 tANI_U32 statsMask,
14286 tCsrStatsCallback callback,
14287 tANI_U32 periodicity, tANI_BOOLEAN cache,
14288 tANI_U8 staId, void *pContext)
14289{
14290 tCsrStatsClientReqInfo staEntry;
14291 tCsrStatsClientReqInfo *pStaEntry = NULL;
14292 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14293 tListElem *pEntry = NULL;
14294 tANI_BOOLEAN found = FALSE;
14295 eHalStatus status = eHAL_STATUS_SUCCESS;
14296 tANI_BOOLEAN insertInClientList = FALSE;
14297 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070014298 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014299
14300 if( csrIsAllSessionDisconnected(pMac) )
14301 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014302 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014303 return eHAL_STATUS_FAILURE;
14304 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014305 if((!statsMask) && (!callback))
14306 {
14307 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014308 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070014309 return eHAL_STATUS_FAILURE;
14310 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014311 //for the search list method for deregister
14312 staEntry.requesterId = requesterId;
14313 staEntry.statsMask = statsMask;
14314 //requester wants to deregister or just an error
14315 if((statsMask) && (!callback))
14316 {
14317 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
14318 if(!pEntry)
14319 {
14320 //msg
14321 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014322 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014323 return eHAL_STATUS_FAILURE;
14324 }
14325 else
14326 {
14327 //clean up & return
14328 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070014329 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014330 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014331 pStaEntry->pPeStaEntry->numClient--;
14332 //check if we need to delete the entry from peStatsReqList too
14333 if(!pStaEntry->pPeStaEntry->numClient)
14334 {
14335 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14336 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014337 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014338
Jeff Johnson295189b2012-06-20 16:38:30 -070014339 //check if we need to stop the tl stats timer too
14340 pMac->roam.tlStatsReqInfo.numClient--;
14341 if(!pMac->roam.tlStatsReqInfo.numClient)
14342 {
14343 if(pMac->roam.tlStatsReqInfo.timerRunning)
14344 {
14345 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14346 if(!HAL_STATUS_SUCCESS(status))
14347 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014348 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014349 return eHAL_STATUS_FAILURE;
14350 }
14351 }
14352 pMac->roam.tlStatsReqInfo.periodicity = 0;
14353 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14354 }
14355 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014356 // Destroy the vos timer...
14357 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14358 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14359 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014360 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014361 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014362 csrRoamRemoveStatListEntry(pMac, pEntry);
14363 pStaEntry = NULL;
14364 return eHAL_STATUS_SUCCESS;
14365 }
14366 }
14367
14368 if(cache && !periodicity)
14369 {
14370 //return the cached stats
14371 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14372 }
14373 else
14374 {
14375 //add the request in the client req list
14376 staEntry.callback = callback;
14377 staEntry.pContext = pContext;
14378 staEntry.periodicity = periodicity;
14379 staEntry.pPeStaEntry = NULL;
14380 staEntry.staId = staId;
14381 staEntry.pMac = pMac;
14382 staEntry.timerExpired = FALSE;
14383
14384
Jeff Johnson295189b2012-06-20 16:38:30 -070014385 //if periodic report requested with non cached result from PE/TL
14386 if(periodicity)
14387 {
14388
14389 //if looking for stats from PE
14390 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14391 {
14392
14393 //check if same request made already & waiting for rsp
14394 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14395 periodicity, &found, staId);
14396 if(!pPeStaEntry)
14397 {
14398 //bail out, maxed out on number of req for PE
14399 return eHAL_STATUS_FAILURE;
14400 }
14401 else
14402 {
14403 staEntry.pPeStaEntry = pPeStaEntry;
14404 }
14405
14406 }
14407 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14408 if(statsMask & (1 << eCsrGlobalClassDStats))
14409 {
14410 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14411 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014412 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014413 }
14414 else
14415 {
14416
14417 //update periodicity
14418 if(pMac->roam.tlStatsReqInfo.periodicity)
14419 {
14420 pMac->roam.tlStatsReqInfo.periodicity =
14421 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14422 }
14423 else
14424 {
14425 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14426 }
14427 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14428 {
14429 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14430 }
14431
14432 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14433 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014434 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14435 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014436 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014437 //req TL for class D stats
14438 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14439 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014440 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014441 }
14442 else
14443 {
14444 //save in SME
14445 csrRoamSaveStatsFromTl(pMac, pTlStats);
14446 }
14447 vos_mem_free(pTlStats);
14448 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014449 }
14450 else
14451 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014452 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014453 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014454
Jeff Johnson295189b2012-06-20 16:38:30 -070014455 if(pMac->roam.tlStatsReqInfo.periodicity)
14456 {
14457 //start timer
14458 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14459 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
14460 if(!HAL_STATUS_SUCCESS(status))
14461 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014462 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014463 return eHAL_STATUS_FAILURE;
14464 }
14465 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14466 }
14467 }
14468 }
14469 pMac->roam.tlStatsReqInfo.numClient++;
14470 }
14471
14472 insertInClientList = TRUE;
14473 }
14474 //if one time report requested with non cached result from PE/TL
14475 else if(!cache && !periodicity)
14476 {
14477 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14478 {
14479 //send down a req
14480 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14481 if(!HAL_STATUS_SUCCESS(status))
14482 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014483 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014484 }
14485 //so that when the stats rsp comes back from PE we respond to upper layer
14486 //right away
14487 staEntry.timerExpired = TRUE;
14488 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014489 }
14490 if(statsMask & (1 << eCsrGlobalClassDStats))
14491 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014492 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14493 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014494 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014495 //req TL for class D stats
14496 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14497 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014498 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014499 }
14500 else
14501 {
14502 //save in SME
14503 csrRoamSaveStatsFromTl(pMac, pTlStats);
14504 }
14505 vos_mem_free(pTlStats);
14506 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014507 }
14508 else
14509 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014510 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014511 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014512
14513 }
14514 //if looking for stats from TL only
14515 if(!insertInClientList)
14516 {
14517 //return the stats
14518 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14519 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014520 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014521 if(insertInClientList)
14522 {
14523 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14524 if(!pStaEntry)
14525 {
14526 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014527 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014528 return eHAL_STATUS_FAILURE;
14529 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014530 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014531 //Init & start timer if needed
14532 if(periodicity)
14533 {
14534 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14535 csrRoamStatsClientTimerHandler, pStaEntry );
14536 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14537 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014538 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014539 return eHAL_STATUS_FAILURE;
14540 }
14541 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14542 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14543 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014544 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014545 return eHAL_STATUS_FAILURE;
14546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014547 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014548 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014549 }
14550 return eHAL_STATUS_SUCCESS;
14551}
14552
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014553#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
14554
14555static tSirRetStatus
14556csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
14557 tANI_U8* pBD,
14558 tANI_U8 type,
14559 tANI_U8 subType,
14560 tSirMacAddr peerAddr,
14561 tSirMacAddr selfMacAddr)
14562{
14563 tSirRetStatus statusCode = eSIR_SUCCESS;
14564 tpSirMacMgmtHdr pMacHdr;
14565
14566 /* Prepare MAC management header */
14567 pMacHdr = (tpSirMacMgmtHdr) (pBD);
14568
14569 /* Prepare FC */
14570 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14571 pMacHdr->fc.type = type;
14572 pMacHdr->fc.subType = subType;
14573
14574 /* Prepare Address 1 */
14575 palCopyMemory( pMac->hHdd,
14576 (tANI_U8 *) pMacHdr->da,
14577 (tANI_U8 *) peerAddr,
14578 sizeof( tSirMacAddr ));
14579
14580 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
14581
14582 /* Prepare Address 3 */
14583 palCopyMemory( pMac->hHdd,
14584 (tANI_U8 *) pMacHdr->bssId,
14585 (tANI_U8 *) peerAddr,
14586 sizeof( tSirMacAddr ));
14587 return statusCode;
14588} /*** csrRoamScanOffloadPopulateMacHeader() ***/
14589
14590static tSirRetStatus
14591csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
14592 tANI_U8 nChannelNum,
14593 tANI_U32 dot11mode,
14594 tSirMacAddr selfMacAddr,
14595 tANI_U8 *pFrame,
14596 tANI_U16 *pusLen)
14597{
14598 tDot11fProbeRequest pr;
14599 tANI_U32 nStatus, nBytes, nPayload;
14600 tSirRetStatus nSirStatus;
14601 /*Bcast tx*/
14602 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
14603 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14604
14605
14606 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
14607
14608 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
14609
14610 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
14611 {
14612 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
14613 }
14614
14615
14616 if (IS_DOT11_MODE_HT(dot11mode))
14617 {
14618 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
14619 }
14620
14621
14622 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
14623 if ( DOT11F_FAILED( nStatus ) )
14624 {
14625 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14626 "Failed to calculate the packed size f"
14627 "or a Probe Request (0x%08x).\n", nStatus );
14628
14629
14630 nPayload = sizeof( tDot11fProbeRequest );
14631 }
14632 else if ( DOT11F_WARNED( nStatus ) )
14633 {
14634 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14635 "There were warnings while calculating"
14636 "the packed size for a Probe Request ("
14637 "0x%08x).\n", nStatus );
14638 }
14639
14640 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
14641
14642 /* Prepare outgoing frame*/
14643 palZeroMemory( pMac->hHdd, pFrame, nBytes );
14644
14645
14646 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
14647 SIR_MAC_MGMT_PROBE_REQ, bssId ,selfMacAddr);
14648
14649 if ( eSIR_SUCCESS != nSirStatus )
14650 {
14651 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14652 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
14653 nSirStatus );
14654 return nSirStatus;
14655 }
14656
14657
14658 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
14659 sizeof( tSirMacMgmtHdr ),
14660 nPayload, &nPayload );
14661 if ( DOT11F_FAILED( nStatus ) )
14662 {
14663 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14664 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
14665 return eSIR_FAILURE;
14666 }
14667 else if ( DOT11F_WARNED( nStatus ) )
14668 {
14669 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14670 "There were warnings while packing a Probe Request (0x%08x).\n" );
14671 }
14672
14673 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
14674 return eSIR_SUCCESS;
14675}
14676
14677eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
14678{
14679 vos_msg_t msg;
14680 tSirRoamOffloadScanReq *pRequestBuf;
14681 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
14682 tCsrRoamSession *pSession;
14683 tANI_U8 i,num_channels = 0, ucDot11Mode;
14684 tANI_U8 *ChannelList = NULL;
14685 tANI_U32 sessionId;
14686 eHalStatus status = eHAL_STATUS_SUCCESS;
14687 tpCsrChannelInfo currChannelListInfo;
14688 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
14689
14690 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled)
14691 {
14692 return eHAL_STATUS_FAILURE;
14693 }
14694 status = csrRoamGetSessionIdFromBSSID(pMac,
14695 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
14696 &sessionId);
14697 /*The Dynamic Config Items Update may happen even if the state is in INIT.
14698 * It is important to ensure that the command is passed down to the FW only
14699 * if the Infra Station is in a connected state.A connected station could also be
14700 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
14701 * We also have to ensure that if there is a STOP command we always have to inform Riva,
14702 * irrespective of whichever state we are in.*/
14703 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
14704 (command != ROAM_SCAN_OFFLOAD_STOP))
14705 {
14706 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
14707 pMac->roam.neighborRoamInfo.neighborRoamState, command);
14708 return eHAL_STATUS_FAILURE;
14709 }
14710
14711 if ( !HAL_STATUS_SUCCESS( status ) )
14712 {
14713 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
14714 return eHAL_STATUS_FAILURE;
14715 }
14716 pSession = CSR_GET_SESSION( pMac, sessionId );
14717 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
14718 if (NULL == pRequestBuf)
14719 {
14720 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
14721 return eHAL_STATUS_FAILED_ALLOC;
14722 }
14723
14724 vos_mem_zero(pRequestBuf,sizeof(tSirRoamOffloadScanReq));
14725 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
14726 * host driver reloads, but Riva still up and running*/
14727 if(command == ROAM_SCAN_OFFLOAD_STOP)
14728 pRequestBuf->RoamScanOffloadEnabled = 0;
14729 else
14730 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
14731 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid, pNeighborRoamInfo->currAPbssid,
14732 sizeof(tCsrBssid));
14733 pRequestBuf->ConnectedNetwork.ssId.length =
14734 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
14735 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
14736 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
14737 pRequestBuf->ConnectedNetwork.ssId.length);
14738 pRequestBuf->ConnectedNetwork.authentication =
14739 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
14740 pRequestBuf->ConnectedNetwork.encryption =
14741 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
14742 pRequestBuf->ConnectedNetwork.mcencryption =
14743 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
14744 pRequestBuf->LookupThreshold =
14745 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
14746 pRequestBuf->RoamRssiDiff =
14747 pMac->roam.configParam.RoamRssiDiff;
14748 pRequestBuf->Command = command;
14749 pRequestBuf->StartScanReason = reason;
14750 pRequestBuf->NeighborScanTimerPeriod =
14751 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
14752 pRequestBuf->NeighborRoamScanRefreshPeriod =
14753 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
14754 pRequestBuf->NeighborScanChannelMinTime =
14755 pNeighborRoamInfo->cfgParams.minChannelScanTime;
14756 pRequestBuf->NeighborScanChannelMaxTime =
14757 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
14758 pRequestBuf->EmptyRefreshScanPeriod =
14759 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
14760#ifdef FEATURE_WLAN_CCX
14761 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
14762#endif
14763 if (
14764#ifdef FEATURE_WLAN_CCX
14765 ((pNeighborRoamInfo->isCCXAssoc) &&
14766 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
14767 eANI_BOOLEAN_FALSE)) ||
14768 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
14769#endif // CCX
14770 currChannelListInfo->numOfChannels == 0)
14771 {
14772
14773 /*Retreive the Channel Cache either from ini or from the Occupied Channels list.
14774 * Give Preference to INI Channels.*/
14775 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
14776 {
14777 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
14778 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels ;i++)
14779 {
14780 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14781 {
14782 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14783 }
14784 ChannelList++;
14785 }
14786 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14787 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
14788 }
14789 else{
14790 ChannelList = pMac->scan.occupiedChannels.channelList;
14791 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
14792 {
14793 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14794 {
14795 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14796 }
14797 ChannelList++;
14798 }
14799 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14800 /* If the profile changes as to what it was earlier, inform the FW through
14801 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
14802 * for the earlier profile and try to learn them afresh.*/
14803 if (reason == REASON_FLUSH_CHANNEL_LIST)
14804 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
14805 else {
14806 if (csrNeighborRoamIsNewConnectedProfile(pMac))
14807 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
14808 else
14809 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
14810 }
14811 }
14812 }
14813#ifdef FEATURE_WLAN_CCX
14814 else
14815 {
14816 /* If CCX is enabled, and a neighbor Report is received,then
14817 * Ignore the INI Channels or the Occupied Channel List. Consider
14818 * the channels in the neighbor list sent by the CCX AP.*/
14819 if (currChannelListInfo->numOfChannels != 0)
14820 {
14821 ChannelList = currChannelListInfo->ChannelList;
14822 for (i=0;i<currChannelListInfo->numOfChannels;i++)
14823 {
14824 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14825 {
14826 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14827 }
14828 ChannelList++;
14829 }
14830 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14831 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
14832 }
14833 }
14834#endif
14835 num_channels = 0;
14836 ChannelList = NULL;
14837
14838 /* Maintain the Valid Channels List*/
14839 if (0 == strncmp(pMac->scan.countryCodeCurrent, "KR", 2))
14840 {
14841 ChannelList = pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
14842 for(i=0; i<pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels; i++)
14843 {
14844 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14845 {
14846 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
14847 }
14848 ChannelList++;
14849 }
14850 pRequestBuf->ValidChannelCount = num_channels;
14851 } else {
14852 ChannelList = pMac->roam.validChannelList;
14853 for(i=0; i<pMac->roam.numValidChannels; i++)
14854 {
14855 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14856 {
14857 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
14858 }
14859 ChannelList++;
14860 }
14861 pRequestBuf->ValidChannelCount = num_channels;
14862 }
14863 pRequestBuf->MDID.mdiePresent = pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
14864 pRequestBuf->MDID.mobilityDomain = pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
14865 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
14866 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
14867 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
14868 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
14869 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
14870
14871 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
14872 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
14873 msg.type = WDA_START_ROAM_CANDIDATE_LOOKUP_REQ;
14874 msg.reserved = 0;
14875 msg.bodyptr = pRequestBuf;
14876 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
14877 {
14878 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_START_ROAM_CANDIDATE_LOOKUP_REQ message to WDA", __func__);
14879 vos_mem_free(pRequestBuf);
14880 return eHAL_STATUS_FAILURE;
14881 }
14882
14883 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
14884 return status;
14885}
14886#endif
14887
Jeff Johnson295189b2012-06-20 16:38:30 -070014888tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
14889 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
14890{
14891 tANI_BOOLEAN found = FALSE;
14892 eHalStatus status = eHAL_STATUS_SUCCESS;
14893 tCsrPeStatsReqInfo staEntry;
14894 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
14895 tListElem *pStaEntry = NULL;
14896 VOS_STATUS vosStatus;
14897 tPmcPowerState powerState;
14898 *pFound = FALSE;
14899
14900 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
14901 if(pStaEntry)
14902 {
14903 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
14904 if(pTempStaEntry->periodicity)
14905 {
14906 pTempStaEntry->periodicity =
14907 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
14908 }
14909 else
14910 {
14911 pTempStaEntry->periodicity = periodicity;
14912 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014913 pTempStaEntry->numClient++;
14914 found = TRUE;
14915 }
14916 else
14917 {
14918 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
14919 staEntry.numClient = 1;
14920 staEntry.periodicity = periodicity;
14921 staEntry.pMac = pMac;
14922 staEntry.rspPending = FALSE;
14923 staEntry.staId = staId;
14924 staEntry.statsMask = statsMask;
14925 staEntry.timerRunning = FALSE;
14926 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
14927 if(!pTempStaEntry)
14928 {
14929 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014930 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014931 return NULL;
14932 }
14933 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014934 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14935 if(ePMC_FULL_POWER == powerState)
14936 {
14937 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14938 {
14939 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14940 }
14941 }
14942 else
14943 {
14944 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14945 {
14946 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14947 }
14948 }
14949 if(!pTempStaEntry->timerRunning)
14950 {
14951 //send down a req in case of one time req, for periodic ones wait for timer to expire
14952 if(!pTempStaEntry->rspPending &&
14953 !pTempStaEntry->periodicity)
14954 {
14955 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14956 if(!HAL_STATUS_SUCCESS(status))
14957 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014958 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014959 }
14960 else
14961 {
14962 pTempStaEntry->rspPending = TRUE;
14963 }
14964 }
14965 if(pTempStaEntry->periodicity)
14966 {
14967 if(!found)
14968 {
14969
14970 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
14971 csrRoamPeStatsTimerHandler, pTempStaEntry );
14972 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014974 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014975 return NULL;
14976 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014977 }
14978 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014979 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070014980 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
14981 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14982 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014983 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014984 return NULL;
14985 }
14986 pTempStaEntry->timerRunning = TRUE;
14987 }
14988 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014989 *pFound = found;
14990 return pTempStaEntry;
14991}
14992
Jeff Johnson295189b2012-06-20 16:38:30 -070014993/*
14994 pStaEntry is no longer invalid upon the return of this function.
14995*/
14996static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
14997{
14998 if(pEntry)
14999 {
15000 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15001 {
15002 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015003 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015004 }
15005 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015006
15007void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15008{
15009 tListElem *pEntry;
15010 tCsrPeStatsReqInfo *pTempStaEntry;
15011 VOS_STATUS vosStatus;
15012 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015013 if(!pEntry)
15014 {
15015 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015016 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015017 return;
15018 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015019 while( pEntry )
15020 {
15021 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015022 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15023 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015024 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015025 if(pTempStaEntry->timerRunning)
15026 {
15027 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15028 /* If we are not able to stop the timer here, just remove
15029 * the entry from the linked list. Destroy the timer object
15030 * and free the memory in the timer CB
15031 */
15032 if( vosStatus == VOS_STATUS_SUCCESS )
15033 {
15034 /* the timer is successfully stopped */
15035 pTempStaEntry->timerRunning = FALSE;
15036
15037 /* Destroy the timer */
15038 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15039 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15040 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015041 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015042 }
15043 }
15044 else
15045 {
15046 // the timer could not be stopped. Hence destroy and free the
15047 // memory for the PE stat entry in the timer CB.
15048 pTempStaEntry->timerStopFailed = TRUE;
15049 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015050 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015051
15052 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15053 {
15054 // Only free the memory if we could stop the timer successfully
15055 if(!pTempStaEntry->timerStopFailed)
15056 {
15057 palFreeMemory(pMac->hHdd, pTempStaEntry);
15058 pTempStaEntry = NULL;
15059 }
15060 break;
15061 }
15062
15063 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15064 }
15065 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015066 return;
15067}
15068
15069
Jeff Johnsone7245742012-09-05 17:12:55 -070015070void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015071{
15072
Jeff Johnsone7245742012-09-05 17:12:55 -070015073 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15074 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15075 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15076 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15077 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15078 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15079 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015080 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015081 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15082 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15083 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15084 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15085 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15086 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015087 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015088 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15089 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015090
15091}
15092
Jeff Johnson295189b2012-06-20 16:38:30 -070015093void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15094 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15095{
15096 tANI_U8 stats[500];
15097 tANI_U8 *pStats = NULL;
15098 tANI_U32 tempMask = 0;
15099 tANI_U8 counter = 0;
15100 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015101 if(!callback)
15102 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015103 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015104 return;
15105 }
15106 if(!statsMask)
15107 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015108 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015109 return;
15110 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015111 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015112 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015113 while(tempMask)
15114 {
15115 if(tempMask & 1)
15116 {
15117 //new stats info from PE, fill up the stats strucutres in PMAC
15118 switch(counter)
15119 {
15120 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015121 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015122 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
15123 sizeof(tCsrSummaryStatsInfo));
15124 if(!HAL_STATUS_SUCCESS(status))
15125 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015126 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015127 }
15128 pStats += sizeof(tCsrSummaryStatsInfo);
15129 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015130 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015131 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015132 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
15133 sizeof(tCsrGlobalClassAStatsInfo));
15134 if(!HAL_STATUS_SUCCESS(status))
15135 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015136 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015137 }
15138 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015139 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015140 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015141 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015142 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
15143 sizeof(tCsrGlobalClassBStatsInfo));
15144 if(!HAL_STATUS_SUCCESS(status))
15145 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015146 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015147 }
15148 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015149 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015150 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015151 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015152 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
15153 sizeof(tCsrGlobalClassCStatsInfo));
15154 if(!HAL_STATUS_SUCCESS(status))
15155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015156 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015157 }
15158 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015159 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015160 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015161 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015162 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
15163 sizeof(tCsrGlobalClassDStatsInfo));
15164 if(!HAL_STATUS_SUCCESS(status))
15165 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015166 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015167 }
15168 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015169 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015170 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015171 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015172 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
15173 sizeof(tCsrPerStaStatsInfo));
15174 if(!HAL_STATUS_SUCCESS(status))
15175 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015176 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015177 }
15178 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015179 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015180 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015181 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015182 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015183 }
15184 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015185 tempMask >>=1;
15186 counter++;
15187 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015188 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070015189}
15190
Jeff Johnson295189b2012-06-20 16:38:30 -070015191eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
15192{
15193 tListElem *pEntry = NULL;
15194 tListElem *pPrevEntry = NULL;
15195 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15196 eHalStatus status = eHAL_STATUS_SUCCESS;
15197 VOS_STATUS vosStatus;
15198 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015199 if(!pEntry)
15200 {
15201 //list empty
15202 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015203 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015204 return status;
15205 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015206 while( pEntry )
15207 {
15208 if(pPrevEntry)
15209 {
15210 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15211 //send up the stats report
15212 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15213 pTempStaEntry->staId, pTempStaEntry->pContext);
15214 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15215 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015216 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015217 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
15218 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015219 pTempStaEntry->pPeStaEntry->numClient--;
15220 //check if we need to delete the entry from peStatsReqList too
15221 if(!pTempStaEntry->pPeStaEntry->numClient)
15222 {
15223 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
15224 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015225 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015226 //check if we need to stop the tl stats timer too
15227 pMac->roam.tlStatsReqInfo.numClient--;
15228 if(!pMac->roam.tlStatsReqInfo.numClient)
15229 {
15230 if(pMac->roam.tlStatsReqInfo.timerRunning)
15231 {
15232 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15233 if(!HAL_STATUS_SUCCESS(status))
15234 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015235 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015236 //we will continue
15237 }
15238 }
15239 pMac->roam.tlStatsReqInfo.periodicity = 0;
15240 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15241 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015242 if (pTempStaEntry->periodicity)
15243 {
15244 //While creating StaEntry in csrGetStatistics,
15245 //Initializing and starting timer only when periodicity is set.
15246 //So Stop and Destroy timer only when periodicity is set.
15247
Jeff Johnsone7245742012-09-05 17:12:55 -070015248 vos_timer_stop( &pTempStaEntry->timer );
15249 // Destroy the vos timer...
15250 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
15251 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15252 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015253 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015254 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015255 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015256
Jeff Johnson295189b2012-06-20 16:38:30 -070015257
15258 pPrevEntry = pEntry;
15259 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15260 }
15261 //the last one
15262 if(pPrevEntry)
15263 {
15264 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15265 //send up the stats report
15266 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15267 pTempStaEntry->staId, pTempStaEntry->pContext);
15268 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15269 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015270 return status;
15271
15272}
15273
Jeff Johnson295189b2012-06-20 16:38:30 -070015274eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
15275 tRequestFullPowerReason *pReason,
15276 tANI_BOOLEAN *pfNeedPower )
15277{
15278 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15279 tRequestFullPowerReason reason = eSME_REASON_OTHER;
15280 tPmcState pmcState;
15281 eHalStatus status = eHAL_STATUS_SUCCESS;
15282 // TODO : Session info unavailable
15283 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015284 if( pfNeedPower )
15285 {
15286 *pfNeedPower = eANI_BOOLEAN_FALSE;
15287 }
15288 //We only handle CSR commands
15289 if( !(eSmeCsrCommandMask & pCommand->command) )
15290 {
15291 return eHAL_STATUS_SUCCESS;
15292 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015293 //Check PMC state first
15294 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015295 switch( pmcState )
15296 {
15297 case REQUEST_IMPS:
15298 case IMPS:
15299 if( eSmeCommandScan == pCommand->command )
15300 {
15301 switch( pCommand->u.scanCmd.reason )
15302 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015303#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15304 case eCsrScanGetLfrResult:
15305#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015306 case eCsrScanGetResult:
15307 case eCsrScanBGScanAbort:
15308 case eCsrScanBGScanEnable:
15309 case eCsrScanGetScanChnInfo:
15310 //Internal process, no need for full power
15311 fNeedFullPower = eANI_BOOLEAN_FALSE;
15312 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015313 default:
15314 //Other scans are real scan, ask for power
15315 fNeedFullPower = eANI_BOOLEAN_TRUE;
15316 break;
15317 } //switch
15318 }
15319 else
15320 {
15321 //ask for power for roam and status change
15322 fNeedFullPower = eANI_BOOLEAN_TRUE;
15323 }
15324 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015325 case REQUEST_BMPS:
15326 case BMPS:
15327 case REQUEST_START_UAPSD:
15328 case UAPSD:
15329 //We treat WOWL same as BMPS
15330 case REQUEST_ENTER_WOWL:
15331 case WOWL:
15332 if( eSmeCommandRoam == pCommand->command )
15333 {
15334 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
15335 tCsrScanResult *pScanResult;
15336 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015337 switch ( pCommand->u.roamCmd.roamReason )
15338 {
15339 case eCsrForcedDisassoc:
15340 case eCsrForcedDisassocMICFailure:
15341 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15342 fNeedFullPower = eANI_BOOLEAN_TRUE;
15343 break;
15344 case eCsrSmeIssuedDisassocForHandoff:
15345 case eCsrForcedDeauth:
15346 case eCsrHddIssuedReassocToSameAP:
15347 case eCsrSmeIssuedReassocToSameAP:
15348 fNeedFullPower = eANI_BOOLEAN_TRUE;
15349 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015350 case eCsrCapsChange:
15351 fNeedFullPower = eANI_BOOLEAN_TRUE;
15352 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015353 default:
15354 //Check whether the profile is already connected. If so, no need for full power
15355 //Note: IBSS is ignored for now because we don't support powersave in IBSS
15356 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
15357 {
15358 //Only need to check the first one
15359 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
15360 if( pEntry )
15361 {
15362 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
15363#if 0
15364 // TODO : Session Specific info pConnectBssDesc
15365 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
15366 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
15367 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
15368 {
15369 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
15370 // with Authenticating first. To force this, stop the current association (Disassociate) and
15371 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
15372 // a new Association.
15373 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
15374 {
15375 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
15376 {
15377 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
15378 //No need for full power
15379 //Set the flag so the code later can avoid to do the above
15380 //check again.
15381 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
15382 break;
15383 }
15384 }
15385 }
15386#endif
15387 }
15388 }
15389 //If we are here, full power is needed
15390 fNeedFullPower = eANI_BOOLEAN_TRUE;
15391 break;
15392 }
15393 }
15394 else if( eSmeCommandWmStatusChange == pCommand->command )
15395 {
15396 //need full power for all
15397 fNeedFullPower = eANI_BOOLEAN_TRUE;
15398 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
15399 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015400#ifdef FEATURE_WLAN_TDLS
15401 else if( eSmeCommandTdlsAddPeer == pCommand->command )
15402 {
15403 //TDLS link is getting established. need full power
15404 fNeedFullPower = eANI_BOOLEAN_TRUE;
15405 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
15406 }
15407#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015408 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015409 case REQUEST_STOP_UAPSD:
15410 case REQUEST_EXIT_WOWL:
15411 if( eSmeCommandRoam == pCommand->command )
15412 {
15413 fNeedFullPower = eANI_BOOLEAN_TRUE;
15414 switch ( pCommand->u.roamCmd.roamReason )
15415 {
15416 case eCsrForcedDisassoc:
15417 case eCsrForcedDisassocMICFailure:
15418 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15419 break;
15420 default:
15421 break;
15422 }
15423 }
15424 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015425 case STOPPED:
15426 case REQUEST_STANDBY:
15427 case STANDBY:
15428 case LOW_POWER:
15429 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015430 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070015431 status = eHAL_STATUS_FAILURE;
15432 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015433 case FULL_POWER:
15434 case REQUEST_FULL_POWER:
15435 default:
15436 //No need to ask for full power. This has to be FULL_POWER state
15437 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015438 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070015439 if( pReason )
15440 {
15441 *pReason = reason;
15442 }
15443 if( pfNeedPower )
15444 {
15445 *pfNeedPower = fNeedFullPower;
15446 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015447 return ( status );
15448}
15449
Jeff Johnson295189b2012-06-20 16:38:30 -070015450static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15451{
15452 eHalStatus status = eHAL_STATUS_SUCCESS;
15453 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15454 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070015455 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070015456 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
15457 {
15458 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
15459 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015460 return ( status );
15461}
15462
Jeff Johnson295189b2012-06-20 16:38:30 -070015463tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
15464{
15465 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015466 if( pCmd )
15467 {
15468 pMac->roam.sPendingCommands++;
15469 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015470 return ( pCmd );
15471}
15472
Jeff Johnson295189b2012-06-20 16:38:30 -070015473void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
15474{
15475 if (pMac->roam.sPendingCommands > 0)
15476 {
15477 //All command allocated through csrGetCommandBuffer need to
15478 //decrement the pending count when releasing.
15479 pMac->roam.sPendingCommands--;
15480 smeReleaseCommand( pMac, pCommand );
15481 }
15482 else
15483 {
15484 smsLog(pMac, LOGE, FL( "no pending commands"));
15485 VOS_ASSERT(0);
15486 }
15487}
15488
Jeff Johnson295189b2012-06-20 16:38:30 -070015489//Return SUCCESS is the command is queued, failed
15490eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
15491{
15492 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015493 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
15494 {
15495 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
15496 pCommand->u.scanCmd.reason);
15497 return eHAL_STATUS_CSR_WRONG_STATE;
15498 }
15499
15500 //We can call request full power first before putting the command into pending Q
15501 //because we are holding SME lock at this point.
15502 status = csrRequestFullPower( pMac, pCommand );
15503 if( HAL_STATUS_SUCCESS( status ) )
15504 {
15505 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070015506 //make sure roamCmdPendingList is not empty first
15507 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
15508 if( fNoCmdPending )
15509 {
15510 smePushCommand( pMac, pCommand, fHighPriority );
15511 }
15512 else
15513 {
15514 //Other commands are waiting for PMC callback, queue the new command to the pending Q
15515 //no list lock is needed since SME lock is held
15516 if( !fHighPriority )
15517 {
15518 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15519 }
15520 else {
15521 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15522 }
15523 }
15524 }
15525 else if( eHAL_STATUS_PMC_PENDING == status )
15526 {
15527 //no list lock is needed since SME lock is held
15528 if( !fHighPriority )
15529 {
15530 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15531 }
15532 else {
15533 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15534 }
15535 //Let caller know the command is queue
15536 status = eHAL_STATUS_SUCCESS;
15537 }
15538 else
15539 {
15540 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
15541 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015542 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070015543 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015544 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015545}
Jeff Johnson295189b2012-06-20 16:38:30 -070015546eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
15547{
15548 eHalStatus status = eHAL_STATUS_SUCCESS;
15549 tSirUpdateAPWPSIEsReq *pMsg;
15550 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
15551
15552 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15553 if (NULL == pSession)
15554 {
15555 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15556 return eHAL_STATUS_FAILURE;
15557 }
15558
Jeff Johnson295189b2012-06-20 16:38:30 -070015559 do
15560 {
15561 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15562 if (!HAL_STATUS_SUCCESS(status)) break;
15563 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15564 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
15565
15566 pBuf = (tANI_U8 *)&pMsg->transactionId;
15567 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015568 // transactionId
15569 *pBuf = 0;
15570 *( pBuf + 1 ) = 0;
15571 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015572 // bssId
15573 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15574 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015575 //sessionId
15576 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015577 // APWPSIEs
15578 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
15579 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070015580 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015581 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015582 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015583 return ( status );
15584}
Jeff Johnson295189b2012-06-20 16:38:30 -070015585eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
15586{
15587 eHalStatus status = eHAL_STATUS_SUCCESS;
15588 tSirUpdateAPWPARSNIEsReq *pMsg;
15589 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015590 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15591 if (NULL == pSession)
15592 {
15593 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15594 return eHAL_STATUS_FAILURE;
15595 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015596 do
15597 {
15598 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
15599 if (!HAL_STATUS_SUCCESS(status)) break;
15600 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
15601 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015602 pBuf = (tANI_U8 *)&pMsg->transactionId;
15603 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015604 // transactionId
15605 *pBuf = 0;
15606 *( pBuf + 1 ) = 0;
15607 pBuf += sizeof(tANI_U16);
15608
15609 // bssId
15610 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15611 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015612 // sessionId
15613 *pBuf++ = (tANI_U8)sessionId;
15614
15615 // APWPARSNIEs
15616 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
15617 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015618 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015619 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015620 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015621 return ( status );
15622}
Jeff Johnson295189b2012-06-20 16:38:30 -070015623
15624#ifdef WLAN_FEATURE_VOWIFI_11R
15625//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
15626eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
15627{
15628 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15629 tpSirFTPreAuthReq pftPreAuthReq;
15630 tANI_U16 auth_req_len = 0;
15631 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015632 auth_req_len = sizeof(tSirFTPreAuthReq);
15633 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
15634 if (pftPreAuthReq == NULL)
15635 {
15636 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
15637 return eHAL_STATUS_RESOURCES;
15638 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015639 // Save the SME Session ID here. We need it while processing the preauth response
15640 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015641 vos_mem_zero(pftPreAuthReq, auth_req_len);
15642
15643 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
15644 sizeof(pBssDescription->length) + pBssDescription->length);
15645
15646 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
15647
15648 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
15649
Jeff Johnson295189b2012-06-20 16:38:30 -070015650 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015651 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
15652
Jeff Johnson295189b2012-06-20 16:38:30 -070015653#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080015654 if (csrRoamIs11rAssoc(pMac) &&
15655 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070015656 {
15657 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15658 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15659 pMac->ft.ftSmeContext.auth_ft_ies_length);
15660 }
15661 else
15662#endif
15663 {
15664 pftPreAuthReq->ft_ies_length = 0;
15665 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070015666 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
15667 sizeof(pBssDescription->length) + pBssDescription->length);
15668 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015669 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15670}
Jeff Johnson295189b2012-06-20 16:38:30 -070015671/*--------------------------------------------------------------------------
15672 * This will receive and process the FT Pre Auth Rsp from the current
15673 * associated ap.
15674 *
15675 * This will invoke the hdd call back. This is so that hdd can now
15676 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15677 ------------------------------------------------------------------------*/
15678void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15679{
15680 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15681 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015682#ifdef FEATURE_WLAN_LFR
15683 tCsrRoamInfo roamInfo;
15684#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015685
15686#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015687 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015688#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015689#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015690 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015691 if (status != eHAL_STATUS_SUCCESS) {
15692 /*
15693 * Bail out if pre-auth was not even processed.
15694 */
15695 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15696 return;
15697 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015698#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015699 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15700 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15701 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015702 // Implies a success
15703 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015704 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15705 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
15706 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070015707 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15708 * actual transition from the current to handoff AP is triggered */
15709 status = palTimerStart(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15710 60 * PAL_TIMER_TO_MS_UNIT,
15711 eANI_BOOLEAN_FALSE);
15712 if (eHAL_STATUS_SUCCESS != status)
15713 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015714 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015715 return;
15716 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015717 // Save the received response
15718 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15719 if (csrRoamIs11rAssoc(pMac))
15720 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15721 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15722
15723 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015724#ifdef FEATURE_WLAN_LFR
15725 // If Legacy Fast Roaming is enabled, signal the supplicant
15726 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015727 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015728 {
15729 // Save the bssid from the received response
15730 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15731 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15732 }
15733
15734#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015735
15736 // Done with it, init it.
15737 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15738}
15739#endif
15740#ifdef FEATURE_WLAN_BTAMP_UT_RF
15741void csrRoamJoinRetryTimerHandler(void *pv)
15742{
15743 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
15744 tpAniSirGlobal pMac = pInfo->pMac;
15745 tANI_U32 sessionId = pInfo->sessionId;
15746 tCsrRoamSession *pSession;
15747
15748 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15749 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015750 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015751 pSession = CSR_GET_SESSION( pMac, sessionId );
15752 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
15753 {
15754 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
15755 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015756 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015757 }
15758 }
15759 }
15760}
Jeff Johnson295189b2012-06-20 16:38:30 -070015761eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
15762{
15763 eHalStatus status = eHAL_STATUS_FAILURE;
15764 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15765
15766 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
15767 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015768 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070015769 pSession->maxRetryCount--;
15770 pSession->joinRetryTimerInfo.pMac = pMac;
15771 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
15772 status = palTimerStart(pMac->hHdd, pSession->hTimerJoinRetry, interval, eANI_BOOLEAN_FALSE);
15773 if(!HAL_STATUS_SUCCESS(status))
15774 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015775 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015776 }
15777 }
15778 else
15779 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015780 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070015781 pSession->maxRetryCount);
15782 }
15783
15784 return (status);
15785}
Jeff Johnson295189b2012-06-20 16:38:30 -070015786eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
15787{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015788 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070015789 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15790 {
15791 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerJoinRetry));
15792 }
15793
15794 return eHAL_STATUS_SUCCESS;
15795}
15796#endif
15797
15798
15799/*
15800 pBuf points to the beginning of the message
15801 LIM packs disassoc rsp as below,
15802 messageType - 2 bytes
15803 messageLength - 2 bytes
15804 sessionId - 1 byte
15805 transactionId - 2 bytes (tANI_U16)
15806 reasonCode - 4 bytes (sizeof(tSirResultCodes))
15807 peerMacAddr - 6 bytes
15808 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
15809*/
15810static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
15811{
15812 if(pBuf && pRsp)
15813 {
15814 pBuf += 4; //skip type and length
15815 pRsp->sessionId = *pBuf++;
15816 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
15817 pBuf += 2;
15818 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
15819 pBuf += 4;
15820 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
15821 }
15822}
15823
Jeff Johnsond13512a2012-07-17 11:42:19 -070015824eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15825{
15826 static uNvTables nvTables;
15827 eHalStatus status = eHAL_STATUS_SUCCESS;
15828 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
15829
15830 /* read the country code from NV and use it */
15831 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
15832 {
15833 palCopyMemory( pMac->hHdd, pCountry,
15834 nvTables.defaultCountryTable.countryCode,
15835 WNI_CFG_COUNTRY_CODE_LEN );
15836 return status;
15837 }
15838 else
15839 {
15840 palCopyMemory( pMac->hHdd, pCountry,
15841 "XXX",
15842 WNI_CFG_COUNTRY_CODE_LEN );
15843 status = eHAL_STATUS_FAILURE;
15844 return status;
15845 }
15846}
15847
15848eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15849{
15850 palCopyMemory( pMac->hHdd, pCountry,
15851 pMac->scan.countryCode11d,
15852 WNI_CFG_COUNTRY_CODE_LEN );
15853 return eHAL_STATUS_SUCCESS;
15854}
schang86c22c42013-03-13 18:41:24 -070015855
15856eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
15857{
15858 tSirSetTxPowerReq *pMsg = NULL;
15859 eHalStatus status = eHAL_STATUS_SUCCESS;
15860 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15861
15862 if (!pSession)
15863 {
15864 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15865 return eHAL_STATUS_FAILURE;
15866 }
15867
15868 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetTxPowerReq));
15869 if (HAL_STATUS_SUCCESS(status))
15870 {
15871 palZeroMemory(pMac->hHdd, (void *)pMsg, sizeof(tSirSetTxPowerReq));
15872 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
15873 pMsg->length = sizeof(tSirSetTxPowerReq);
15874 pMsg->mwPower = mW;
15875 palCopyMemory( pMac->hHdd,
15876 (tSirMacAddr *)pMsg->bssId,
15877 &pSession->selfMacAddr,
15878 sizeof(tSirMacAddr) );
15879 status = palSendMBMessage(pMac->hHdd, pMsg);
15880 if (!HAL_STATUS_SUCCESS(status))
15881 {
15882 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015883 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070015884 }
15885 }
15886 return status;
15887}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015888
15889/* Returns whether a session is in VOS_STA_MODE...or not */
15890tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
15891{
15892 tCsrRoamSession *pSession = NULL;
15893 pSession = CSR_GET_SESSION ( pMac, sessionId );
15894 if(!pSession)
15895 {
15896 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
15897 return eANI_BOOLEAN_FALSE;
15898 }
15899 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
15900 {
15901 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
15902 return eANI_BOOLEAN_FALSE;
15903 }
15904 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
15905 {
15906 return eANI_BOOLEAN_FALSE;
15907 }
15908 /* There is a possibility that the above check may fail,because
15909 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
15910 * when it is connected.So,we may sneak through the above check even
15911 * if we are not a STA mode INFRA station. So, if we sneak through
15912 * the above condition, we can use the following check if we are
15913 * really in STA Mode.*/
15914
15915 if ( NULL != pSession->pCurRoamProfile )
15916 {
15917 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
15918 {
15919 return eANI_BOOLEAN_TRUE;
15920 } else {
15921 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
15922 return eANI_BOOLEAN_FALSE;
15923 }
15924 }
15925
15926 return eANI_BOOLEAN_FALSE;
15927}