blob: 6582b3529560e32befa9c75696391772b2fc3562 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam0fb93dd2014-02-19 00:32:59 -08002 * Copyright (c) 2012-2014 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
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Kiet Lam0fb93dd2014-02-19 00:32:59 -080026 */
27
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------- *
32 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -070033
Jeff Johnson295189b2012-06-20 16:38:30 -070034
35 \file csrApiRoam.c
36
37 Implementation for the Common Roaming interfaces.
38
Kiet Lamaa8e15a2014-02-11 23:30:06 -080039 Copyright (C) 2008 Qualcomm, Incorporated
40
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070043/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070044 EDIT HISTORY FOR FILE
45
Jeff Johnson295189b2012-06-20 16:38:30 -070046 This section contains comments describing changes made to the module.
47 Notice that changes are listed in reverse chronological order.
48
Jeff Johnson295189b2012-06-20 16:38:30 -070049 when who what, where, why
50---------- --- --------------------------------------------------------
5106/03/10 js Added support to hostapd driven
52 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070053===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070054#include "aniGlobal.h" //for tpAniSirGlobal
55#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070056#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070057#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070058#include "palApi.h"
59#include "csrInsideApi.h"
60#include "smsDebug.h"
61#include "logDump.h"
62#include "smeQosInternal.h"
63#include "wlan_qct_tl.h"
64#include "smeInside.h"
65#include "vos_diag_core_event.h"
66#include "vos_diag_core_log.h"
67#include "csrApi.h"
68#include "pmc.h"
69#include "vos_nvitem.h"
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053070#include "macTrace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070071#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
72#include "csrNeighborRoam.h"
73#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080074#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
75#include "csrEse.h"
76#endif /* FEATURE_WLAN_ESE && !FEATURE_WLAN_ESE_UPLOAD */
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053077#ifdef DEBUG_ROAM_DELAY
78#include "vos_utils.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080#define CSR_NUM_IBSS_START_CHANNELS_50 4
81#define CSR_NUM_IBSS_START_CHANNELS_24 3
82#define CSR_DEF_IBSS_START_CHANNEL_50 36
83#define CSR_DEF_IBSS_START_CHANNEL_24 1
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080084#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 -070085#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
86/*---------------------------------------------------------------------------
87 OBIWAN recommends [8 10]% : pick 9%
88---------------------------------------------------------------------------*/
89#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070090/*---------------------------------------------------------------------------
91 OBIWAN recommends -85dBm
92---------------------------------------------------------------------------*/
93#define CSR_VCC_RSSI_THRESHOLD 80
94#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
95#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
96#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
97#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -070098//We use constatnt 4 here
99//This macro returns true when higher AC parameter is bigger than lower AC for a difference
100//The bigger the number, the less chance of TX
101//It must put lower AC as the first parameter.
102#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700103//Flag to send/do not send disassoc frame over the air
104#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700106#define MAX_CB_VALUE_IN_INI (2)
107
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700108#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
109static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
110#endif
111
Jeff Johnson295189b2012-06-20 16:38:30 -0700112/*--------------------------------------------------------------------------
113 Static Type declarations
114 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800115static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800116
Jeff Johnson295189b2012-06-20 16:38:30 -0700117/*--------------------------------------------------------------------------
118 Type declarations
119 ------------------------------------------------------------------------*/
120#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700121int diagAuthTypeFromCSRType(eCsrAuthType authType)
122{
123 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700124 switch(authType)
125 {
126 case eCSR_AUTH_TYPE_SHARED_KEY:
127 n = AUTH_SHARED;
128 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700129 case eCSR_AUTH_TYPE_WPA:
130 n = AUTH_WPA_EAP;
131 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700132 case eCSR_AUTH_TYPE_WPA_PSK:
133 n = AUTH_WPA_PSK;
134 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 case eCSR_AUTH_TYPE_RSN:
136 n = AUTH_WPA2_EAP;
137 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700138 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700139#ifdef WLAN_FEATURE_11W
140 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
141#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700142 n = AUTH_WPA2_PSK;
143 break;
144#ifdef FEATURE_WLAN_WAPI
145 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
146 n = AUTH_WAPI_CERT;
147 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700148 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
149 n = AUTH_WAPI_PSK;
150 break;
151#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700152 default:
153 break;
154 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 return (n);
156}
Jeff Johnson295189b2012-06-20 16:38:30 -0700157int diagEncTypeFromCSRType(eCsrEncryptionType encType)
158{
159 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700160 switch(encType)
161 {
162 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
163 case eCSR_ENCRYPT_TYPE_WEP40:
164 n = ENC_MODE_WEP40;
165 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
167 case eCSR_ENCRYPT_TYPE_WEP104:
168 n = ENC_MODE_WEP104;
169 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700170 case eCSR_ENCRYPT_TYPE_TKIP:
171 n = ENC_MODE_TKIP;
172 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700173 case eCSR_ENCRYPT_TYPE_AES:
174 n = ENC_MODE_AES;
175 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700176#ifdef FEATURE_WLAN_WAPI
177 case eCSR_ENCRYPT_TYPE_WPI:
178 n = ENC_MODE_SMS4;
179 break;
180#endif /* FEATURE_WLAN_WAPI */
181 default:
182 break;
183 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700184 return (n);
185}
Jeff Johnson295189b2012-06-20 16:38:30 -0700186#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700187static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
188static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700189static void initConfigParam(tpAniSirGlobal pMac);
190static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
191 eCsrRoamCompleteResult Result, void *Context );
192static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
193 tCsrRoamProfile *pProfile,
194 tANI_BOOLEAN *pfSameIbss );
195static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
196static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700197 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
198static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700199eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
200static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
201eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
202eHalStatus csrRoamClose(tpAniSirGlobal pMac);
203void csrRoamMICErrorTimerHandler(void *pv);
204void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
205tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
206
207static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
208static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
209static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700210eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
211eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
212static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700213static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700214static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700215static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
216eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
217 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
218 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
219 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
220 tANI_U8 *pKeyRsc );
221static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
222 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
223 tCsrRoamProfile *pProfile );
224void csrRoamStatisticsTimerHandler(void *pv);
225void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700226static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
227VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
228 v_U8_t rssiNotification,
229 void * context);
230static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
231void csrRoamVccTrigger(tpAniSirGlobal pMac);
232eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
233/*
234 pStaEntry is no longer invalid upon the return of this function.
235*/
236static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700237static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700238static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700239tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
240 tDblLinkList *pStaList,
241 tCsrStatsClientReqInfo *pStaEntry);
242void csrRoamStatsClientTimerHandler(void *pv);
243tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
244 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
245void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
246 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700247void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700248void csrRoamTlStatsTimerHandler(void *pv);
249void csrRoamPeStatsTimerHandler(void *pv);
250tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
251void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
252tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
253eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
254static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
255static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
256static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
257static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
258 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
259//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
260static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
261void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
262#ifdef FEATURE_WLAN_BTAMP_UT_RF
263void csrRoamJoinRetryTimerHandler(void *pv);
264#endif
Atul Mittalb849d5a2014-07-29 12:08:39 +0530265void limInitOperatingClasses( tHalHandle hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -0700266extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700267extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700268static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700269void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700270
271//Initialize global variables
272static void csrRoamInitGlobals(tpAniSirGlobal pMac)
273{
274 if(pMac)
275 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800276 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
277 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 }
279 return;
280}
281
Jeff Johnson295189b2012-06-20 16:38:30 -0700282static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
283{
284 if(pMac)
285 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800286 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 }
288 return;
289}
Jeff Johnson295189b2012-06-20 16:38:30 -0700290eHalStatus csrOpen(tpAniSirGlobal pMac)
291{
292 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530293#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700294 static uNvTables nvTables;
295 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700296 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530297#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700298 tANI_U32 i;
299
300 do
301 {
302 /* Initialize CSR Roam Globals */
303 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
305 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
306
307 initConfigParam(pMac);
308 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
309 break;
310 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
311 break;
312 pMac->roam.nextRoamId = 1; //Must not be 0
313 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
314 break;
315 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
316 break;
317 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
318 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530319
320#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700321 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
322 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
323 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530324 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
325 WNI_CFG_COUNTRY_CODE_LEN);
326 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 }
328 else
329 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800330 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 //hardcoded for now
332 pMac->scan.countryCodeDefault[0] = 'U';
333 pMac->scan.countryCodeDefault[1] = 'S';
334 pMac->scan.countryCodeDefault[2] = 'I';
335 //status = eHAL_STATUS_SUCCESS;
336 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700337 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530338
339 if (!('0' == pMac->scan.countryCodeDefault[0] &&
340 '0' == pMac->scan.countryCodeDefault[1]))
341 {
342 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
343 &regId, COUNTRY_NV);
344 }
345 else
346 {
347 regId = REGDOMAIN_WORLD;
348 }
Abhishek Singha306a442013-11-07 18:39:01 +0530349 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 pMac->scan.domainIdDefault = regId;
351 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530352 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
353 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700354 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530355#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700356 }while(0);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530357
Jeff Johnson295189b2012-06-20 16:38:30 -0700358 return (status);
359}
360
Mihir Shetee1093ba2014-01-21 20:13:32 +0530361/* --------------------------------------------------------------------------
362 \fn csrInitChannels
363 \brief This function must be called to initialize CSR channel lists
364 \return eHalStatus
365 ----------------------------------------------------------------------------*/
366eHalStatus csrInitChannels(tpAniSirGlobal pMac)
367{
368 eHalStatus status = eHAL_STATUS_SUCCESS;
369 static uNvTables nvTables;
370 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530371 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530372
373 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
374 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
375 {
376 vos_mem_copy(pMac->scan.countryCodeDefault,
377 nvTables.defaultCountryTable.countryCode,
378 WNI_CFG_COUNTRY_CODE_LEN);
379 }
380 else
381 {
382 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
383 //hardcoded for now
384 pMac->scan.countryCodeDefault[0] = 'U';
385 pMac->scan.countryCodeDefault[1] = 'S';
386 pMac->scan.countryCodeDefault[2] = 'I';
387 }
388 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
389
Mihir Shetee1093ba2014-01-21 20:13:32 +0530390 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
391 pMac->scan.domainIdDefault = regId;
392 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
393 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
394 WNI_CFG_COUNTRY_CODE_LEN);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530395 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
396 WNI_CFG_COUNTRY_CODE_LEN);
Agarwal Ashishcd9b8e62014-07-21 19:48:24 +0530397 vos_mem_copy(pMac->scan.countryCode11d, pMac->scan.countryCodeDefault,
398 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530399 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530400 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530401
402 return status;
403}
404
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530405eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac)
406{
407 eHalStatus status = eHAL_STATUS_SUCCESS;
408 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
409
410 if (!('0' == pMac->scan.countryCodeDefault[0] &&
411 '0' == pMac->scan.countryCodeDefault[1]))
412 {
413 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
414 &regId, COUNTRY_NV);
415
416 }
417 else
418 {
419 return status;
420 }
421 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
422 pMac->scan.domainIdDefault = regId;
423 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
424 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
425 WNI_CFG_COUNTRY_CODE_LEN);
426 status = csrInitGetChannels( pMac );
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530427
428 /* reset info based on new cc, and we are done */
429 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
430 csrScanFilterResults(pMac);
431
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530432 return status;
433}
434
Jeff Johnson295189b2012-06-20 16:38:30 -0700435eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
436{
437 eHalStatus status = eHAL_STATUS_SUCCESS;
438 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
439 v_REGDOMAIN_t regId;
440 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700441 if(NULL == apCntryCode)
442 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530443 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700444 return eHAL_STATUS_FAILURE;
445 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530446 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 /* To get correct Regulatory domain from NV table
448 * 2 character Country code should be used
449 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700450 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
451/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700452 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700453
454 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
455 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800456 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700457 return eHAL_STATUS_FAILURE;
458 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700459*/
Kiet Lam6c583332013-10-14 05:37:09 +0530460 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
461 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 if (status != eHAL_STATUS_SUCCESS)
463 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700464 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700465 return status;
466 }
Abhishek Singha306a442013-11-07 18:39:01 +0530467 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 if (status != eHAL_STATUS_SUCCESS)
469 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700470 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 return status;
472 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 pMac->scan.domainIdDefault = regId;
474 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700475 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530476 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
477
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530479 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
480
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 /* If 2 bytes country code, 3rd byte must be filled with space */
482 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
483 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530484 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530486 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
487 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 return status;
490}
Jeff Johnson295189b2012-06-20 16:38:30 -0700491eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
492{
493 eHalStatus status = eHAL_STATUS_SUCCESS;
494 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
495 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530496 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
497 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
499 {
500 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
501 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
502 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
503 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
504 }
505 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
506
507 return status;
508}
Jeff Johnson295189b2012-06-20 16:38:30 -0700509eHalStatus csrClose(tpAniSirGlobal pMac)
510{
511 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800512
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 csrRoamClose(pMac);
514 csrScanClose(pMac);
515 csrLLClose(&pMac->roam.statsClientReqList);
516 csrLLClose(&pMac->roam.peStatsReqList);
517 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 /* DeInit Globals */
519 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700520 return (status);
521}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530522
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800523eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530524{
525 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800526 tCsrScanStruct *pScan = &pMac->scan;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530527 tANI_U8 numChan = pScan->base20MHzChannels.numChannels;
528 tANI_U32 bufLen = sizeof(tSirUpdateChanList) +
529 (sizeof(tSirUpdateChanParam) * (numChan - 1));
530 vos_msg_t msg;
531 tANI_U8 i;
532
Atul Mittalb849d5a2014-07-29 12:08:39 +0530533 limInitOperatingClasses((tHalHandle)pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530534 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
535 if (!pChanList)
536 {
537 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
538 "Failed to allocate memory for tSirUpdateChanList");
539 return eHAL_STATUS_FAILED_ALLOC;
540 }
541
542 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
543 msg.reserved = 0;
544 msg.bodyptr = pChanList;
545 pChanList->numChan = numChan;
546 for (i = 0; i < pChanList->numChan; i++)
547 {
548 pChanList->chanParam[i].chanId = pScan->defaultPowerTable[i].chanId;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800549 pChanList->chanParam[i].pwr = cfgGetRegulatoryMaxTransmitPower(pMac,
550 pScan->defaultPowerTable[i].chanId);
551 if (vos_nv_getChannelEnabledState(pChanList->chanParam[i].chanId) ==
552 NV_CHANNEL_DFS)
553 pChanList->chanParam[i].dfsSet = VOS_TRUE;
554 else
555 pChanList->chanParam[i].dfsSet = VOS_FALSE;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530556 }
557
558 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
559 {
560 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
561 "%s: Failed to post msg to WDA", __func__);
562 vos_mem_free(pChanList);
563 return eHAL_STATUS_FAILURE;
564 }
565
566 return eHAL_STATUS_SUCCESS;
567}
568
Jeff Johnson295189b2012-06-20 16:38:30 -0700569eHalStatus csrStart(tpAniSirGlobal pMac)
570{
571 eHalStatus status = eHAL_STATUS_SUCCESS;
572 tANI_U32 i;
573
574 do
575 {
576 //save the global vos context
577 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
578 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
579 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
580
581 status = csrRoamStart(pMac);
582 if(!HAL_STATUS_SUCCESS(status)) break;
583 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
584 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
585 if(!HAL_STATUS_SUCCESS(status)) break;
586 pMac->roam.sPendingCommands = 0;
587 csrScanEnable(pMac);
588#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
589 status = csrNeighborRoamInit(pMac);
590#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
591 pMac->roam.tlStatsReqInfo.numClient = 0;
592 pMac->roam.tlStatsReqInfo.periodicity = 0;
593 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
594 //init the link quality indication also
595 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
596 if(!HAL_STATUS_SUCCESS(status))
597 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800598 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 break;
600 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530601
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700603#if defined(ANI_LOGDUMP)
604 csrDumpInit(pMac);
605#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700606 return (status);
607}
608
Kiet Lama72a2322013-11-15 11:18:11 +0530609eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700610{
611 tANI_U32 sessionId;
612 tANI_U32 i;
613
614 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 csrScanDisable(pMac);
619 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
620 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700621 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
622
623#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
624 csrNeighborRoamClose(pMac);
625#endif
626 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 // deregister from PMC since we register during csrStart()
628 // (ignore status since there is nothing we can do if it fails)
629 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 //Reset the domain back to the deault
631 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800632 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700633
634 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
635 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530636 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
638 }
639
Kiet Lama72a2322013-11-15 11:18:11 +0530640#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
641 /* When HAL resets all the context information
642 * in HAL is lost, so we might need to send the
643 * scan offload request again when it comes
644 * out of reset for scan offload to be functional
645 */
646 if (HAL_STOP_TYPE_SYS_RESET == stopType)
647 {
648 bRoamScanOffloadStarted = VOS_FALSE;
649 }
650#endif
651
Jeff Johnson295189b2012-06-20 16:38:30 -0700652 return (eHAL_STATUS_SUCCESS);
653}
654
Jeff Johnson295189b2012-06-20 16:38:30 -0700655eHalStatus csrReady(tpAniSirGlobal pMac)
656{
657 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 csrScanGetSupportedChannels( pMac );
659 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
660 //use it to init the background scan list
661 csrInitBGScanChannelList(pMac);
662 /* HDD issues the init scan */
663 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800664 /* If the gScanAgingTime is set to '0' then scan results aging timeout
665 based on timer feature is not enabled*/
666 if(0 != pMac->scan.scanResultCfgAgingTime )
667 {
668 csrScanStartResultCfgAgingTimer(pMac);
669 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700670 //Store the AC weights in TL for later use
671 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700672 status = csrInitChannelList( pMac );
673 if ( ! HAL_STATUS_SUCCESS( status ) )
674 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800675 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700676 status );
677 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700678 return (status);
679}
Jeff Johnson295189b2012-06-20 16:38:30 -0700680void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
681{
682 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
684 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
685}
Jeff Johnson295189b2012-06-20 16:38:30 -0700686void csrSetGlobalCfgs( tpAniSirGlobal pMac )
687{
Jeff Johnsone7245742012-09-05 17:12:55 -0700688
Jeff Johnson295189b2012-06-20 16:38:30 -0700689 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
690 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
691 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
692 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
693 NULL, eANI_BOOLEAN_FALSE);
694 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700695 /* 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
696 * Once session is established we will use the session related params stored in PE session for CB mode
697 */
698 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
700
701 //Update the operating mode to configured value during initialization,
702 //So that client can advertise full capabilities in Probe request frame.
703 csrSetDefaultDot11Mode( pMac );
704}
705
Jeff Johnson295189b2012-06-20 16:38:30 -0700706eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
707{
708 eHalStatus status = eHAL_STATUS_SUCCESS;
709 tANI_U32 i;
710 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 do
712 {
713 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
714 {
715 pSession = CSR_GET_SESSION( pMac, i );
716 pSession->roamingTimerInfo.pMac = pMac;
717 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
718 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
720 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530721 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
722 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530724 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700725 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800726 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 break;
728 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530729 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
730 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
731 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800733 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 return eHAL_STATUS_FAILURE;
735 }
736 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 return (status);
738}
739
Jeff Johnson295189b2012-06-20 16:38:30 -0700740eHalStatus csrRoamClose(tpAniSirGlobal pMac)
741{
742 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700743 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
744 {
745 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
746 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530747 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
748 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
749 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
750 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 return (eHAL_STATUS_SUCCESS);
752}
753
Jeff Johnson295189b2012-06-20 16:38:30 -0700754eHalStatus csrRoamStart(tpAniSirGlobal pMac)
755{
756 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 return (eHAL_STATUS_SUCCESS);
758}
759
Jeff Johnson295189b2012-06-20 16:38:30 -0700760void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
761{
762 csrRoamStopRoamingTimer(pMac, sessionId);
763 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
764 csrRoamDeregStatisticsReq(pMac);
765}
Jeff Johnson295189b2012-06-20 16:38:30 -0700766eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
767{
768 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800769 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 {
771 status = eHAL_STATUS_SUCCESS;
772 *pState = pMac->roam.roamSession[sessionId].connectState;
773 }
774 return (status);
775}
776
Jeff Johnson295189b2012-06-20 16:38:30 -0700777eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
778{
779 eHalStatus status = eHAL_STATUS_FAILURE;
780 tANI_U32 size = 0;
781 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700782
783 if(!pSession)
784 {
785 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
786 return eHAL_STATUS_FAILURE;
787 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700788
789 if(pProfile)
790 {
791 if(pSession->pConnectBssDesc)
792 {
793 do
794 {
795 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
796 if(size)
797 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530798 pProfile->pBssDesc = vos_mem_malloc(size);
799 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700800 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530801 vos_mem_copy(pProfile->pBssDesc,
802 pSession->pConnectBssDesc, size);
803 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700804 }
805 else
806 break;
807 }
808 else
809 {
810 pProfile->pBssDesc = NULL;
811 }
812 pProfile->AuthType = pSession->connectedProfile.AuthType;
813 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
814 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
815 pProfile->BSSType = pSession->connectedProfile.BSSType;
816 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
817 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530818 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
819 sizeof(tCsrBssid));
820 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
821 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700822#ifdef WLAN_FEATURE_VOWIFI_11R
823 if (pSession->connectedProfile.MDID.mdiePresent)
824 {
825 pProfile->MDID.mdiePresent = 1;
826 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
827 }
828 else
829 {
830 pProfile->MDID.mdiePresent = 0;
831 pProfile->MDID.mobilityDomain = 0;
832 }
833#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800834#ifdef FEATURE_WLAN_ESE
835 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
836 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800838 vos_mem_copy (pProfile->eseCckmInfo.krk,
839 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530840 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800841 pProfile->eseCckmInfo.reassoc_req_num=
842 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
843 pProfile->eseCckmInfo.krk_plumbed =
844 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 }
846#endif
847 }while(0);
848 }
849 }
850
851 return (status);
852}
853
Jeff Johnson295189b2012-06-20 16:38:30 -0700854eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
855{
856 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700857
858 if((csrIsConnStateConnected(pMac, sessionId)) ||
859 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 {
861 if(pProfile)
862 {
863 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
864 }
865 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 return (status);
867}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700868
Jeff Johnson295189b2012-06-20 16:38:30 -0700869eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
870{
871 eHalStatus status = eHAL_STATUS_SUCCESS;
872
Kiet Lam64c1b492013-07-12 13:56:44 +0530873 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530875 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530877 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700878 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530879 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700880 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530881 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
882
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
884 return (status);
885}
886
Jeff Johnson295189b2012-06-20 16:38:30 -0700887static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
888{
889 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 if( pConnectedInfo->pbFrames )
891 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530892 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 pConnectedInfo->pbFrames = NULL;
894 }
895 pConnectedInfo->nBeaconLength = 0;
896 pConnectedInfo->nAssocReqLength = 0;
897 pConnectedInfo->nAssocRspLength = 0;
898 pConnectedInfo->staId = 0;
899#ifdef WLAN_FEATURE_VOWIFI_11R
900 pConnectedInfo->nRICRspLength = 0;
901#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800902#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700903 pConnectedInfo->nTspecIeLength = 0;
904#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 return ( status );
906}
907
Jeff Johnson295189b2012-06-20 16:38:30 -0700908
909
Jeff Johnsone7245742012-09-05 17:12:55 -0700910
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700911void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
912{
913 csrReinitPreauthCmd(pMac, pCommand);
914 csrReleaseCommand( pMac, pCommand );
915}
916
Jeff Johnson295189b2012-06-20 16:38:30 -0700917void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
918{
919 csrReinitRoamCmd(pMac, pCommand);
920 csrReleaseCommand( pMac, pCommand );
921}
922
Jeff Johnson295189b2012-06-20 16:38:30 -0700923void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
924{
925 csrReinitScanCmd(pMac, pCommand);
926 csrReleaseCommand( pMac, pCommand );
927}
928
Jeff Johnson295189b2012-06-20 16:38:30 -0700929void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
930{
931 csrReinitWmStatusChangeCmd(pMac, pCommand);
932 csrReleaseCommand( pMac, pCommand );
933}
934
Jeff Johnson295189b2012-06-20 16:38:30 -0700935void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
936{
Kiet Lam64c1b492013-07-12 13:56:44 +0530937 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700938}
939
Jeff Johnson295189b2012-06-20 16:38:30 -0700940void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
941{
Kiet Lam64c1b492013-07-12 13:56:44 +0530942 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700943}
944
Jeff Johnson295189b2012-06-20 16:38:30 -0700945void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
946{
947 csrReinitSetKeyCmd(pMac, pCommand);
948 csrReleaseCommand( pMac, pCommand );
949}
Jeff Johnson295189b2012-06-20 16:38:30 -0700950void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
951{
952 csrReinitRemoveKeyCmd(pMac, pCommand);
953 csrReleaseCommand( pMac, pCommand );
954}
Jeff Johnson295189b2012-06-20 16:38:30 -0700955void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
956{
957
958 if( eSmeCsrCommandMask & pCommand->command )
959 {
960 switch (pCommand->command)
961 {
962 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800963 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -0800964 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
965 __func__, pCommand->u.scanCmd.reason,
966 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 if (NULL != pCommand->u.scanCmd.callback)
968 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800969 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
971 }
972 csrReleaseCommandScan( pMac, pCommand );
973 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 case eSmeCommandRoam:
975 csrReleaseCommandRoam( pMac, pCommand );
976 break;
977
978 case eSmeCommandWmStatusChange:
979 csrReleaseCommandWmStatusChange( pMac, pCommand );
980 break;
981
982 case eSmeCommandSetKey:
983 csrReleaseCommandSetKey( pMac, pCommand );
984 break;
985
986 case eSmeCommandRemoveKey:
987 csrReleaseCommandRemoveKey( pMac, pCommand );
988 break;
989
990 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800991 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 csrReleaseCommand( pMac, pCommand );
993 break;
994 }
995 }
996}
997
Jeff Johnson295189b2012-06-20 16:38:30 -0700998void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
999{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301000 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1001 macTraceGetcsrRoamSubState(NewSubstate),
1002 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001003
Jeff Johnson295189b2012-06-20 16:38:30 -07001004 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1005 {
1006 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001007 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 pMac->roam.curSubState[sessionId] = NewSubstate;
1009}
1010
Jeff Johnson295189b2012-06-20 16:38:30 -07001011eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1012{
1013 eCsrRoamState PreviousState;
1014
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301015 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1016 macTraceGetcsrRoamState(NewRoamState),
1017 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001018
1019 PreviousState = pMac->roam.curState[sessionId];
1020
1021 if ( NewRoamState != pMac->roam.curState[sessionId] )
1022 {
1023 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1024 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1025 {
1026 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1027 }
1028
1029 pMac->roam.curState[sessionId] = NewRoamState;
1030 }
1031 return( PreviousState );
1032}
1033
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001034void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001035{
1036 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 if(catOffset)
1038 {
1039 pMac->roam.configParam.bCatRssiOffset = catOffset;
1040 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1041 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001042 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)bestApRssi - pMac->roam.configParam.nSelect5GHzMargin - (int)(i * catOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 }
1044 }
1045}
1046
Jeff Johnson295189b2012-06-20 16:38:30 -07001047static void initConfigParam(tpAniSirGlobal pMac)
1048{
1049 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001050 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301051 pMac->roam.configParam.channelBondingMode24GHz =
1052 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1053 pMac->roam.configParam.channelBondingMode5GHz =
1054 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001055 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1056 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1057 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1058 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1059 pMac->roam.configParam.HeartbeatThresh24 = 40;
1060 pMac->roam.configParam.HeartbeatThresh50 = 40;
1061 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1062 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1063 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001064 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 pMac->roam.configParam.RTSThreshold = 2346;
1066 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1067 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1068 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1069 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1070 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1071 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1072 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1073 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1074 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1075 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1076 {
1077 pMac->roam.configParam.BssPreferValue[i] = i;
1078 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001079 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1081 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1082 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001083 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1084 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05301085 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001086 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1087 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1088 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1089 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001090 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1091 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001092 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001093#ifdef WLAN_AP_STA_CONCURRENCY
1094 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1095 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1096 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1097 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1098 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001099 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1100 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001101#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001102 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1103 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1104 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1105 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001106#ifdef WLAN_FEATURE_VOWIFI_11R
1107 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1108#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001109#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1110 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1111 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1112 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1113 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1114 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1115 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1116 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1117 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1118 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1119 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1120 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001121 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05301122 pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001123#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001124#ifdef WLAN_FEATURE_11AC
1125 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1126#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001127
1128 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1129 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001130
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001131 //Remove this code once SLM_Sessionization is supported
1132 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001133 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001134
Jeff Johnsone7245742012-09-05 17:12:55 -07001135}
Jeff Johnson295189b2012-06-20 16:38:30 -07001136eCsrBand csrGetCurrentBand(tHalHandle hHal)
1137{
1138 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1139 return pMac->roam.configParam.bandCapability;
1140}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001141
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001142
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001143#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001144/*
1145 This function flushes the roam scan cache
1146*/
1147eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1148{
1149 eHalStatus status = eHAL_STATUS_SUCCESS;
1150 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1151
1152 /* Free up the memory first (if required) */
1153 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1154 {
1155 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1156 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1157 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1158 }
1159 return status;
1160}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001161#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001162
1163
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001164#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001165/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001166 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001167*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001168eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001169{
1170 eHalStatus status = eHAL_STATUS_SUCCESS;
1171 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1172
1173 /* Free up the memory first (if required) */
1174 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1175 {
1176 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1177 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001178 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001179 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001180 return status;
1181}
1182
1183
1184
1185/*
1186 This function flushes the roam scan cache and creates fresh cache
1187 based on the input channel list
1188*/
1189eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1190 const tANI_U8 *pChannelList,
1191 const tANI_U8 numChannels)
1192{
1193 eHalStatus status = eHAL_STATUS_SUCCESS;
1194 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1195
Srinivas Girigowdade697412013-02-14 16:31:48 -08001196 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1197
1198 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1199 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1200
1201 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1202 {
1203 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1204 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1205 return eHAL_STATUS_RESOURCES;
1206 }
1207
1208 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301209 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1210 pChannelList,
1211 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001212 return status;
1213}
1214
1215/* This function modifies the bgscan channel list set via config ini or
1216 runtime, whenever the band changes.
1217 if the band is auto, then no operation is performed on the channel list
1218 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1219 if the band is 5G, then make sure channel list contains only 5G valid channels
1220*/
1221eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1222 eCsrBand eBand)
1223{
1224 eHalStatus status = eHAL_STATUS_SUCCESS;
1225 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1226 tANI_U8 outNumChannels = 0;
1227 tANI_U8 inNumChannels = 0;
1228 tANI_U8 *inPtr = NULL;
1229 tANI_U8 i = 0;
1230 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1231
1232 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1233
1234 {
1235 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1236 "No update required for channel list "
1237 "either cfg.ini channel list is not set up or "
1238 "auto band (Band %d)", eBand);
1239 return status;
1240 }
1241
1242 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1243 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1244 if (eCSR_BAND_24 == eBand)
1245 {
1246 for (i = 0; i < inNumChannels; i++)
1247 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001248 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001249 {
1250 ChannelList[outNumChannels++] = inPtr[i];
1251 }
1252 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001253 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001254 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001255 }
1256 else if (eCSR_BAND_5G == eBand)
1257 {
1258 for (i = 0; i < inNumChannels; i++)
1259 {
1260 /* Add 5G Non-DFS channel */
1261 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001262 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001263 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1264 {
1265 ChannelList[outNumChannels++] = inPtr[i];
1266 }
1267 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001268 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001269 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001270 }
1271 else if (eCSR_BAND_ALL == eBand)
1272 {
1273 for (i = 0; i < inNumChannels; i++)
1274 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001275 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001276 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1277 {
1278 ChannelList[outNumChannels++] = inPtr[i];
1279 }
1280 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001281 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001282 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001283 }
1284 else
1285 {
1286 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1287 "Invalid band, No operation carried out (Band %d)", eBand);
1288 status = eHAL_STATUS_INVALID_PARAMETER;
1289 }
1290
1291 return status;
1292}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001293#endif
1294
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001295#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001296/* This function modifies the roam scan channel list as per AP neighbor
1297 report; AP neighbor report may be empty or may include only other AP
1298 channels; in any case, we merge the channel list with the learned occupied
1299 channels list.
1300 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1301 if the band is 5G, then make sure channel list contains only 5G valid channels
1302*/
1303eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1304 tANI_U8 *pChannelList,
1305 tANI_U8 numChannels,
1306 const eCsrBand eBand)
1307{
1308 eHalStatus status = eHAL_STATUS_SUCCESS;
1309 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1310 tANI_U8 outNumChannels = 0;
1311 tANI_U8 inNumChannels = numChannels;
1312 tANI_U8 *inPtr = pChannelList;
1313 tANI_U8 i = 0;
1314 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1315 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1316 tANI_U8 mergedOutputNumOfChannels = 0;
1317 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1318
1319 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1320 * report Channels. This increases the chances of the DUT to get a candidate AP while
1321 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1322 if (pMac->scan.occupiedChannels.numChannels)
1323 {
1324 csrNeighborRoamMergeChannelLists(pMac,
1325 &pMac->scan.occupiedChannels.channelList[0],
1326 pMac->scan.occupiedChannels.numChannels,
1327 inPtr,
1328 inNumChannels,
1329 &mergedOutputNumOfChannels);
1330 inNumChannels = mergedOutputNumOfChannels;
1331 }
1332
1333 if (eCSR_BAND_24 == eBand)
1334 {
1335 for (i = 0; i < inNumChannels; i++)
1336 {
1337 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1338 {
1339 ChannelList[outNumChannels++] = inPtr[i];
1340 }
1341 }
1342 }
1343 else if (eCSR_BAND_5G == eBand)
1344 {
1345 for (i = 0; i < inNumChannels; i++)
1346 {
1347 /* Add 5G Non-DFS channel */
1348 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1349 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1350 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1351 {
1352 ChannelList[outNumChannels++] = inPtr[i];
1353 }
1354 }
1355 }
1356 else if (eCSR_BAND_ALL == eBand)
1357 {
1358 for (i = 0; i < inNumChannels; i++)
1359 {
1360 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1361 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1362 {
1363 ChannelList[outNumChannels++] = inPtr[i];
1364 }
1365 }
1366 }
1367 else
1368 {
1369 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1370 "Invalid band, No operation carried out (Band %d)", eBand);
1371 return eHAL_STATUS_INVALID_PARAMETER;
1372 }
1373
1374 /* if roaming within band is enabled, then select only the
1375 in band channels .
1376 This is required only if the band capability is set to ALL,
1377 E.g., if band capability is only 2.4G then all the channels in the
1378 list are already filtered for 2.4G channels, hence ignore this check*/
1379
1380 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1381 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301382 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001383 pMac,
1384 ChannelList,
1385 outNumChannels,
1386 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301387 &outNumChannels,
1388 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301389 vos_mem_copy(ChannelList,
1390 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001391 }
1392
1393 /* Prepare final roam scan channel list */
1394 if(outNumChannels)
1395 {
1396 /* Clear the channel list first */
1397 if (NULL != currChannelListInfo->ChannelList)
1398 {
1399 vos_mem_free(currChannelListInfo->ChannelList);
1400 currChannelListInfo->ChannelList = NULL;
1401 currChannelListInfo->numOfChannels = 0;
1402 }
1403
1404 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1405 if (NULL == currChannelListInfo->ChannelList)
1406 {
1407 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1408 "Failed to allocate memory for roam scan channel list");
1409 currChannelListInfo->numOfChannels = 0;
1410 return VOS_STATUS_E_RESOURCES;
1411 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301412 vos_mem_copy(currChannelListInfo->ChannelList,
1413 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001414 }
1415 return status;
1416}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001417#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001418
Jeff Johnson295189b2012-06-20 16:38:30 -07001419eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1420{
1421 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1422 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1424 (eBand == eCSR_BAND_24))
1425 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001426 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001428 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001429 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001430 pMac->roam.configParam.uCfgDot11Mode, eBand);
1431 return eHAL_STATUS_INVALID_PARAMETER;
1432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1434 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1435 (eBand == eCSR_BAND_5G))
1436 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001437 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001438 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001439 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001440 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 pMac->roam.configParam.uCfgDot11Mode, eBand);
1442 return eHAL_STATUS_INVALID_PARAMETER;
1443 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001444 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001445 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001446 pMac->roam.configParam.eBand = eBand;
1447 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001448 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001449#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001450 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1451 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001452#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001453 status = csrInitGetChannels( pMac );
1454 if (eHAL_STATUS_SUCCESS == status)
1455 csrInitChannelList( hHal );
1456 return status;
1457}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001458
1459
Jeff Johnsone7245742012-09-05 17:12:55 -07001460/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1461 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1462 * Ideally we should have kept the ini value and enum value same and representing the same
1463 * cb values as in 11n standard i.e.
1464 * Set to 1 (SCA) if the secondary channel is above the primary channel
1465 * Set to 3 (SCB) if the secondary channel is below the primary channel
1466 * Set to 0 (SCN) if no secondary channel is present
1467 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1468 * 0 - secondary none
1469 * 1 - secondary LOW
1470 * 2 - secondary HIGH
1471 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1472 * The enum values are as follows:
1473 * PHY_SINGLE_CHANNEL_CENTERED = 0
1474 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1475 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1476 */
1477ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1478{
1479
1480 ePhyChanBondState phyCbState;
1481 switch (cbIniValue) {
1482 // secondary none
1483 case 0:
1484 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1485 break;
1486 // secondary LOW
1487 case 1:
1488 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1489 break;
1490 // secondary HIGH
1491 case 2:
1492 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1493 break;
1494#ifdef WLAN_FEATURE_11AC
1495 case 3:
1496 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1497 break;
1498 case 4:
1499 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1500 break;
1501 case 5:
1502 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1503 break;
1504 case 6:
1505 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1506 break;
1507 case 7:
1508 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1509 break;
1510 case 8:
1511 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1512 break;
1513 case 9:
1514 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1515 break;
1516#endif
1517 default:
1518 // If an invalid value is passed, disable CHANNEL BONDING
1519 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1520 break;
1521 }
1522 return phyCbState;
1523}
1524
1525v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1526{
1527
1528 v_U32_t cbIniValue;
1529 switch (phyCbState) {
1530 // secondary none
1531 case PHY_SINGLE_CHANNEL_CENTERED:
1532 cbIniValue = 0;
1533 break;
1534 // secondary LOW
1535 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1536 cbIniValue = 1;
1537 break;
1538 // secondary HIGH
1539 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1540 cbIniValue = 2;
1541 break;
1542#ifdef WLAN_FEATURE_11AC
1543 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1544 cbIniValue = 3;
1545 break;
1546 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1547 cbIniValue = 4;
1548 break;
1549 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1550 cbIniValue = 5;
1551 break;
1552 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1553 cbIniValue = 6;
1554 break;
1555 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1556 cbIniValue = 7;
1557 break;
1558 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1559 cbIniValue = 8;
1560 break;
1561 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1562 cbIniValue = 9;
1563 break;
1564#endif
1565 default:
1566 // return some invalid value
1567 cbIniValue = 10;
1568 break;
1569 }
1570 return cbIniValue;
1571}
Jeff Johnson295189b2012-06-20 16:38:30 -07001572
1573eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1574{
1575 eHalStatus status = eHAL_STATUS_SUCCESS;
1576
1577 if(pParam)
1578 {
1579 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1580 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1581 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1582 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1583 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1584 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1585
1586 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001587 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1588
Jeff Johnsone7245742012-09-05 17:12:55 -07001589 /* channelBondingMode5GHz plays a dual role right now
1590 * 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
1591 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1592 */
1593 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1594 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001595 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001596 }
1597 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1598 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1599 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001600 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001601 }
1602 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1604 pMac->roam.configParam.phyMode = pParam->phyMode;
1605 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1606 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1607 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1608 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1609 pMac->roam.configParam.TxRate = pParam->TxRate;
1610 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1611 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1612 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1613 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1614 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001615 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 //if HDD passed down non zero values then only update,
1617 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301618 if (pParam->nInitialDwellTime)
1619 {
1620 pMac->roam.configParam.nInitialDwellTime =
1621 pParam->nInitialDwellTime;
1622 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001623 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 {
1625 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301626 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1627 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001628 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001629 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 {
1631 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301632 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1633 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001635 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001636 {
1637 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301638 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1639 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001640 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001641 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001642 {
1643 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301644 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1645 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001647 if (pParam->nActiveMaxChnTimeBtc)
1648 {
1649 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1650 }
1651 if (pParam->nActiveMinChnTimeBtc)
1652 {
1653 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1654 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001655#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001656 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001657 {
1658 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1659 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001660 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001661 {
1662 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1663 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001664 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001665 {
1666 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1667 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001668 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001669 {
1670 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1671 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001672 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001673 {
1674 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1675 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001676 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001677 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001678 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1679 }
1680 if (pParam->nNumP2PChanCombinedConc)
1681 {
1682 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001683 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001684#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001686 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001687 {
1688 //Change the unit from second to microsecond
1689 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001690 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1691 {
1692 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1693 }
1694 else
1695 {
1696 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1697 }
1698 }
1699 else
1700 {
1701 pMac->roam.configParam.impsSleepTime = 0;
1702 }
1703 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1705 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 //if HDD passed down non zero values for age params, then only update,
1707 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001708 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 {
1710 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1711 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 if(pParam->scanAgeTimeNCNPS)
1713 {
1714 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1715 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001716 if(pParam->scanAgeTimeNCPS)
1717 {
1718 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001720 if(pParam->scanAgeTimeCNPS)
1721 {
1722 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1723 }
1724 if(pParam->scanAgeTimeCPS)
1725 {
1726 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1727 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301728 if (pParam->initialScanSkipDFSCh)
1729 {
1730 pMac->roam.configParam.initialScanSkipDFSCh =
1731 pParam->initialScanSkipDFSCh;
1732 }
1733
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001734 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001735 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1736 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1737 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1738 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1739 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001740 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1741 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1743 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1744 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1745 //Assign this before calling CsrInit11dInfo
1746 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 if( csrIs11dSupported( pMac ) )
1748 {
1749 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1750 }
1751 else
1752 {
1753 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1754 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001755
1756 /* Initialize the power + channel information if 11h is enabled.
1757 If 11d is enabled this information has already been initialized */
1758 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1759 {
1760 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1761 }
1762
1763
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301764#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301765 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1766 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001767 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001768#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001769#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001771 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001772 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001773 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001774 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001775 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001776 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001777 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001778 pMac->roam.configParam.nProbes = pParam->nProbes;
1779 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001780#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001781#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1782 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001783 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001784#endif
1785#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001786 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001787 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001788#endif
1789
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001790#ifdef FEATURE_WLAN_ESE
1791 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001792#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001793#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301794 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1795 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001796 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1797 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1798 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1799 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1800 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1801 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1802 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1803 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05301804 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 {
1806 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001807 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 -07001808 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1809 {
1810 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1811 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001812 }
1813#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001814 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1815 pMac->scan.fValidateList = pParam->fValidateList;
1816 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1817 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001818 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001820 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1821 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1822 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1823 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1824 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1825 * single session
1826 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001827 //Remove this code once SLM_Sessionization is supported
1828 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001829 pMac->roam.configParam.doBMPSWorkaround = 0;
1830
Jeff Johnsone7245742012-09-05 17:12:55 -07001831#ifdef WLAN_FEATURE_11AC
1832 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001833 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001834 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001835 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301836 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1837 if ( pParam->enableTxBF )
1838 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
1839 else
1840 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001841#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001842 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001843
1844 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001845 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001846 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1847 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301848 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05301849 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 }
1851
1852 return status;
1853}
1854
Jeff Johnson295189b2012-06-20 16:38:30 -07001855eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1856{
1857 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001858 if(pParam)
1859 {
1860 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1861 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1862 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1863 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1864 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1865 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001866 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1867 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001868 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1869 pParam->phyMode = pMac->roam.configParam.phyMode;
1870 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1871 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1872 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1873 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1874 pParam->TxRate = pMac->roam.configParam.TxRate;
1875 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1876 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1877 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1878 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1879 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001880 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1881 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1882 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1883 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001884 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1885 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1886 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001887#ifdef WLAN_AP_STA_CONCURRENCY
1888 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1889 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1890 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1891 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1892 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001893 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1894 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001895#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 //Change the unit from microsecond to second
1897 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1898 pParam->eBand = pMac->roam.configParam.eBand;
1899 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1900 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1901 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1902 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1903 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1904 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1905 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1906 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1907 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1908 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1909 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1910 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1911 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1913 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1914 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1915 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1917 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1918 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1919 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1920 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001921 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001922 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001923 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001924 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001925
1926#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301927 vos_mem_copy(&pParam->neighborRoamConfig,
1928 &pMac->roam.configParam.neighborRoamConfig,
1929 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001930#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001931#ifdef WLAN_FEATURE_11AC
1932 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001933 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001934 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001935 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301936 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1937 if ( pParam->enableTxBF )
1938 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
1939 else
1940 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001941#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001942#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301943 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1944 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001945#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001946#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001947 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1948 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1949 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1950 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1951 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001952 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001953 pParam->nProbes = pMac->roam.configParam.nProbes;
1954 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001955#endif
1956#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1957 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1958 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1959#endif
1960#ifdef FEATURE_WLAN_LFR
1961 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1962#endif
1963
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001964#ifdef FEATURE_WLAN_ESE
1965 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001966#endif
1967#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301968 vos_mem_copy(&pParam->neighborRoamConfig,
1969 &pMac->roam.configParam.neighborRoamConfig,
1970 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001971 {
1972 int i;
1973 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1974 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1975 {
1976 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1977 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001978 }
1979#endif
1980
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001981 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001982
krunal soni5afa96c2013-09-06 22:19:02 -07001983 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001984 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07001985
krunal sonie9002db2013-11-25 14:24:17 -08001986 pParam->isCoalesingInIBSSAllowed =
1987 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301988 pParam->allowDFSChannelRoam =
1989 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05301990 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07001991 csrSetChannels(pMac, pParam);
1992
1993 status = eHAL_STATUS_SUCCESS;
1994 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001995 return (status);
1996}
1997
Jeff Johnson295189b2012-06-20 16:38:30 -07001998eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1999{
2000 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2001 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2002 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2003 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002004 do
2005 {
2006 if(eCSR_BAND_24 == eBand)
2007 {
2008 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2009 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2010 }
2011 if(eCSR_BAND_5G == eBand)
2012 {
2013 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2014 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2015 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2016 )
2017 {
2018 break;
2019 }
2020 }
2021 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2022 {
2023 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2024 }
2025 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2026 {
2027 newPhyMode = eCSR_DOT11_MODE_AUTO;
2028 }
2029 else
2030 {
2031 //Check for dual band and higher capability first
2032 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2033 {
2034 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2035 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2036 }
2037 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2038 {
2039 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2040 if(eCSR_BAND_24 == eBand) break;
2041 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2042 eBand = eCSR_BAND_5G;
2043 }
2044 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2045 {
2046 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2047 if(eCSR_BAND_5G == eBand) break;
2048 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2049 eBand = eCSR_BAND_24;
2050 }
2051 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2052 {
2053 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2054 if(eCSR_BAND_5G == eBand) break;
2055 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2056 eBand = eCSR_BAND_24;
2057 }
2058 else if(eCSR_DOT11_MODE_11n & phyMode)
2059 {
2060 newPhyMode = eCSR_DOT11_MODE_11n;
2061 }
2062 else if(eCSR_DOT11_MODE_abg & phyMode)
2063 {
2064 newPhyMode = eCSR_DOT11_MODE_abg;
2065 }
2066 else if(eCSR_DOT11_MODE_11a & phyMode)
2067 {
2068 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2069 {
2070 if(eCSR_BAND_ALL == eBand)
2071 {
2072 newPhyMode = eCSR_DOT11_MODE_abg;
2073 }
2074 else
2075 {
2076 //bad setting
2077 break;
2078 }
2079 }
2080 else
2081 {
2082 newPhyMode = eCSR_DOT11_MODE_11a;
2083 eBand = eCSR_BAND_5G;
2084 }
2085 }
2086 else if(eCSR_DOT11_MODE_11g & phyMode)
2087 {
2088 newPhyMode = eCSR_DOT11_MODE_11g;
2089 eBand = eCSR_BAND_24;
2090 }
2091 else if(eCSR_DOT11_MODE_11b & phyMode)
2092 {
2093 newPhyMode = eCSR_DOT11_MODE_11b;
2094 eBand = eCSR_BAND_24;
2095 }
2096 else
2097 {
2098 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002099 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002100 newPhyMode = eCSR_DOT11_MODE_AUTO;
2101 }
2102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 //Done validating
2104 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002105 //Now we need to check whether a restart is needed.
2106 if(eBand != pMac->roam.configParam.eBand)
2107 {
2108 fRestartNeeded = eANI_BOOLEAN_TRUE;
2109 break;
2110 }
2111 if(newPhyMode != pMac->roam.configParam.phyMode)
2112 {
2113 fRestartNeeded = eANI_BOOLEAN_TRUE;
2114 break;
2115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002116 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 if(HAL_STATUS_SUCCESS(status))
2118 {
2119 pMac->roam.configParam.eBand = eBand;
2120 pMac->roam.configParam.phyMode = newPhyMode;
2121 if(pfRestartNeeded)
2122 {
2123 *pfRestartNeeded = fRestartNeeded;
2124 }
2125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 return (status);
2127}
2128
Jeff Johnson295189b2012-06-20 16:38:30 -07002129void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2130{
2131 tANI_U8 Index;
2132 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 // for dual band NICs, don't need to trim the channel list....
2134 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2135 {
2136 // 2.4 GHz band operation requires the channel list to be trimmed to
2137 // the 2.4 GHz channels only...
2138 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2139 {
2140 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2141 Index++ )
2142 {
2143 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2144 {
2145 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2146 cChannels++;
2147 }
2148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2150 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2151 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2152 // only if we need to.
2153 //
2154 // The amount of memory to clear is the number of channesl that we trimmed
2155 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2156
2157 if ( pChannelList->numChannels > cChannels )
2158 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302159 vos_mem_set(&pChannelList->channelList[ cChannels ],
2160 sizeof( pChannelList->channelList[ 0 ] ) *
2161 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 }
2163
2164 pChannelList->numChannels = cChannels;
2165 }
2166 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2167 {
2168 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2169 {
2170 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2171 {
2172 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2173 cChannels++;
2174 }
2175 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2177 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2178 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2179 // only if we need to.
2180 //
2181 // The amount of memory to clear is the number of channesl that we trimmed
2182 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2183 if ( pChannelList->numChannels > cChannels )
2184 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302185 vos_mem_set(&pChannelList->channelList[ cChannels ],
2186 sizeof( pChannelList->channelList[ 0 ] ) *
2187 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002188 }
2189
2190 pChannelList->numChannels = cChannels;
2191 }
2192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002193}
Jeff Johnson295189b2012-06-20 16:38:30 -07002194#define INFRA_AP_DEFAULT_CHANNEL 6
2195eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2196{
2197 tANI_U8 index= 0;
2198 eHalStatus status = eHAL_STATUS_FAILURE;
2199 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2200 {
2201 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2202 status = eHAL_STATUS_SUCCESS;
2203 break;
2204 }
2205 }
2206 return status;
2207}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002208
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002209
Jeff Johnson295189b2012-06-20 16:38:30 -07002210eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2211{
2212 eHalStatus status = eHAL_STATUS_SUCCESS;
2213 tANI_U8 num20MHzChannelsFound = 0;
2214 VOS_STATUS vosStatus;
2215 tANI_U8 Index = 0;
2216 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002217
Jeff Johnson295189b2012-06-20 16:38:30 -07002218
2219 //TODO: this interface changed to include the 40MHz channel list
2220 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2221 // Read the scan channel list (including the power limit) from EEPROM
2222 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2223 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2224 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2225 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002226 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 status = eHAL_STATUS_FAILURE;
2228 }
2229 else
2230 {
2231 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2232 {
2233 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2234 }
2235 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2236 // Move the channel list to the global data
2237 // structure -- this will be used as the scan list
2238 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2239 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 }
2242 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2243 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2244 {
2245 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2246 }
2247 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2248 {
2249 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2250 }
2251 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 return (status);
2254}
Jeff Johnson295189b2012-06-20 16:38:30 -07002255eHalStatus csrInitChannelList( tHalHandle hHal )
2256{
2257 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2258 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2260 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002261 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2262 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002264 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302265 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 return (status);
2267}
Jeff Johnson295189b2012-06-20 16:38:30 -07002268eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2269 tCsrUpdateConfigParam *pUpdateConfigParam)
2270{
2271 eHalStatus status = eHAL_STATUS_FAILURE;
2272 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2274 status = CsrInit11dInfo(pMac, ps11dinfo);
2275 return status;
2276}
2277
Jeff Johnson295189b2012-06-20 16:38:30 -07002278static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2279{
2280 eHalStatus status = eHAL_STATUS_FAILURE;
2281 tANI_U8 index;
2282 tANI_U32 count=0;
2283 tSirMacChanInfo *pChanInfo;
2284 tSirMacChanInfo *pChanInfoStart;
2285 tANI_BOOLEAN applyConfig = TRUE;
2286
Mihir Shetebc866f62014-02-13 16:08:53 +05302287 pMac->scan.currentCountryRSSI = -128;
2288
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 if(!ps11dinfo)
2290 {
2291 return (status);
2292 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002293 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2294 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302295 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2296 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2297 ps11dinfo->Channels.channelList,
2298 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002299 }
2300 else
2301 {
2302 //No change
2303 return (eHAL_STATUS_SUCCESS);
2304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302306
2307 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2308 WNI_CFG_COUNTRY_CODE_LEN);
2309
2310
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 //Tush: at csropen get this initialized with default, during csr reset if this
2312 // already set with some value no need initilaize with default again
2313 if(0 == pMac->scan.countryCodeCurrent[0])
2314 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302315 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2316 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002318 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302319 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2320 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002321 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302322 vos_mem_set(pChanInfo,
2323 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2324 0);
2325
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002327 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2328 {
2329 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2330 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2331 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2332 pChanInfo++;
2333 count++;
2334 }
2335 if(count)
2336 {
2337 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2338 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302339 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002340 }
2341 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2342 if( HAL_STATUS_SUCCESS(status) )
2343 {
2344 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2345 {
2346 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2347 {
2348 applyConfig = FALSE;
2349 }
2350 }
2351
2352 if(TRUE == applyConfig)
2353 {
2354 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002355 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002356 }
2357
2358 }
2359 return (status);
2360}
2361/* Initialize the Channel + Power List in the local cache and in the CFG */
2362eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2363{
2364 tANI_U8 index;
2365 tANI_U32 count=0;
2366 tSirMacChanInfo *pChanInfo;
2367 tSirMacChanInfo *pChanInfoStart;
2368
2369 if(!ps11dinfo || !pMac)
2370 {
2371 return eHAL_STATUS_FAILURE;
2372 }
2373
Kiet Lam64c1b492013-07-12 13:56:44 +05302374 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2375 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002376 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302377 vos_mem_set(pChanInfo,
2378 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2379 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002380 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002381
2382 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2383 {
2384 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2385 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2386 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2387 pChanInfo++;
2388 count++;
2389 }
2390 if(count)
2391 {
2392 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2393 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302394 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002395 }
2396
Jeff Johnsone7245742012-09-05 17:12:55 -07002397 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002398}
2399
2400//pCommand may be NULL
2401//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2402void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2403{
2404 tListElem *pEntry, *pNextEntry;
2405 tSmeCmd *pDupCommand;
2406 tDblLinkList localList;
2407
2408 vos_mem_zero(&localList, sizeof(tDblLinkList));
2409 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2410 {
2411 smsLog(pMac, LOGE, FL(" failed to open list"));
2412 return;
2413 }
2414 csrLLLock( &pMac->sme.smeCmdPendingList );
2415 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2416 while( pEntry )
2417 {
2418 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2419 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 // Remove the previous command if..
2421 // - the new roam command is for the same RoamReason...
2422 // - the new roam command is a NewProfileList.
2423 // - the new roam command is a Forced Dissoc
2424 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2425 if (
2426 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2427 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002428 /* This peermac check is requried for Softap/GO scenarios
2429 * For STA scenario below OR check will suffice as pCommand will
2430 * always be NULL for STA scenarios
2431 */
2432 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2434 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2435 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2436 ||
2437 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002438 ( (sessionId == pDupCommand->sessionId) &&
2439 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 ((eCsrForcedDisassoc == eRoamReason) ||
2441 (eCsrHddIssued == eRoamReason))
2442 )
2443 )
2444 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002445 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 // Remove the 'stale' roam command from the pending list...
2447 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2448 {
2449 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2450 }
2451 }
2452 pEntry = pNextEntry;
2453 }
2454 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2455
2456 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2457 {
2458 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2459 //Tell caller that the command is cancelled
2460 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2461 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2462 csrReleaseCommandRoam(pMac, pDupCommand);
2463 }
2464 csrLLClose(&localList);
2465}
Jeff Johnson295189b2012-06-20 16:38:30 -07002466eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2467 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2468{
2469 eHalStatus status = eHAL_STATUS_SUCCESS;
2470#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2471 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2472#endif
2473 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2475 {
2476 pSession = CSR_GET_SESSION( pMac, sessionId );
2477 }
2478 else
2479 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002480 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002481 VOS_ASSERT(0);
2482 return eHAL_STATUS_FAILURE;
2483 }
krunal soni587bf012014-02-04 12:35:11 -08002484
2485 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2486 {
2487 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2488 return eHAL_STATUS_FAILURE;
2489 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002490
krunal soni587bf012014-02-04 12:35:11 -08002491 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2492
krunal soni7f7d2c92014-02-06 15:08:43 -08002493 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002494 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002495 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002497 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2498 /*
2499 * Decrement bRefAssocStartCnt for FT reassoc failure.
2500 * Reason: For FT reassoc failures, we first call
2501 * csrRoamCallCallback before notifying a failed roam
2502 * completion through csrRoamComplete. The latter in
2503 * turn calls csrRoamProcessResults which tries to
2504 * once again call csrRoamCallCallback if bRefAssocStartCnt
2505 * is non-zero. Since this is redundant for FT reassoc
2506 * failure, decrement bRefAssocStartCnt.
2507 */
2508 pSession->bRefAssocStartCnt--;
2509 }
2510
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 if(NULL != pSession->callback)
2512 {
2513 if( pRoamInfo )
2514 {
2515 pRoamInfo->sessionId = (tANI_U8)sessionId;
2516 }
2517
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302518 /* avoid holding the global lock when making the roaming callback, original change came
2519 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2520 is possible on other OS ports where the callback may need to take locks to protect
2521 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2523 that may actually depend on the lock being held */
2524 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2525 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2526 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2527 }
2528 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2529 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2530#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302531 vos_mem_set(&connectionStatus,
2532 sizeof(vos_event_wlan_status_payload_type), 0);
2533
krunal soni7f7d2c92014-02-06 15:08:43 -08002534 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 {
2536 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2537 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2538 if(NULL != pRoamInfo->pBssDesc)
2539 {
2540 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2541 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002543 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2544 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2545 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302546 vos_mem_copy(connectionStatus.ssid,
2547 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2548
Jeff Johnson295189b2012-06-20 16:38:30 -07002549 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2550 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2553 {
2554 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2555 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2556 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2557 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 if(eCSR_ROAM_RESULT_FORCED == u2)
2559 {
2560 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2561 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2562 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2565 {
2566 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2567 connectionStatus.reason = eCSR_REASON_DISASSOC;
2568 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2571 {
2572 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2573 connectionStatus.reason = eCSR_REASON_DEAUTH;
2574 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2575 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002576#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2577
2578 return (status);
2579}
Jeff Johnson295189b2012-06-20 16:38:30 -07002580// Returns whether handoff is currently in progress or not
2581tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2582{
2583#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2584 return csrNeighborRoamIsHandoffInProgress(pMac);
2585#else
2586 return eANI_BOOLEAN_FALSE;
2587#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002588}
Jeff Johnson295189b2012-06-20 16:38:30 -07002589eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2590 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2591{
2592 eHalStatus status = eHAL_STATUS_SUCCESS;
2593 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2594 tANI_U16 reasonCode;
2595 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002596
2597 if(!pSession)
2598 {
2599 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2600 return eHAL_STATUS_FAILURE;
2601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002602
2603 //Restore AC weight in case we change it
2604 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2605 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002606 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 -07002607 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2608 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2609 }
2610
2611 if ( fMICFailure )
2612 {
2613 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2614 }
2615 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2616 {
2617 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002618 }
2619 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 {
2621 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002623#ifdef WLAN_FEATURE_VOWIFI_11R
2624 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2625 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2626 {
2627 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302628 vos_mem_copy(&bssId,
2629 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2630 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002631 }
2632 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002633#endif
2634 if(pSession->pConnectBssDesc)
2635 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302636 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002638
Jeff Johnson295189b2012-06-20 16:38:30 -07002639
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302640 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2641 " subState = %s reason=%d"),
2642 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2643 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002644
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2646
2647 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2648
2649 if(HAL_STATUS_SUCCESS(status))
2650 {
2651 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002652#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2653 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2654 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2655 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002656 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2658 }
2659#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002660 }
2661 else
2662 {
2663 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2664 }
2665
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 return (status);
2667}
Jeff Johnson295189b2012-06-20 16:38:30 -07002668
Jeff Johnson295189b2012-06-20 16:38:30 -07002669/* ---------------------------------------------------------------------------
2670 \fn csrRoamIssueDisassociateStaCmd
2671 \brief csr function that HDD calls to disassociate a associated station
2672 \param sessionId - session Id for Soft AP
2673 \param pPeerMacAddr - MAC of associated station to delete
2674 \param reason - reason code, be one of the tSirMacReasonCodes
2675 \return eHalStatus
2676 ---------------------------------------------------------------------------*/
2677eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2678 tANI_U32 sessionId,
2679 tANI_U8 *pPeerMacAddr,
2680 tANI_U32 reason)
2681{
2682 eHalStatus status = eHAL_STATUS_SUCCESS;
2683 tSmeCmd *pCommand;
2684
2685 do
2686 {
2687 pCommand = csrGetCommandBuffer( pMac );
2688 if ( !pCommand )
2689 {
2690 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2691 status = eHAL_STATUS_RESOURCES;
2692 break;
2693 }
2694 pCommand->command = eSmeCommandRoam;
2695 pCommand->sessionId = (tANI_U8)sessionId;
2696 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2697 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2698 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2699 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2700 if( !HAL_STATUS_SUCCESS( status ) )
2701 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002702 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002703 csrReleaseCommandRoam( pMac, pCommand );
2704 }
2705 }while(0);
2706
2707 return status;
2708}
2709
2710
Jeff Johnson295189b2012-06-20 16:38:30 -07002711/* ---------------------------------------------------------------------------
2712 \fn csrRoamIssueDeauthSta
2713 \brief csr function that HDD calls to delete a associated station
2714 \param sessionId - session Id for Soft AP
2715 \param pPeerMacAddr - MAC of associated station to delete
2716 \param reason - reason code, be one of the tSirMacReasonCodes
2717 \return eHalStatus
2718 ---------------------------------------------------------------------------*/
2719eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2720 tANI_U32 sessionId,
2721 tANI_U8 *pPeerMacAddr,
2722 tANI_U32 reason)
2723{
2724 eHalStatus status = eHAL_STATUS_SUCCESS;
2725 tSmeCmd *pCommand;
2726
2727 do
2728 {
2729 pCommand = csrGetCommandBuffer( pMac );
2730 if ( !pCommand )
2731 {
2732 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2733 status = eHAL_STATUS_RESOURCES;
2734 break;
2735 }
2736 pCommand->command = eSmeCommandRoam;
2737 pCommand->sessionId = (tANI_U8)sessionId;
2738 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2739 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2740 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2741 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2742 if( !HAL_STATUS_SUCCESS( status ) )
2743 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002744 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 csrReleaseCommandRoam( pMac, pCommand );
2746 }
2747 }while(0);
2748
2749 return status;
2750}
Jeff Johnson295189b2012-06-20 16:38:30 -07002751eHalStatus
2752csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2753 tANI_BOOLEAN bEnable )
2754{
2755 eHalStatus status = eHAL_STATUS_FAILURE;
2756 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2757 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 if (!pSession)
2759 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002760 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002761 return (status);
2762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002763 if (pSession->pConnectBssDesc)
2764 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302765 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 }
2767 else
2768 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002769 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 return (status);
2771 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002772 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2773 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2775 return (status);
2776}
Jeff Johnson295189b2012-06-20 16:38:30 -07002777eHalStatus
2778csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2779 VOS_MODULE_ID modId, void *pUsrContext,
2780 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2781{
2782 eHalStatus status = eHAL_STATUS_SUCCESS;
2783 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2784 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002785 if (!pSession)
2786 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002787 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 return (status);
2789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 if(pSession->pConnectBssDesc)
2791 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302792 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002793 }
2794 else
2795 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002796 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 return (status);
2798 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002799 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2800 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002801 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2802 return (status);
2803}
Jeff Johnson295189b2012-06-20 16:38:30 -07002804eHalStatus
2805csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2806 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2807{
2808 eHalStatus status = eHAL_STATUS_SUCCESS;
2809 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2810 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2811
2812 if (!pSession)
2813 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002814 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 return (status);
2816 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 if(pSession->pConnectBssDesc)
2818 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302819 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002820 }
2821 else
2822 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002823 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 return (status);
2825 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002826 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2827 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002828
2829 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2830
2831 return (status);
2832}
Jeff Johnson295189b2012-06-20 16:38:30 -07002833eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2834{
2835 eHalStatus status = eHAL_STATUS_SUCCESS;
2836 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2837 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002838
2839 if (!pSession)
2840 {
2841 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2842 return eHAL_STATUS_FAILURE;
2843 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002844
2845 if(pSession->pConnectBssDesc)
2846 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302847 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002848 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002849 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2850 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2852
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302853 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05302854 if(HAL_STATUS_SUCCESS(status))
2855 {
2856 csrRoamLinkDown(pMac, sessionId);
2857 }
2858 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002859 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302860 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2861 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002862 }
2863
Jeff Johnson295189b2012-06-20 16:38:30 -07002864 return (status);
2865}
2866
Jeff Johnson295189b2012-06-20 16:38:30 -07002867eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2868{
2869 eHalStatus status = eHAL_STATUS_SUCCESS;
2870 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2871 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002872
2873 if(!pSession)
2874 {
2875 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2876 return eHAL_STATUS_FAILURE;
2877 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002878
2879 // If no BSS description was found in this connection (happens with start IBSS), then
2880 // nix the BSS description that we keep around for the connected BSS) and get out...
2881 if(NULL == pBssDesc)
2882 {
2883 csrFreeConnectBssDesc(pMac, sessionId);
2884 }
2885 else
2886 {
2887 size = pBssDesc->length + sizeof( pBssDesc->length );
2888 if(NULL != pSession->pConnectBssDesc)
2889 {
2890 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2891 {
2892 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2893 csrFreeConnectBssDesc(pMac, sessionId);
2894 }
2895 }
2896 if(NULL == pSession->pConnectBssDesc)
2897 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302898 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302900 if (NULL == pSession->pConnectBssDesc)
2901 status = eHAL_STATUS_FAILURE;
2902 else
2903 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2904 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 return (status);
2906}
2907
Jeff Johnson295189b2012-06-20 16:38:30 -07002908eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2909 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2910 tDot11fBeaconIEs *pIes)
2911{
2912 eHalStatus status = eHAL_STATUS_SUCCESS;
2913 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302915 if (pIes == NULL)
2916 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002917
Jeff Johnson295189b2012-06-20 16:38:30 -07002918 do
2919 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302920 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2921 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 //get qos
2923 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2924 //get SSID
2925 if(pIes->SSID.present)
2926 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302927 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002928 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2929 }
2930 else
2931 pBssConfig->SSID.length = 0;
2932 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2933 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002934 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002935 //Return failed if profile doesn't have an SSID either.
2936 if(pProfile->SSIDs.numOfSSIDs == 0)
2937 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002938 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 status = eHAL_STATUS_FAILURE;
2940 break;
2941 }
2942 }
2943 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2944 {
2945 pBssConfig->eBand = eCSR_BAND_5G;
2946 }
2947 else
2948 {
2949 pBssConfig->eBand = eCSR_BAND_24;
2950 }
2951 //phymode
2952 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2953 {
2954 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2955 }
2956 else
2957 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002958 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002959 //force it
2960 if(eCSR_BAND_24 == pBssConfig->eBand)
2961 {
2962 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2963 }
2964 else
2965 {
2966 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2967 }
2968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002969 //Qos
2970 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2971 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2972 {
2973 //Joining BSS is not 11n capable and WMM is disabled on client.
2974 //Disable QoS and WMM
2975 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2976 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302977
2978 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302979 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302980 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2981 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2982 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2983 {
2984 //Joining BSS is 11n capable and WMM is disabled on AP.
2985 //Assume all HT AP's are QOS AP's and enable WMM
2986 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2987 }
2988
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 //auth type
2990 switch( pProfile->negotiatedAuthType )
2991 {
2992 default:
2993 case eCSR_AUTH_TYPE_WPA:
2994 case eCSR_AUTH_TYPE_WPA_PSK:
2995 case eCSR_AUTH_TYPE_WPA_NONE:
2996 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2997 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2998 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002999 case eCSR_AUTH_TYPE_SHARED_KEY:
3000 pBssConfig->authType = eSIR_SHARED_KEY;
3001 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003002 case eCSR_AUTH_TYPE_AUTOSWITCH:
3003 pBssConfig->authType = eSIR_AUTO_SWITCH;
3004 break;
3005 }
3006 //short slot time
3007 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3008 {
3009 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3010 }
3011 else
3012 {
3013 pBssConfig->uShortSlotTime = 0;
3014 }
3015 if(pBssConfig->BssCap.ibss)
3016 {
3017 //We don't support 11h on IBSS
3018 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3019 }
3020 else
3021 {
3022 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3023 }
3024 //power constraint
3025 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3026 //heartbeat
3027 if ( CSR_IS_11A_BSS( pBssDesc ) )
3028 {
3029 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3030 }
3031 else
3032 {
3033 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3034 }
3035 //Join timeout
3036 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07003037 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 if ( pBssDesc->beaconInterval )
3039 {
3040 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07003041 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 }
3043 else
3044 {
3045 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3046 }
3047 //validate CB
3048 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sandeep Puligilla60342762014-01-30 21:05:37 +05303049
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003051 return (status);
3052}
3053
Jeff Johnson295189b2012-06-20 16:38:30 -07003054static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3055 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3056{
3057 eHalStatus status = eHAL_STATUS_SUCCESS;
3058 tANI_U8 operationChannel = 0;
3059 tANI_U8 qAPisEnabled = FALSE;
3060 //SSID
3061 pBssConfig->SSID.length = 0;
3062 if(pProfile->SSIDs.numOfSSIDs)
3063 {
3064 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303065 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3066 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003067 }
3068 else
3069 {
3070 //SSID must present
3071 return eHAL_STATUS_FAILURE;
3072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 //Settomg up the capabilities
3074 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3075 {
3076 pBssConfig->BssCap.ibss = 1;
3077 }
3078 else
3079 {
3080 pBssConfig->BssCap.ess = 1;
3081 }
3082 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3083 {
3084 pBssConfig->BssCap.privacy = 1;
3085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 pBssConfig->eBand = pMac->roam.configParam.eBand;
3087 //phymode
3088 if(pProfile->ChannelInfo.ChannelList)
3089 {
3090 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3093 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 //QOS
3095 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 if ( pBssConfig->BssCap.ess == 1 )
3097 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 /*For Softap case enable WMM*/
3099 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3100 qAPisEnabled = TRUE;
3101 }
3102 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3104 qAPisEnabled = TRUE;
3105 } else {
3106 qAPisEnabled = FALSE;
3107 }
3108 } else {
3109 qAPisEnabled = TRUE;
3110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003111 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3112 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3113 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3114 )
3115 {
3116 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3117 } else {
3118 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3119 }
3120
3121 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003122 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 {
3124 default:
3125 case eCSR_AUTH_TYPE_WPA:
3126 case eCSR_AUTH_TYPE_WPA_PSK:
3127 case eCSR_AUTH_TYPE_WPA_NONE:
3128 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3129 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3130 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 case eCSR_AUTH_TYPE_SHARED_KEY:
3132 pBssConfig->authType = eSIR_SHARED_KEY;
3133 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 case eCSR_AUTH_TYPE_AUTOSWITCH:
3135 pBssConfig->authType = eSIR_AUTO_SWITCH;
3136 break;
3137 }
3138 //short slot time
3139 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3140 {
3141 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3142 }
3143 else
3144 {
3145 pBssConfig->uShortSlotTime = 0;
3146 }
3147 //power constraint. We don't support 11h on IBSS
3148 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3149 pBssConfig->uPowerLimit = 0;
3150 //heartbeat
3151 if ( eCSR_BAND_5G == pBssConfig->eBand )
3152 {
3153 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3154 }
3155 else
3156 {
3157 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3158 }
3159 //Join timeout
3160 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003161
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 return (status);
3163}
Jeff Johnson295189b2012-06-20 16:38:30 -07003164static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3165{
3166 eHalStatus status = eHAL_STATUS_FAILURE;
3167 tDot11fBeaconIEs *pIes = NULL;
3168
3169 do
3170 {
3171 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3172 {
3173 //err msg
3174 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003175 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 break;
3177 }
3178 //check if the AP is QAP & it supports APSD
3179 if( CSR_IS_QOS_BSS(pIes) )
3180 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303181 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 }
3183 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303184
3185 if (NULL != pIes)
3186 {
3187 vos_mem_free(pIes);
3188 }
3189
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 return status;
3191}
3192
Jeff Johnson295189b2012-06-20 16:38:30 -07003193void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3194{
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3196 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3197 // See !!Note: below in this function...
3198 tANI_U32 PrivacyEnabled = 0;
3199 tANI_U32 RsnEnabled = 0;
3200 tANI_U32 WepDefaultKeyId = 0;
3201 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3202 tANI_U32 Key0Length = 0;
3203 tANI_U32 Key1Length = 0;
3204 tANI_U32 Key2Length = 0;
3205 tANI_U32 Key3Length = 0;
3206
3207 // Reserve for the biggest key
3208 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3209 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3210 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3211 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3212
3213 switch ( pProfile->negotiatedUCEncryptionType )
3214 {
3215 case eCSR_ENCRYPT_TYPE_NONE:
3216
3217 // for NO encryption, turn off Privacy and Rsn.
3218 PrivacyEnabled = 0;
3219 RsnEnabled = 0;
3220
3221 // WEP key length and Wep Default Key ID don't matter in this case....
3222
3223 // clear out the WEP keys that may be hanging around.
3224 Key0Length = 0;
3225 Key1Length = 0;
3226 Key2Length = 0;
3227 Key3Length = 0;
3228
3229 break;
3230
3231 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303232 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003233
3234 // Privacy is ON. NO RSN for Wep40 static key.
3235 PrivacyEnabled = 1;
3236 RsnEnabled = 0;
3237
3238 // Set the Wep default key ID.
3239 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 // Wep key size if 5 bytes (40 bits).
3241 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3242
3243 // set encryption keys in the CFG database or clear those that are not present in this profile.
3244 if ( pProfile->Keys.KeyLength[0] )
3245 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303246 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3247 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003248 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3249 }
3250 else
3251 {
3252 Key0Length = 0;
3253 }
3254
3255 if ( pProfile->Keys.KeyLength[1] )
3256 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303257 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3258 WNI_CFG_WEP_KEY_LENGTH_5);
3259 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003260 }
3261 else
3262 {
3263 Key1Length = 0;
3264 }
3265
3266 if ( pProfile->Keys.KeyLength[2] )
3267 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303268 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3269 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3271 }
3272 else
3273 {
3274 Key2Length = 0;
3275 }
3276
3277 if ( pProfile->Keys.KeyLength[3] )
3278 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303279 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3280 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003281 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3282 }
3283 else
3284 {
3285 Key3Length = 0;
3286 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 break;
3288
3289 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303290 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003291
3292 // Privacy is ON. NO RSN for Wep40 static key.
3293 PrivacyEnabled = 1;
3294 RsnEnabled = 0;
3295
3296 // Set the Wep default key ID.
3297 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3298
3299 // Wep key size if 13 bytes (104 bits).
3300 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3301
3302 // set encryption keys in the CFG database or clear those that are not present in this profile.
3303 if ( pProfile->Keys.KeyLength[0] )
3304 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303305 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3306 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3308 }
3309 else
3310 {
3311 Key0Length = 0;
3312 }
3313
3314 if ( pProfile->Keys.KeyLength[1] )
3315 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303316 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3317 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3319 }
3320 else
3321 {
3322 Key1Length = 0;
3323 }
3324
3325 if ( pProfile->Keys.KeyLength[2] )
3326 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303327 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3328 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3330 }
3331 else
3332 {
3333 Key2Length = 0;
3334 }
3335
3336 if ( pProfile->Keys.KeyLength[3] )
3337 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303338 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3339 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003340 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3341 }
3342 else
3343 {
3344 Key3Length = 0;
3345 }
3346
3347 break;
3348
Jeff Johnson295189b2012-06-20 16:38:30 -07003349 case eCSR_ENCRYPT_TYPE_TKIP:
3350 case eCSR_ENCRYPT_TYPE_AES:
3351#ifdef FEATURE_WLAN_WAPI
3352 case eCSR_ENCRYPT_TYPE_WPI:
3353#endif /* FEATURE_WLAN_WAPI */
3354 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3355 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3356 PrivacyEnabled = (0 != fPrivacy);
3357
3358 // turn on RSN enabled for WPA associations
3359 RsnEnabled = 1;
3360
3361 // WEP key length and Wep Default Key ID don't matter in this case....
3362
3363 // clear out the static WEP keys that may be hanging around.
3364 Key0Length = 0;
3365 Key1Length = 0;
3366 Key2Length = 0;
3367 Key3Length = 0;
3368
3369 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 default:
3371 PrivacyEnabled = 0;
3372 RsnEnabled = 0;
3373 break;
3374 }
3375
3376 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3377 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3378 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3379 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3380 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3381 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3382 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3383 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3384}
3385
Jeff Johnson295189b2012-06-20 16:38:30 -07003386static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3387{
3388 tANI_U32 len = 0;
3389 if(pSSID->length <= WNI_CFG_SSID_LEN)
3390 {
3391 len = pSSID->length;
3392 }
3393 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3394}
3395
Jeff Johnson295189b2012-06-20 16:38:30 -07003396eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3397{
3398 eHalStatus status = eHAL_STATUS_SUCCESS;
3399 tANI_U32 QoSEnabled;
3400 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 // set the CFG enable/disable variables based on the qosType being configured...
3402 switch( qosType )
3403 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3405 QoSEnabled = FALSE;
3406 WmeEnabled = TRUE;
3407 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003408 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3409 QoSEnabled = FALSE;
3410 WmeEnabled = TRUE;
3411 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003412 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3413 QoSEnabled = FALSE;
3414 WmeEnabled = TRUE;
3415 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003416 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3417 QoSEnabled = TRUE;
3418 WmeEnabled = FALSE;
3419 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 case eCSR_MEDIUM_ACCESS_11e_HCF:
3421 QoSEnabled = TRUE;
3422 WmeEnabled = FALSE;
3423 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 default:
3425 case eCSR_MEDIUM_ACCESS_DCF:
3426 QoSEnabled = FALSE;
3427 WmeEnabled = FALSE;
3428 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003429 }
3430 //save the WMM setting for later use
3431 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303432 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 return (status);
3434}
Jeff Johnson295189b2012-06-20 16:38:30 -07003435static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3436 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3437{
3438 eHalStatus status = eHAL_STATUS_FAILURE;
3439 int i;
3440 eCsrCfgDot11Mode cfgDot11Mode;
3441 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303442 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3443 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003445
3446 if( NULL != pIes )
3447 {
3448 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003449 // Originally, we thought that for 11a networks, the 11a rates are always
3450 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3451 // appear in the Operational Rate set. Consequently, in either case, we
3452 // would blindly put the rates we support into our Operational Rate set
3453 // (including the basic rates, which we have already verified are
3454 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 // However, it turns out that this is not always the case. Some AP's
3456 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3457 // too. Now, we're a little more careful:
3458 pDstRate = pOpRateSet->rate;
3459 if(pIes->SuppRates.present)
3460 {
3461 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3462 {
3463 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3464 {
3465 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003466 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 }
3468 }
3469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003470 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3471 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3472 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3473 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3474 {
3475 // If there are Extended Rates in the beacon, we will reflect those
3476 // extended rates that we support in out Extended Operational Rate
3477 // set:
3478 pDstRate = pExRateSet->rate;
3479 if(pIes->ExtSuppRates.present)
3480 {
3481 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3482 {
3483 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3484 {
3485 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3486 pExRateSet->numRates++;
3487 }
3488 }
3489 }
3490 }
3491 }//Parsing BSSDesc
3492 else
3493 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003494 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 }
3496 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3497 return status;
3498}
3499
3500static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3501 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3502{
3503 int i;
3504 tANI_U8 *pDstRate;
3505 eCsrCfgDot11Mode cfgDot11Mode;
3506 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3507 tANI_U32 OperationalRatesLength = 0;
3508 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3509 tANI_U32 ExtendedOperationalRatesLength = 0;
3510 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3511 tANI_U32 ProprietaryOperationalRatesLength = 0;
3512 tANI_U32 PropRatesEnable = 0;
3513 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3514 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 if( NULL != pIes )
3517 {
3518 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 // Originally, we thought that for 11a networks, the 11a rates are always
3520 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3521 // appear in the Operational Rate set. Consequently, in either case, we
3522 // would blindly put the rates we support into our Operational Rate set
3523 // (including the basic rates, which we have already verified are
3524 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003525 // However, it turns out that this is not always the case. Some AP's
3526 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3527 // too. Now, we're a little more careful:
3528 pDstRate = OperationalRates;
3529 if(pIes->SuppRates.present)
3530 {
3531 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3532 {
3533 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3534 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3535 {
3536 *pDstRate++ = pIes->SuppRates.rates[ i ];
3537 OperationalRatesLength++;
3538 }
3539 }
3540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3542 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3543 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3544 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3545 {
3546 // If there are Extended Rates in the beacon, we will reflect those
3547 // extended rates that we support in out Extended Operational Rate
3548 // set:
3549 pDstRate = ExtendedOperationalRates;
3550 if(pIes->ExtSuppRates.present)
3551 {
3552 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3553 {
3554 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3555 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3556 {
3557 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3558 ExtendedOperationalRatesLength++;
3559 }
3560 }
3561 }
3562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 // Enable proprietary MAC features if peer node is Airgo node and STA
3564 // user wants to use them
3565 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3566 {
3567 PropRatesEnable = 1;
3568 }
3569 else
3570 {
3571 PropRatesEnable = 0;
3572 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 // For ANI network companions, we need to populate the proprietary rate
3574 // set with any proprietary rates we found in the beacon, only if user
3575 // allows them...
3576 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3577 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3578 {
3579 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3580 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3581 {
3582 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3583 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303584 vos_mem_copy(ProprietaryOperationalRates,
3585 pIes->Airgo.PropSuppRates.rates,
3586 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 }
3588 else {
3589 // No proprietary modes...
3590 ProprietaryOperationalRatesLength = 0;
3591 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003592 /* Get MCS Rate */
3593 pDstRate = MCSRateIdxSet;
3594 if ( pIes->HTCaps.present )
3595 {
3596 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3597 {
3598 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3599 {
3600 MCSRateLength++;
3601 *pDstRate++ = i;
3602 }
3603 }
3604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 // Set the operational rate set CFG variables...
3606 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3607 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3608 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3609 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3610 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3611 ProprietaryOperationalRates,
3612 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3613 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3614 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3615 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3616 }//Parsing BSSDesc
3617 else
3618 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003619 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003620 }
3621}
3622
Jeff Johnson295189b2012-06-20 16:38:30 -07003623static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3624 tCsrRoamProfile *pProfile )
3625{
3626 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3627 { 8,
3628 { SIR_MAC_RATE_6,
3629 SIR_MAC_RATE_9,
3630 SIR_MAC_RATE_12,
3631 SIR_MAC_RATE_18,
3632 SIR_MAC_RATE_24,
3633 SIR_MAC_RATE_36,
3634 SIR_MAC_RATE_48,
3635 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003636 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3637 { 4,
3638 { SIR_MAC_RATE_1,
3639 SIR_MAC_RATE_2,
3640 SIR_MAC_RATE_5_5,
3641 SIR_MAC_RATE_11 } } };
3642
3643
3644 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3645 { SIR_MAC_RATE_72,
3646 SIR_MAC_RATE_96,
3647 SIR_MAC_RATE_108 } };
3648 eCsrCfgDot11Mode cfgDot11Mode;
3649 eCsrBand eBand;
3650 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3651 tANI_U32 OperationalRatesLength = 0;
3652 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3653 tANI_U32 ExtendedOperationalRatesLength = 0;
3654 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3655 tANI_U32 ProprietaryOperationalRatesLength = 0;
3656 tANI_U32 PropRatesEnable = 0;
3657 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 if(pProfile->ChannelInfo.ChannelList)
3659 {
3660 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003662 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3664 // networks, the 11b rates appear in the Operational Rate set. In either case,
3665 // we can blindly put the rates we support into our Operational Rate set
3666 // (including the basic rates, which we have already verified are supported
3667 // earlier in the roaming decision).
3668 if ( eCSR_BAND_5G == eBand )
3669 {
3670 // 11a rates into the Operational Rate Set.
3671 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3672 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303673 vos_mem_copy(OperationalRates,
3674 DefaultSupportedRates11a.supportedRateSet.rate,
3675 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003676
3677 // Nothing in the Extended rate set.
3678 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 // populate proprietary rates if user allows them
3680 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3681 {
3682 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3683 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303684 vos_mem_copy(ProprietaryOperationalRates,
3685 DefaultSupportedPropRates.propRate,
3686 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003687 }
3688 else
3689 {
3690 // No proprietary modes
3691 ProprietaryOperationalRatesLength = 0;
3692 }
3693 }
3694 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3695 {
3696 // 11b rates into the Operational Rate Set.
3697 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3698 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303699 vos_mem_copy(OperationalRates,
3700 DefaultSupportedRates11b.supportedRateSet.rate,
3701 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 // Nothing in the Extended rate set.
3703 ExtendedOperationalRatesLength = 0;
3704 // No proprietary modes
3705 ProprietaryOperationalRatesLength = 0;
3706 }
3707 else
3708 {
3709 // 11G
3710
3711 // 11b rates into the Operational Rate Set.
3712 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3713 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303714 vos_mem_copy(OperationalRates,
3715 DefaultSupportedRates11b.supportedRateSet.rate,
3716 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003717
3718 // 11a rates go in the Extended rate set.
3719 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3720 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303721 vos_mem_copy(ExtendedOperationalRates,
3722 DefaultSupportedRates11a.supportedRateSet.rate,
3723 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003724
3725 // populate proprietary rates if user allows them
3726 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3727 {
3728 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3729 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303730 vos_mem_copy(ProprietaryOperationalRates,
3731 DefaultSupportedPropRates.propRate,
3732 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 }
3734 else
3735 {
3736 // No proprietary modes
3737 ProprietaryOperationalRatesLength = 0;
3738 }
3739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3741 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3742 {
3743 PropRatesEnable = 1;
3744 }
3745 else
3746 {
3747 PropRatesEnable = 0;
3748 }
3749
3750 // Set the operational rate set CFG variables...
3751 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3752 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3753 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3754 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3755 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3756 ProprietaryOperationalRates,
3757 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3758 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003759}
Jeff Johnson295189b2012-06-20 16:38:30 -07003760void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3761{
3762 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003763
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3765 tANI_U32 sessionId;
3766 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003767 if(NULL == pEntry)
3768 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003769 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 return;
3771 }
3772 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3773 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05303774 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
3775 " current state : %d sub state : %d "),
3776 result, pMac->roam.curState[sessionId],
3777 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003778 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3779 {
3780 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3781 }
3782}
3783
Jeff Johnson295189b2012-06-20 16:38:30 -07003784//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3785tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3786{
3787 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3788 {
3789 return (WNI_CFG_PHY_MODE_11B);
3790 }
3791 else
3792 {
3793 if(eCSR_BAND_24 == band)
3794 return (WNI_CFG_PHY_MODE_11G);
3795 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 return (WNI_CFG_PHY_MODE_11A);
3797}
Jeff Johnson295189b2012-06-20 16:38:30 -07003798
Jeff Johnsone7245742012-09-05 17:12:55 -07003799
3800#ifdef WLAN_FEATURE_11AC
3801ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3802{
3803 switch ( aniCBMode )
3804 {
3805 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3806 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3807 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3808 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3809 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3810 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3811 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3812 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3813 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003814 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003815 return PHY_SINGLE_CHANNEL_CENTERED;
3816 }
3817}
3818#endif
3819
Jeff Johnson295189b2012-06-20 16:38:30 -07003820//pIes may be NULL
3821eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3822 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303823 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003824{
3825 eHalStatus status = eHAL_STATUS_SUCCESS;
3826 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3827 tANI_U8 channel = 0;
3828 //Make sure we have the domain info for the BSS we try to connect to.
3829 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303830 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05303832 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003833 {
3834 //Make sure the 11d info from this BSSDesc can be applied
3835 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303836 if (VOS_TRUE == resetCountry)
3837 {
3838 csrApplyCountryInformation(pMac, FALSE);
3839 }
3840 else
3841 {
3842 csrApplyCountryInformation(pMac, TRUE);
3843 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 }
Kiran4a17ebe2013-01-31 10:43:43 -08003845 if ((csrIs11dSupported (pMac)) && pIes)
3846 {
3847 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003848 {
Kiran4a17ebe2013-01-31 10:43:43 -08003849 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003850 }
3851 else
3852 {
3853 //Let's also update the below to make sure we don't update CC while
3854 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303855 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003856 pBssDesc->bssId, sizeof(tSirMacAddr));
3857 }
Kiran4a17ebe2013-01-31 10:43:43 -08003858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003859 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 //Qos
3861 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3862 //SSID
3863 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3864 //fragment threshold
3865 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3866 //RTS threshold
3867 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3868
3869 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003870 //Auth type
3871 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3872 //encryption type
3873 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3874 //short slot time
3875 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 //11d
3877 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3878 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3879 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003880 /*//11h
3881 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3882 */
3883 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3884 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003885
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003886 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 {
3888 channel = pProfile->operationChannel;
3889 }
3890 else
3891 {
3892 if(pBssDesc)
3893 {
3894 channel = pBssDesc->channelId;
3895 }
3896 }
3897 if(0 != channel)
3898 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05303899 if(CSR_IS_CHANNEL_24GHZ(channel) &&
3900 !pMac->roam.configParam.channelBondingMode24GHz &&
3901 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
3902 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05303904 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3905 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
3906 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 }
3908 else
3909 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003910 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 }
3912 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003913#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003914 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3915 // in function csrConvertCBIniValueToPhyCBState()
3916 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3917 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003918 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003919 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003920 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003921 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05303922 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003923 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003924 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003925 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003926 }
3927 else
3928#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3930 //Rate
3931 //Fixed Rate
3932 if(pBssDesc)
3933 {
3934 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3935 }
3936 else
3937 {
3938 csrSetCfgRateSetFromProfile(pMac, pProfile);
3939 }
3940 //Make this the last CFG to set. The callback will trigger a join_req
3941 //Join time out
3942 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3943
3944 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 return (status);
3946}
3947
Jeff Johnson295189b2012-06-20 16:38:30 -07003948eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3949 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3950{
3951 eHalStatus status;
3952 tBssConfigParam *pBssConfig;
3953 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003954
3955 if(!pSession)
3956 {
3957 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3958 return eHAL_STATUS_FAILURE;
3959 }
3960
Kiet Lam64c1b492013-07-12 13:56:44 +05303961 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
3962 if ( NULL == pBssConfig )
3963 status = eHAL_STATUS_FAILURE;
3964 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303966 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3968 if(HAL_STATUS_SUCCESS(status))
3969 {
3970 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003971 /* This will allow to pass cbMode during join req */
3972 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 //For IBSS, we need to prepare some more information
3974 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003976 )
3977 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003978 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 }
3980 // If we are in an IBSS, then stop the IBSS...
3981 ////Not worry about WDS connection for now
3982 if ( csrIsConnStateIbss( pMac, sessionId ) )
3983 {
3984 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3985 }
3986 else
3987 {
3988 // if we are in an Infrastructure association....
3989 if ( csrIsConnStateInfra( pMac, sessionId ) )
3990 {
3991 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3992 // across SSIDs (roaming to a new SSID)... //
3993 //Not worry about WDS connection for now
3994 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303995 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 {
3997 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303998 status = csrRoamIssueDisassociate( pMac, sessionId,
3999 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304001 else
4002 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4004 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304005 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304007 // Set parameters for this Bss.
4008 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4009 pBssDesc, pBssConfig,
4010 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004011 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304012 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304014 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 {
4016 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4017 // Nothing to stop.
4018 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304020 )
4021 {
4022 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4023 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4024 // Set parameters for this Bss.
4025 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4026 pBssDesc, pBssConfig,
4027 pIes, is11rRoamingFlag);
4028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 }
4030 }
4031 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304032 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 return (status);
4035}
4036
Jeff Johnson295189b2012-06-20 16:38:30 -07004037eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4038 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4039{
4040 eCsrJoinState eRoamState = eCsrContinueRoaming;
4041 eHalStatus status;
4042 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4043 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4044 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004045
4046 if(!pSession)
4047 {
4048 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4049 return (eCsrStopRoaming);
4050 }
4051
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 if( CSR_IS_WDS_STA( pProfile ) )
4053 {
4054 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4055 if( !HAL_STATUS_SUCCESS( status ) )
4056 {
4057 eRoamState = eCsrStopRoaming;
4058 }
4059 }
4060 else
4061 {
4062 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4063 {
4064 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4065 return (eCsrStopRoaming);
4066 }
4067 if ( csrIsInfraBssDesc( pBssDesc ) )
4068 {
4069 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4070 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4071 // have changed and handle the changes (without disturbing the current association).
4072
4073 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4074 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4075 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4076 )
4077 {
4078 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4079 // with Authenticating first. To force this, stop the current association (Disassociate) and
4080 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4081 // a new Association.
4082 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4083 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004084 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4086 {
4087 eRoamState = eCsrReassocToSelfNoCapChange;
4088 }
4089 else
4090 {
4091 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304093 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4095 if(HAL_STATUS_SUCCESS(status))
4096 {
4097 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004098 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304100 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4101 pBssDesc, &bssConfig,
4102 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 if(!HAL_STATUS_SUCCESS(status))
4104 {
4105 eRoamState = eCsrStopRoaming;
4106 }
4107 }
4108 else
4109 {
4110 eRoamState = eCsrStopRoaming;
4111 }
4112 }//same profile
4113 }
4114 else
4115 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304116 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4118 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304119 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4120 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304122 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304124 }
4125 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004126 {
4127 // note: we used to pre-auth here with open authentication networks but that was not working so well.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304128 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07004129 // work much better.
4130 //
4131 //
4132 // stop the existing network before attempting to join the new network...
4133 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4134 {
4135 eRoamState = eCsrStopRoaming;
4136 }
4137 }
4138 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304139 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 {
4141 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4142 {
4143 eRoamState = eCsrStopRoaming;
4144 }
4145 }
4146 if( pIesLocal && !pScanResult->pvIes )
4147 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304148 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 }
4150 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 return( eRoamState );
4152}
4153
Jeff Johnson295189b2012-06-20 16:38:30 -07004154eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4155 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4156{
4157 eHalStatus status = eHAL_STATUS_SUCCESS;
4158 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304159 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 roamInfo.pBssDesc = pBssDesc;
4161 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4162 return (status);
4163}
Jeff Johnson295189b2012-06-20 16:38:30 -07004164//In case no matching BSS is found, use whatever default we can find
4165static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4166{
4167 //Need to get all negotiated types in place first
4168 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004169 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 {
4171 default:
4172 case eCSR_AUTH_TYPE_WPA:
4173 case eCSR_AUTH_TYPE_WPA_PSK:
4174 case eCSR_AUTH_TYPE_WPA_NONE:
4175 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4176 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4177 break;
4178
4179 case eCSR_AUTH_TYPE_SHARED_KEY:
4180 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4181 break;
4182
4183 case eCSR_AUTH_TYPE_AUTOSWITCH:
4184 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4185 break;
4186 }
4187 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4188 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4189 //In this case, the multicast encryption needs to follow the uncast ones.
4190 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4191 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4192}
4193
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004194
4195static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4196{
4197 switch(pCommand->u.roamCmd.roamReason)
4198 {
4199 case eCsrLostLink1:
4200 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4201 break;
4202 case eCsrLostLink2:
4203 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4204 break;
4205 case eCsrLostLink3:
4206 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4207 break;
4208 default:
4209 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4210 pCommand->u.roamCmd.roamReason);
4211 break;
4212 }
4213}
4214
Jeff Johnson295189b2012-06-20 16:38:30 -07004215static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4216{
4217 eHalStatus status;
4218 tCsrScanResult *pScanResult = NULL;
4219 eCsrJoinState eRoamState = eCsrStopRoaming;
4220 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4221 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4222 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4223#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4224 v_U8_t acm_mask = 0;
4225#endif
4226 tANI_U32 sessionId = pCommand->sessionId;
4227 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4228 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4229 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004230
4231 if(!pSession)
4232 {
4233 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4234 return (eCsrStopRoaming);
4235 }
4236
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 do
4238 {
4239 // Check for Cardbus eject condition, before trying to Roam to any BSS
4240 //***if( !balIsCardPresent(pAdapter) ) break;
4241
Kiet Lam64c1b492013-07-12 13:56:44 +05304242 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304243 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004244 if(NULL != pBSSList)
4245 {
4246 // When handling AP's capability change, continue to associate to
4247 // same BSS and make sure pRoamBssEntry is not Null.
4248 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4249 {
4250 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4251 {
4252 //Try the first BSS
4253 pCommand->u.roamCmd.pLastRoamBss = NULL;
4254 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4255 }
4256 else
4257 {
4258 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4259 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4260 {
4261 //Done with all the BSSs
4262 //In this case, will tell HDD the completion
4263 break;
4264 }
4265 else
4266 {
4267 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304268 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004269 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4270 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4271 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4272 pRoamInfo = &roamInfo;
4273 }
4274 }
4275 while(pCommand->u.roamCmd.pRoamBssEntry)
4276 {
4277 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004278 /*If concurrency enabled take the concurrent connected channel first. */
4279 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304280 if (vos_concurrent_open_sessions_running() &&
4281 !csrIsValidMcConcurrentSession(pMac, sessionId,
4282 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 {
4284 concurrentChannel =
4285 csrGetConcurrentOperationChannel(pMac);
4286 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004287 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 if ((concurrentChannel) &&
4289 (concurrentChannel ==
4290 pScanResult->Result.BssDescriptor.channelId))
4291 {
4292 //make this 0 because we do not want the
4293 //below check to pass as we don't want to
4294 //connect on other channel
4295 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4296 FL("Concurrent channel match =%d"),
4297 concurrentChannel);
4298 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 }
4300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004301
4302 if (!concurrentChannel)
4303 {
4304
4305 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4306 sessionId, &pScanResult->Result.BssDescriptor,
4307 pCommand->u.roamCmd.roamId)))
4308 {
4309 //Ok to roam this
4310 break;
4311 }
4312 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004313 else
4314 {
4315 eRoamState = eCsrStopRoamingDueToConcurrency;
4316 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4318 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4319 {
4320 //Done with all the BSSs
4321 fDone = eANI_BOOLEAN_TRUE;
4322 break;
4323 }
4324 }
4325 if(fDone)
4326 {
4327 break;
4328 }
4329 }
4330 }
4331 //We have something to roam, tell HDD when it is infra.
4332 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4333 //For WDS, the indication is eCSR_ROAM_WDS_IND
4334 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4335 {
4336 if(pRoamInfo)
4337 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004338 if(pSession->bRefAssocStartCnt)
4339 {
4340 pSession->bRefAssocStartCnt--;
4341 //Complete the last association attemp because a new one is about to be tried
4342 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4343 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004344 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004345 }
4346 }
4347 /* If the roaming has stopped, not to continue the roaming command*/
4348 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4349 {
4350 //No need to complete roaming here as it already completes
4351 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4352 pCommand->u.roamCmd.roamReason);
4353 eRoamState = eCsrStopRoaming;
4354 csrSetAbortRoamingCommand(pMac, pCommand);
4355 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304357 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 if(pScanResult)
4359 {
4360 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4362 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004363 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004364 fDone = eANI_BOOLEAN_TRUE;
4365 eRoamState = eCsrStopRoaming;
4366 break;
4367 }
4368 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4369 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4370 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4371 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4372 CSR_IS_QOS_BSS(pIesLocal) &&
4373 CSR_IS_UAPSD_BSS(pIesLocal) )
4374 {
4375#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4377 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004378#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 }
4380 else
4381 {
4382 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4383 }
4384 if( pIesLocal && !pScanResult->Result.pvIes)
4385 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304386 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 }
4388 }
4389 else
4390 {
4391 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4392 }
4393 roamInfo.pProfile = pProfile;
4394 pSession->bRefAssocStartCnt++;
4395 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4396 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4399 {
4400 // If this is a start IBSS profile, then we need to start the IBSS.
4401 if ( CSR_IS_START_IBSS(pProfile) )
4402 {
4403 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004404 // Attempt to start this IBSS...
4405 csrRoamAssignDefaultParam( pMac, pCommand );
4406 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4407 if(HAL_STATUS_SUCCESS(status))
4408 {
4409 if ( fSameIbss )
4410 {
4411 eRoamState = eCsrStartIbssSameIbss;
4412 }
4413 else
4414 {
4415 eRoamState = eCsrContinueRoaming;
4416 }
4417 }
4418 else
4419 {
4420 //it somehow fail need to stop
4421 eRoamState = eCsrStopRoaming;
4422 }
4423 break;
4424 }
4425 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 )
4428 {
4429 // Attempt to start this WDS...
4430 csrRoamAssignDefaultParam( pMac, pCommand );
4431 /* For AP WDS, we dont have any BSSDescription */
4432 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4433 if(HAL_STATUS_SUCCESS(status))
4434 {
4435 eRoamState = eCsrContinueRoaming;
4436 }
4437 else
4438 {
4439 //it somehow fail need to stop
4440 eRoamState = eCsrStopRoaming;
4441 }
4442 }
4443 else
4444 {
4445 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004446 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 eRoamState = eCsrStopRoaming;
4448 break;
4449 }
4450 }
4451 else //We have BSS
4452 {
4453 //Need to assign these value because they are used in csrIsSameProfile
4454 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004455 /* The OSEN IE doesn't provide the cipher suite.
4456 * Therefore set to constant value of AES */
4457 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4458 {
4459 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4460 eCSR_ENCRYPT_TYPE_AES;
4461 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4462 eCSR_ENCRYPT_TYPE_AES;
4463 }
4464 else
4465 {
4466 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4467 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4468 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4469 pScanResult->mcEncryptionType;
4470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4472 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4473 {
4474 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4475 {
4476 eRoamState = eCsrStartIbssSameIbss;
4477 break;
4478 }
4479 }
4480 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4481 {
4482 //trying to connect to the one already connected
4483 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4484 eRoamState = eCsrReassocToSelfNoCapChange;
4485 break;
4486 }
4487 // Attempt to Join this Bss...
4488 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4489 break;
4490 }
4491
4492 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004493 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4494 {
4495 //Need to indicate association_completion if association_start has been done
4496 if(pSession->bRefAssocStartCnt > 0)
4497 {
4498 pSession->bRefAssocStartCnt--;
4499 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004500 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4502 eCSR_ROAM_ASSOCIATION_COMPLETION,
4503 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4504 }
4505 }
4506
4507 return( eRoamState );
4508}
4509
Jeff Johnson295189b2012-06-20 16:38:30 -07004510static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4511{
4512 eHalStatus status = eHAL_STATUS_SUCCESS;
4513 eCsrJoinState RoamState;
4514 tANI_U32 sessionId = pCommand->sessionId;
4515
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 //***if( hddIsRadioStateOn( pAdapter ) )
4517 {
4518 // Attept to join a Bss...
4519 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004520
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004522 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 {
4524 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 // and if connected in Infrastructure mode...
4526 if ( csrIsConnStateInfra(pMac, sessionId) )
4527 {
4528 //... then we need to issue a disassociation
4529 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4530 if(!HAL_STATUS_SUCCESS(status))
4531 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004532 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 //roam command is completed by caller in the failed case
4534 fComplete = eANI_BOOLEAN_TRUE;
4535 }
4536 }
4537 else if( csrIsConnStateIbss(pMac, sessionId) )
4538 {
4539 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4540 if(!HAL_STATUS_SUCCESS(status))
4541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004542 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 //roam command is completed by caller in the failed case
4544 fComplete = eANI_BOOLEAN_TRUE;
4545 }
4546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004547 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4548 {
4549 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4550 if(!HAL_STATUS_SUCCESS(status))
4551 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004552 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 //roam command is completed by caller in the failed case
4554 fComplete = eANI_BOOLEAN_TRUE;
4555 }
4556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 else
4558 {
4559 fComplete = eANI_BOOLEAN_TRUE;
4560 }
4561 if(fComplete)
4562 {
4563 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004564 if(eCsrStopRoamingDueToConcurrency == RoamState)
4565 {
4566 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4567 }
4568 else
4569 {
4570 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4571 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004572 }
4573 }
4574 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4575 {
4576 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4577 }
4578 else if ( eCsrStartIbssSameIbss == RoamState )
4579 {
4580 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4581 }
4582 }//hddIsRadioStateOn
4583
4584 return status;
4585}
Jeff Johnson295189b2012-06-20 16:38:30 -07004586eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4587{
4588 tANI_U32 sessionId;
4589 tCsrRoamSession *pSession;
4590 tCsrScanResult *pScanResult = NULL;
4591 tSirBssDescription *pBssDesc = NULL;
4592 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 sessionId = pCommand->sessionId;
4594 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004595
4596 if(!pSession)
4597 {
4598 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4599 return eHAL_STATUS_FAILURE;
4600 }
4601
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4603 {
4604 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004605 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4607 return eHAL_STATUS_FAILURE;
4608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 if (pCommand->u.roamCmd.pRoamBssEntry)
4610 {
4611 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4612 pBssDesc = &pScanResult->Result.BssDescriptor;
4613 }
4614 else
4615 {
4616 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004617 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4619 return eHAL_STATUS_FAILURE;
4620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004621 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4622 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4623 return status;
4624}
4625
Jeff Johnson295189b2012-06-20 16:38:30 -07004626eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4627{
4628 eHalStatus status = eHAL_STATUS_SUCCESS;
4629 tCsrRoamInfo roamInfo;
4630 tANI_U32 sessionId = pCommand->sessionId;
4631 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004632
4633 if(!pSession)
4634 {
4635 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4636 return eHAL_STATUS_FAILURE;
4637 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05304638
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 switch ( pCommand->u.roamCmd.roamReason )
4640 {
4641 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004642 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004643 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 case eCsrSmeIssuedDisassocForHandoff:
4646 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4647#if 0 // TODO : Confirm this change
4648 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4649#else
4650 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4651#endif
4652
4653 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004656 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004657 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004660 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004661 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004662 case eCsrHddIssuedReassocToSameAP:
4663 case eCsrSmeIssuedReassocToSameAP:
4664 {
4665 tDot11fBeaconIEs *pIes = NULL;
4666
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 if( pSession->pConnectBssDesc )
4668 {
4669 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4670 if(!HAL_STATUS_SUCCESS(status) )
4671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004672 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 }
4674 else
4675 {
4676 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4677 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4678 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4680 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4681 pSession->bRefAssocStartCnt++;
4682 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4683 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4684
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004685 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004686 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4687 &pCommand->u.roamCmd.roamProfile );
4688 if(!HAL_STATUS_SUCCESS(status))
4689 {
4690 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004691 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004692 }
4693
Kiet Lam64c1b492013-07-12 13:56:44 +05304694 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004695 pIes = NULL;
4696 }
4697 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05304698 else
4699 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 break;
4701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004703 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004704 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4705 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4706 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004707 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004708 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4710 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004711
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 case eCsrStopBss:
4713 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4714 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4715 break;
4716
4717 case eCsrForcedDisassocSta:
4718 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4719 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4720 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4721 pCommand->u.roamCmd.reason);
4722 break;
4723
4724 case eCsrForcedDeauthSta:
4725 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4726 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4727 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4728 pCommand->u.roamCmd.reason);
4729 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004730
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004731 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004732 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004733 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4734 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004735 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004736
4737 default:
4738 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4739
4740 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4741 {
4742 //Remember the roaming profile
4743 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304744 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4745 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004746 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304747 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4749 }
4750 }
4751
4752 //At this point, original uapsd_mask is saved in pCurRoamProfile
4753 //uapsd_mask in the pCommand may change from this point on.
4754
4755 // Attempt to roam with the new scan results (if we need to..)
4756 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004757 if(!HAL_STATUS_SUCCESS(status))
4758 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004759 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004760 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 break;
4762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 return (status);
4764}
4765
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004766void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4767{
4768 pCommand->u.roamCmd.pLastRoamBss = NULL;
4769 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4770 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304771 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004772}
4773
Jeff Johnson295189b2012-06-20 16:38:30 -07004774void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4775{
4776 if(pCommand->u.roamCmd.fReleaseBssList)
4777 {
4778 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4779 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4780 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4781 }
4782 if(pCommand->u.roamCmd.fReleaseProfile)
4783 {
4784 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4785 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4786 }
4787 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4788 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304789 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004790}
4791
Jeff Johnson295189b2012-06-20 16:38:30 -07004792void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4793{
Kiet Lam64c1b492013-07-12 13:56:44 +05304794 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004795}
Jeff Johnson295189b2012-06-20 16:38:30 -07004796void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4797{
4798 tListElem *pEntry;
4799 tSmeCmd *pCommand;
4800 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004801 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4803 if ( pEntry )
4804 {
4805 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004806 // If the head of the queue is Active and it is a ROAM command, remove
4807 // and put this on the Free queue.
4808 if ( eSmeCommandRoam == pCommand->command )
4809 {
4810 //we need to process the result first before removing it from active list because state changes
4811 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4812 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4813 if( fReleaseCommand )
4814 {
4815 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4816 {
4817 csrReleaseCommandRoam( pMac, pCommand );
4818 }
4819 else
4820 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004821 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004822 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004823 }
4824 }
4825 else
4826 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004827 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004828 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 }
4830 }
4831 else
4832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004833 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004834 }
4835 }
4836 else
4837 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004838 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004840 if( fReleaseCommand )
4841 {
4842 smeProcessPendingQueue( pMac );
4843 }
4844}
4845
Jeff Johnson295189b2012-06-20 16:38:30 -07004846void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4847{
4848 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004849 if(!pSession)
4850 {
4851 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4852 return;
4853 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304854 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4855 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 pSession->NumPmkidCandidate = 0;
4857}
Jeff Johnson295189b2012-06-20 16:38:30 -07004858#ifdef FEATURE_WLAN_WAPI
4859void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4860{
4861 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004862 if(!pSession)
4863 {
4864 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4865 return;
4866 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304867 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4868 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004869 pSession->NumBkidCandidate = 0;
4870}
4871#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004872extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4873
Jeff Johnson295189b2012-06-20 16:38:30 -07004874static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4875 tSirBssDescription *pSirBssDesc,
4876 tDot11fBeaconIEs *pIes)
4877{
4878 eHalStatus status = eHAL_STATUS_SUCCESS;
4879 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4880 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004881
4882 if(!pSession)
4883 {
4884 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4885 return eHAL_STATUS_FAILURE;
4886 }
4887
Jeff Johnson295189b2012-06-20 16:38:30 -07004888 if((eCSR_AUTH_TYPE_WPA == authType) ||
4889 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4890 (eCSR_AUTH_TYPE_RSN == authType) ||
4891 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4892#if defined WLAN_FEATURE_VOWIFI_11R
4893 ||
4894 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4895 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4896#endif /* FEATURE_WLAN_WAPI */
4897#ifdef FEATURE_WLAN_WAPI
4898 ||
4899 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4900 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4901#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004902#ifdef WLAN_FEATURE_11W
4903 ||
4904 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4905#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004906 )
4907 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4909 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004910 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 }
4912 if( pIesLocal )
4913 {
4914 tANI_U32 nIeLen;
4915 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 if((eCSR_AUTH_TYPE_RSN == authType) ||
4917#if defined WLAN_FEATURE_VOWIFI_11R
4918 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4919 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4920#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004921#if defined WLAN_FEATURE_11W
4922 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4923#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4925 {
4926 if(pIesLocal->RSN.present)
4927 {
4928 //Calculate the actual length
4929 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4930 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4931 + 2 //akm_suite_count
4932 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4933 + 2; //reserved
4934 if( pIesLocal->RSN.pmkid_count )
4935 {
4936 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4937 }
4938 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304939 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4940 if (NULL == pSession->pWpaRsnRspIE)
4941 status = eHAL_STATUS_FAILURE;
4942 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304944 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004945 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4946 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4947 //copy upto akm_suites
4948 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304949 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4950 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004951 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304952 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4953 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004954 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304955 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4956 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004957 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004958 if( pIesLocal->RSN.pwise_cipher_suite_count )
4959 {
4960 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304961 vos_mem_copy(pIeBuf,
4962 pIesLocal->RSN.pwise_cipher_suites,
4963 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4965 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304966 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 pIeBuf += 2;
4968 if( pIesLocal->RSN.akm_suite_count )
4969 {
4970 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304971 vos_mem_copy(pIeBuf,
4972 pIesLocal->RSN.akm_suites,
4973 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4975 }
4976 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304977 vos_mem_copy(pIeBuf,
4978 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4979 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4981 }
4982 }
4983 }
4984 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4985 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4986 {
4987 if(pIesLocal->WPA.present)
4988 {
4989 //Calculate the actual length
4990 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4991 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4992 + 2 //auth_suite_count
4993 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4994 // The WPA capabilities follows the Auth Suite (two octects)--
4995 // this field is optional, and we always "send" zero, so just
4996 // remove it. This is consistent with our assumptions in the
4997 // frames compiler; c.f. bug 15234:
4998 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304999
5000 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5001 if ( NULL == pSession->pWpaRsnRspIE )
5002 status = eHAL_STATUS_FAILURE;
5003 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 {
5005 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5006 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5007 pIeBuf = pSession->pWpaRsnRspIE + 2;
5008 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305009 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005010 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305011 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5012 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005013 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305014 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5015 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005016 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5017 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5018 }
5019 }
5020 }
5021#ifdef FEATURE_WLAN_WAPI
5022 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5023 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5024 {
5025 if(pIesLocal->WAPI.present)
5026 {
5027 //Calculate the actual length
5028 nIeLen = 4 //version + akm_suite_count
5029 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5030 + 2 //pwise_cipher_suite_count
5031 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5032 + 6; //gp_cipher_suite + preauth + reserved
5033 if( pIesLocal->WAPI.bkid_count )
5034 {
5035 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5036 }
5037
5038 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305039 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5040 if ( NULL == pSession->pWapiRspIE )
5041 status = eHAL_STATUS_FAILURE;
5042 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005043 {
5044 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5045 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5046 pIeBuf = pSession->pWapiRspIE + 2;
5047 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305048 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005049 pIeBuf += 4;
5050 if( pIesLocal->WAPI.akm_suite_count )
5051 {
5052 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305053 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5054 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305056 }
5057 vos_mem_copy(pIeBuf,
5058 &pIesLocal->WAPI.unicast_cipher_suite_count,
5059 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005060 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5062 {
5063 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305064 vos_mem_copy( pIeBuf,
5065 pIesLocal->WAPI.unicast_cipher_suites,
5066 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5068 }
lukez3c809222013-05-03 10:23:02 -07005069 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305070 vos_mem_copy(pIeBuf,
5071 pIesLocal->WAPI.multicast_cipher_suite,
5072 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005073 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305074 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305075 vos_mem_copy(pIeBuf,
5076 pIesLocal->WAPI.multicast_cipher_suite + 4,
5077 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005078 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305079 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305080 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5081
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005082 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 if( pIesLocal->WAPI.bkid_count )
5084 {
5085 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305086 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5087 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005088 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5089 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305090 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 }
5093 }
5094#endif /* FEATURE_WLAN_WAPI */
5095 if( !pIes )
5096 {
5097 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305098 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 }
5100 }
5101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005102 return (status);
5103}
5104
Jeff Johnson295189b2012-06-20 16:38:30 -07005105static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5106{
5107 v_U8_t bACWeights[WLANTL_MAX_AC];
5108 v_U8_t paramBk, paramBe, paramVi, paramVo;
5109 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005110 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5111 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5112 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5113 //This doesn't address the case where the lower AC needs a real higher weight
5114 if( pIEs->WMMParams.present )
5115 {
5116 //no change to the lowest ones
5117 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5118 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5119 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5120 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5121 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5122 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5123 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5124 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5125 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5126 {
5127 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5128 fWeightChange = VOS_TRUE;
5129 }
5130 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5131 {
5132 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5133 fWeightChange = VOS_TRUE;
5134 }
5135 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5136 {
5137 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5138 fWeightChange = VOS_TRUE;
5139 }
5140 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5141 {
5142 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5143 fWeightChange = VOS_TRUE;
5144 }
5145 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5146 {
5147 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5148 fWeightChange = VOS_TRUE;
5149 }
5150 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5151 {
5152 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5153 fWeightChange = VOS_TRUE;
5154 }
5155 if(fWeightChange)
5156 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005157 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005158 bACWeights[2], bACWeights[3]);
5159 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5160 }
5161 }
5162}
Jeff Johnson295189b2012-06-20 16:38:30 -07005163#ifdef WLAN_FEATURE_VOWIFI_11R
5164//Returns whether the current association is a 11r assoc or not
5165tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5166{
5167#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5168 return csrNeighborRoamIs11rAssoc(pMac);
5169#else
5170 return eANI_BOOLEAN_FALSE;
5171#endif
5172}
5173#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005174#ifdef FEATURE_WLAN_ESE
5175//Returns whether the current association is a ESE assoc or not
5176tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005177{
5178#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005179 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005180#else
5181 return eANI_BOOLEAN_FALSE;
5182#endif
5183}
5184#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005185#ifdef FEATURE_WLAN_LFR
5186//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305187tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005188{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305189 tCsrRoamSession *pSession = NULL;
5190
5191 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5192 {
5193 pSession = CSR_GET_SESSION( pMac, sessionId );
5194 if (NULL != pSession->pCurRoamProfile)
5195 {
5196 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5197 {
5198 return eANI_BOOLEAN_FALSE;
5199 }
5200 }
5201 }
5202
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005203#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5204 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5205 {
5206 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5207 }
5208 else
5209#endif
5210 {
5211 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005212 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005213 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005214}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005215
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005216#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005217/* ---------------------------------------------------------------------------
5218
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005219 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005220
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005221 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005222
5223 \param pMac - The handle returned by macOpen.
5224
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005225 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005226
5227---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005228tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005229{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005230 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005231}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005232#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005233
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005234#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5235//Returns whether "FW based BG scan" is currently enabled...or not
5236tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5237{
5238 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5239}
5240#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005241#endif
5242
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005243#if defined(FEATURE_WLAN_ESE)
5244tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005245{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005246 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005247}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005248#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005249
Jeff Johnson295189b2012-06-20 16:38:30 -07005250//Return true means the command can be release, else not
5251static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5252 eCsrRoamCompleteResult Result, void *Context )
5253{
5254 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5255 tSirBssDescription *pSirBssDesc = NULL;
5256 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5257 tCsrScanResult *pScanResult = NULL;
5258 tCsrRoamInfo roamInfo;
5259 sme_QosAssocInfo assocInfo;
5260 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5261 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5262 tDot11fBeaconIEs *pIes = NULL;
5263 tANI_U32 sessionId = pCommand->sessionId;
5264 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5265 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5266 eRoamCmdStatus roamStatus;
5267 eCsrRoamResult roamResult;
5268 eHalStatus status;
5269 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005270 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005271
Jeff Johnson32d95a32012-09-10 13:15:23 -07005272 if(!pSession)
5273 {
5274 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5275 return eANI_BOOLEAN_FALSE;
5276 }
5277
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005278 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005279 switch( Result )
5280 {
5281 case eCsrJoinSuccess:
5282 // reset the IDLE timer
5283 // !!
5284 // !! fall through to the next CASE statement here is intentional !!
5285 // !!
5286 case eCsrReassocSuccess:
5287 if(eCsrReassocSuccess == Result)
5288 {
5289 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5290 }
5291 else
5292 {
5293 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5294 }
5295 // Success Join Response from LIM. Tell NDIS we are connected and save the
5296 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005297 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305298 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 //always free the memory here
5300 if(pSession->pWpaRsnRspIE)
5301 {
5302 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305303 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005304 pSession->pWpaRsnRspIE = NULL;
5305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005306#ifdef FEATURE_WLAN_WAPI
5307 if(pSession->pWapiRspIE)
5308 {
5309 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305310 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005311 pSession->pWapiRspIE = NULL;
5312 }
5313#endif /* FEATURE_WLAN_WAPI */
5314#ifdef FEATURE_WLAN_BTAMP_UT_RF
5315 //Reset counter so no join retry is needed.
5316 pSession->maxRetryCount = 0;
5317 csrRoamStopJoinRetryTimer(pMac, sessionId);
5318#endif
5319 /* This creates problem since we have not saved the connected profile.
5320 So moving this after saving the profile
5321 */
5322 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305323
5324 /* Reset remainInPowerActiveTillDHCP as it might have been set
5325 * by last failed secured connection.
5326 * It should be set only for secured connection.
5327 */
5328 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5330 {
5331 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5332 }
5333 else
5334 {
5335 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5336 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005337 //Use the last connected bssdesc for reassoc-ing to the same AP.
5338 //NOTE: What to do when reassoc to a different AP???
5339 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5340 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5341 {
5342 pSirBssDesc = pSession->pConnectBssDesc;
5343 if(pSirBssDesc)
5344 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305345 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5346 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 }
5348 }
5349 else
5350 {
5351
5352 if(pCommand->u.roamCmd.pRoamBssEntry)
5353 {
5354 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5355 if(pScanResult != NULL)
5356 {
5357 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5358 //this can be NULL
5359 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305360 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5361 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005362 }
5363 }
5364 }
5365 if( pSirBssDesc )
5366 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005367 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005368 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5369 //Save WPA/RSN IE
5370 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005371#ifdef FEATURE_WLAN_ESE
5372 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005373#endif
5374
5375 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5376 // substate change.
5377 // Moving even save profile above so that below mentioned conditon is also met.
5378 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5379 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005380 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5381 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5382 // will be dropped for the security context may not be set properly.
5383 //
5384 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5385 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5386 //
5387 // this reordering was done on titan_prod_usb branch and is being replicated here.
5388 //
5389
5390 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5391 !pProfile->bWPSAssociation)
5392 {
5393 // Issue the set Context request to LIM to establish the Unicast STA context
5394 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5395 pProfile->negotiatedUCEncryptionType,
5396 pSirBssDesc, &(pSirBssDesc->bssId),
5397 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5398 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005399 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005400 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5401 }
5402 // Issue the set Context request to LIM to establish the Broadcast STA context
5403 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5404 pSirBssDesc, &BroadcastMac,
5405 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5406 }
5407 else
5408 {
5409 //Need to wait for supplicant authtication
5410 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 //Set the subestate to WaitForKey in case authentiation is needed
5412 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5413
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 if(pProfile->bWPSAssociation)
5415 {
5416 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5417 }
5418 else
5419 {
5420 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5421 }
5422
5423 //Save sessionId in case of timeout
5424 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5425 //This time should be long enough for the rest of the process plus setting key
5426 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5427 {
5428 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005429 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5431 }
5432 }
5433
5434 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5435 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005436 if(Context)
5437 {
5438 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5439 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5441 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5442#ifdef WLAN_FEATURE_VOWIFI_11R
5443 len += pJoinRsp->parsedRicRspLen;
5444#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005445#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005446 len += pJoinRsp->tspecIeLen;
5447#endif
5448 if(len)
5449 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305450 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5451 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005452 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305453 vos_mem_copy(pSession->connectedInfo.pbFrames,
5454 pJoinRsp->frames, len);
5455 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5456 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5457 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005458#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305459 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005460#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005461#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305462 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005463#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305464 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5465 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5466 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5467 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 }
5469 }
5470 if(pCommand->u.roamCmd.fReassoc)
5471 {
5472 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5473 }
5474 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5475 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5476 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5477 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305478 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 }
5480 else
5481 {
5482 if(pCommand->u.roamCmd.fReassoc)
5483 {
5484 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5485 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5486 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5487 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5488 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5489 }
5490 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305491 /* Update the staId from the previous connected profile info
5492 as the reassociation is triggred at SME/HDD */
5493 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5494 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5495 {
5496 roamInfo.staId = pSession->connectedInfo.staId;
5497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005498#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5499 // Indicate SME-QOS with reassoc success event, only after
5500 // copying the frames
5501 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5502#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005503 roamInfo.pBssDesc = pSirBssDesc;
5504 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5505 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5506#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5507 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5508#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5509 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5511 //It may be better to let QoS do this????
5512 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5513 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005514 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005515 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5516 pmcStartUapsd( pMac, NULL, NULL );
5517 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305518 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5520 if( pSession->bRefAssocStartCnt > 0 )
5521 {
5522 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005523 //Remove this code once SLM_Sessionization is supported
5524 //BMPS_WORKAROUND_NOT_NEEDED
5525 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005526 {
5527 pMac->roam.configParam.doBMPSWorkaround = 1;
5528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005529 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5530 }
5531
5532 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 // reset the PMKID candidate list
5534 csrResetPMKIDCandidateList( pMac, sessionId );
5535 //Update TL's AC weight base on the current EDCA parameters
5536 //These parameters may change in the course of the connection, that sictuation
5537 //is not taken care here. This change is mainly to address a WIFI WMM test where
5538 //BE has a equal or higher TX priority than VI.
5539 //We only do this for infra link
5540 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5541 {
5542 csrCheckAndUpdateACWeight(pMac, pIes);
5543 }
5544#ifdef FEATURE_WLAN_WAPI
5545 // reset the BKID candidate list
5546 csrResetBKIDCandidateList( pMac, sessionId );
5547#endif /* FEATURE_WLAN_WAPI */
5548 }
5549 else
5550 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005551 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 csrScanCancelIdleScan(pMac);
5554 //Not to signal link up because keys are yet to be set.
5555 //The linkup function will overwrite the sub-state that we need to keep at this point.
5556 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5557 {
5558 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5559 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005560 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5561 //enough to let security and DHCP handshake succeed before entry into BMPS
5562 if (pmcShouldBmpsTimerRun(pMac))
5563 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305564 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5565 * until keys are set before going into BMPS.
5566 */
5567 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5568 {
5569 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5570 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5571 "to make sure we wait until keys are set before"
5572 " going to BMPS"));
5573 }
5574
Jeff Johnson295189b2012-06-20 16:38:30 -07005575 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5576 != eHAL_STATUS_SUCCESS)
5577 {
5578 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5579 }
5580 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005582 break;
5583
Jeff Johnson295189b2012-06-20 16:38:30 -07005584 case eCsrStartBssSuccess:
5585 // on the StartBss Response, LIM is returning the Bss Description that we
5586 // are beaconing. Add this Bss Description to our scan results and
5587 // chain the Profile to this Bss Description. On a Start BSS, there was no
5588 // detected Bss description (no partner) so we issued the Start Bss to
5589 // start the Ibss without any Bss description. Lim was kind enough to return
5590 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005591 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005592 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005593 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305594 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 if( CSR_IS_IBSS( pProfile ) )
5596 {
5597 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5598 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005599 else if (CSR_IS_INFRA_AP(pProfile))
5600 {
5601 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5602 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005603 else
5604 {
5605 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5606 }
5607 if( !CSR_IS_WDS_STA( pProfile ) )
5608 {
5609 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005611 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5612 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305613 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 roamInfo.pBssDesc = pSirBssDesc;
5615 //We need to associate_complete it first, becasue Associate_start already indicated.
5616 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5617 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5618 break;
5619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005621 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005622 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005623 }
5624 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5625 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5626 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5627 if(pSirBssDesc)
5628 {
5629 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305630 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5631 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 }
5633 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305634 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005635#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5636 {
5637 vos_log_ibss_pkt_type *pIbssLog;
5638 tANI_U32 bi;
5639
5640 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5641 if(pIbssLog)
5642 {
5643 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5644 {
5645 //We start the IBSS (didn't find any matched IBSS out there)
5646 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5647 }
5648 else
5649 {
5650 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5651 }
5652 if(pSirBssDesc)
5653 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305654 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5656 }
5657 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5658 {
5659 //***U8 is not enough for beacon interval
5660 pIbssLog->beaconInterval = (v_U8_t)bi;
5661 }
5662 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5663 }
5664 }
5665#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5666 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5667 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005668 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5669 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5671 csrRoamIssueSetContextReq( pMac, sessionId,
5672 pProfile->negotiatedMCEncryptionType,
5673 pSirBssDesc, &BroadcastMac,
5674 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5675 }
5676 }
5677 else
5678 {
5679 //Keep the state to eCSR_ROAMING_STATE_JOINING
5680 //Need to send join_req.
5681 if(pCommand->u.roamCmd.pRoamBssEntry)
5682 {
5683 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5684 {
5685 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5686 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5687 // Set the roaming substate to 'join attempt'...
5688 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005689 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 }
5691 }
5692 else
5693 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005694 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005695 VOS_ASSERT( 0 );
5696 }
5697 }
5698 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5699 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5700 //trigger the connection start indication in Vista
5701 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5702 {
5703 roamStatus = eCSR_ROAM_IBSS_IND;
5704 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5705 if( CSR_IS_WDS( pProfile ) )
5706 {
5707 roamStatus = eCSR_ROAM_WDS_IND;
5708 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5709 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005710 if( CSR_IS_INFRA_AP( pProfile ) )
5711 {
5712 roamStatus = eCSR_ROAM_INFRA_IND;
5713 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005715
5716 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5717 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5718 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305719 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5721 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005722 //We start the IBSS (didn't find any matched IBSS out there)
5723 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305725 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5726 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005727 //Remove this code once SLM_Sessionization is supported
5728 //BMPS_WORKAROUND_NOT_NEEDED
5729 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005730 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005731 {
5732 pMac->roam.configParam.doBMPSWorkaround = 1;
5733 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005734
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5736 }
5737
5738 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005739
5740 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005741 {
5742 //need to send stop BSS because we fail to send join_req
5743 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5744 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5745 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5746 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005747 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 case eCsrStartBssFailure:
5749#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5750 {
5751 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5753 if(pIbssLog)
5754 {
5755 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5756 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5757 }
5758 }
5759#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005760 roamStatus = eCSR_ROAM_IBSS_IND;
5761 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5762 if( CSR_IS_WDS( pProfile ) )
5763 {
5764 roamStatus = eCSR_ROAM_WDS_IND;
5765 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5766 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005767 if( CSR_IS_INFRA_AP( pProfile ) )
5768 {
5769 roamStatus = eCSR_ROAM_INFRA_IND;
5770 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005772 if(Context)
5773 {
5774 pSirBssDesc = (tSirBssDescription *)Context;
5775 }
5776 else
5777 {
5778 pSirBssDesc = NULL;
5779 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305780 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 roamInfo.pBssDesc = pSirBssDesc;
5782 //We need to associate_complete it first, becasue Associate_start already indicated.
5783 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5784 csrSetDefaultDot11Mode( pMac );
5785 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 case eCsrSilentlyStopRoaming:
5787 // We are here because we try to start the same IBSS
5788 //No message to PE
5789 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005790 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005791 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5792 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305793 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005794 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5795 if( roamInfo.pBssDesc )
5796 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305797 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5798 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 }
5800 //Since there is no change in the current state, simply pass back no result otherwise
5801 //HDD may be mistakenly mark to disconnected state.
5802 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5803 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 case eCsrSilentlyStopRoamingSaveState:
5806 //We are here because we try to connect to the same AP
5807 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005808 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305809 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005810
5811 //to aviod resetting the substate to NONE
5812 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5813 //No need to change substate to wai_for_key because there is no state change
5814 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5815 if( roamInfo.pBssDesc )
5816 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305817 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5818 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5821 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5822 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5823 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5824 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5825 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5826 roamInfo.staId = pSession->connectedInfo.staId;
5827 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005829 pSession->bRefAssocStartCnt--;
5830 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5831 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5832 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5833 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 case eCsrReassocFailure:
5835#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5836 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5837#endif
5838 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005839 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 csrFreeConnectBssDesc(pMac, sessionId);
5841 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5842 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305843 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005844 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5845 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5846 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5847 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5848 eCSR_ROAM_WDS_IND,
5849 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5850 //Need to issue stop_bss
5851 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 case eCsrJoinFailure:
5853 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005854 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 default:
5856 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005857 smsLog(pMac, LOGW, FL("receives no association indication"));
5858 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005859 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005860 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5861 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5862 {
5863 //do not free for the other profiles as we need to send down stop BSS later
5864 csrFreeConnectBssDesc(pMac, sessionId);
5865 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5866 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5867 csrSetDefaultDot11Mode( pMac );
5868 }
5869
5870 switch( pCommand->u.roamCmd.roamReason )
5871 {
5872 // If this transition is because of an 802.11 OID, then we transition
5873 // back to INIT state so we sit waiting for more OIDs to be issued and
5874 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005875 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 case eCsrSmeIssuedAssocToSimilarAP:
5877 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005878 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305880 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5882 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5883 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305884 vos_mem_copy(&roamInfo.bssid,
5885 &pSession->joinFailStatusCode.bssId,
5886 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005887
Jeff Johnson295189b2012-06-20 16:38:30 -07005888 /* Defeaturize this later if needed */
5889#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5890 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5891 if (csrRoamIsHandoffInProgress(pMac))
5892 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 /* Should indicate neighbor roam algorithm about the connect failure here */
5894 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005896#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005897 if(pSession->bRefAssocStartCnt > 0)
5898 {
5899 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005900 if(eCsrJoinFailureDueToConcurrency == Result)
5901 {
5902 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5903 eCSR_ROAM_ASSOCIATION_COMPLETION,
5904 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5905 }
5906 else
5907 {
5908 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005909 eCSR_ROAM_ASSOCIATION_COMPLETION,
5910 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005911 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005913 else
5914 {
5915 /* bRefAssocStartCnt is not incremented when
5916 * eRoamState == eCsrStopRoamingDueToConcurrency
5917 * in csrRoamJoinNextBss API. so handle this in
5918 * else case by sending assoc failure
5919 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005920 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005921 pCommand->u.scanCmd.roamId,
5922 eCSR_ROAM_ASSOCIATION_FAILURE,
5923 eCSR_ROAM_RESULT_FAILURE);
5924 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005925 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005926#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05305927 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5929#endif
5930 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5931 csrScanStartIdleScan(pMac);
5932#ifdef FEATURE_WLAN_BTAMP_UT_RF
5933 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5934 //BT activity and not able to recevie WLAN traffic. Retry the join
5935 if( CSR_IS_WDS_STA(pProfile) )
5936 {
5937 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5938 }
5939#endif
5940 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 case eCsrHddIssuedReassocToSameAP:
5942 case eCsrSmeIssuedReassocToSameAP:
5943 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5944
5945 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5946#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5947 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5948#endif
5949 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5950 csrScanStartIdleScan(pMac);
5951 break;
5952 case eCsrForcedDisassoc:
5953 case eCsrForcedDeauth:
5954 case eCsrSmeIssuedIbssJoinFailure:
5955 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5956
5957 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5958 {
5959 // Notify HDD that IBSS join failed
5960 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5961 }
5962 else
5963 {
5964 csrRoamCallCallback(pMac, sessionId, NULL,
5965 pCommand->u.roamCmd.roamId,
5966 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5967 }
5968#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5969 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5970#endif
5971 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08005972 /*
5973 *DelSta not done FW still in conneced state so dont
5974 *issue IMPS req
5975 */
5976 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
5977 {
5978 smsLog(pMac, LOGW, FL("FW still in connected state "));
5979 break;
5980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 csrScanStartIdleScan(pMac);
5982 break;
5983 case eCsrForcedIbssLeave:
5984 csrRoamCallCallback(pMac, sessionId, NULL,
5985 pCommand->u.roamCmd.roamId,
5986 eCSR_ROAM_IBSS_LEAVE,
5987 eCSR_ROAM_RESULT_IBSS_STOP);
5988 break;
5989 case eCsrForcedDisassocMICFailure:
5990 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5991
5992 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5993#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5994 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5995#endif
5996 csrScanStartIdleScan(pMac);
5997 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 case eCsrStopBss:
5999 csrRoamCallCallback(pMac, sessionId, NULL,
6000 pCommand->u.roamCmd.roamId,
6001 eCSR_ROAM_INFRA_IND,
6002 eCSR_ROAM_RESULT_INFRA_STOPPED);
6003 break;
6004 case eCsrForcedDisassocSta:
6005 case eCsrForcedDeauthSta:
6006 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
6007 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
6008 {
6009 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006010
6011 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6012 {
6013 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05306014 vos_mem_copy(roamInfo.peerMac,
6015 pCommand->u.roamCmd.peerMac,
6016 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07006017 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6018 roamInfo.statusCode = eSIR_SME_SUCCESS;
6019 status = csrRoamCallCallback(pMac, sessionId,
6020 &roamInfo, pCommand->u.roamCmd.roamId,
6021 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
6022 }
6023 }
6024 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 case eCsrLostLink1:
6026 // if lost link roam1 failed, then issue lost link Scan2 ...
6027 csrScanRequestLostLink2(pMac, sessionId);
6028 break;
6029 case eCsrLostLink2:
6030 // if lost link roam2 failed, then issue lost link scan3 ...
6031 csrScanRequestLostLink3(pMac, sessionId);
6032 break;
6033 case eCsrLostLink3:
6034 default:
6035 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6036
6037 //We are done with one round of lostlink roaming here
6038 csrScanHandleFailedLostlink3(pMac, sessionId);
6039 break;
6040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 break;
6042 }
6043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 return ( fReleaseCommand );
6045}
6046
Jeff Johnson295189b2012-06-20 16:38:30 -07006047eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6048{
6049 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006050 return (status);
6051}
6052
Jeff Johnson295189b2012-06-20 16:38:30 -07006053eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6054{
6055 eHalStatus status = eHAL_STATUS_SUCCESS;
6056 tANI_U32 size = 0;
6057
6058 do
6059 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306060 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6062 {
6063 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306064 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6065 if ( NULL == pDstProfile->BSSIDs.bssid )
6066 status = eHAL_STATUS_FAILURE;
6067 else
6068 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 if(!HAL_STATUS_SUCCESS(status))
6070 {
6071 break;
6072 }
6073 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306074 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6075 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 }
6077 if(pSrcProfile->SSIDs.numOfSSIDs)
6078 {
6079 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306080 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6081 if ( NULL == pDstProfile->SSIDs.SSIDList )
6082 status = eHAL_STATUS_FAILURE;
6083 else
6084 status = eHAL_STATUS_SUCCESS;
6085 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 {
6087 break;
6088 }
6089 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306090 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6091 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 }
6093 if(pSrcProfile->nWPAReqIELength)
6094 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306095 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6096 if ( NULL == pDstProfile->pWPAReqIE )
6097 status = eHAL_STATUS_FAILURE;
6098 else
6099 status = eHAL_STATUS_SUCCESS;
6100
6101 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 {
6103 break;
6104 }
6105 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306106 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6107 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006108 }
6109 if(pSrcProfile->nRSNReqIELength)
6110 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306111 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6112 if ( NULL == pDstProfile->pRSNReqIE )
6113 status = eHAL_STATUS_FAILURE;
6114 else
6115 status = eHAL_STATUS_SUCCESS;
6116
6117 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006118 {
6119 break;
6120 }
6121 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306122 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6123 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 }
6125#ifdef FEATURE_WLAN_WAPI
6126 if(pSrcProfile->nWAPIReqIELength)
6127 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306128 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6129 if ( NULL == pDstProfile->pWAPIReqIE )
6130 status = eHAL_STATUS_FAILURE;
6131 else
6132 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006133 if(!HAL_STATUS_SUCCESS(status))
6134 {
6135 break;
6136 }
6137 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306138 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6139 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 }
6141#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 if(pSrcProfile->nAddIEScanLength)
6143 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306144 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6145 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306147 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306148 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306149 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6150 }
6151 else
6152 {
6153 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6154 FL(" AddIEScanLength is not valid %u"),
6155 pSrcProfile->nAddIEScanLength);
6156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006158 if(pSrcProfile->nAddIEAssocLength)
6159 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306160 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6161 if ( NULL == pDstProfile->pAddIEAssoc )
6162 status = eHAL_STATUS_FAILURE;
6163 else
6164 status = eHAL_STATUS_SUCCESS;
6165
Jeff Johnson295189b2012-06-20 16:38:30 -07006166 if(!HAL_STATUS_SUCCESS(status))
6167 {
6168 break;
6169 }
6170 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306171 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6172 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 if(pSrcProfile->ChannelInfo.ChannelList)
6175 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306176 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6177 pSrcProfile->ChannelInfo.numOfChannels);
6178 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6179 status = eHAL_STATUS_FAILURE;
6180 else
6181 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006182 if(!HAL_STATUS_SUCCESS(status))
6183 {
6184 break;
6185 }
6186 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306187 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6188 pSrcProfile->ChannelInfo.ChannelList,
6189 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 pDstProfile->AuthType = pSrcProfile->AuthType;
6192 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6193 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6194 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6195 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6196 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006197#ifdef WLAN_FEATURE_11W
6198 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6199 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6200 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6201#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006202 pDstProfile->BSSType = pSrcProfile->BSSType;
6203 pDstProfile->phyMode = pSrcProfile->phyMode;
6204 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6205
6206#ifdef FEATURE_WLAN_WAPI
6207 if(csrIsProfileWapi(pSrcProfile))
6208 {
6209 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6210 {
6211 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6212 }
6213 }
6214#endif /* FEATURE_WLAN_WAPI */
6215 pDstProfile->CBMode = pSrcProfile->CBMode;
6216 /*Save the WPS info*/
6217 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006218 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 pDstProfile->privacy = pSrcProfile->privacy;
6222 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6223 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6224 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6225 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6226 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6227 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6228 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6229 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6230 pDstProfile->wps_state = pSrcProfile->wps_state;
6231 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306232 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6233 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006234#ifdef WLAN_FEATURE_VOWIFI_11R
6235 if (pSrcProfile->MDID.mdiePresent)
6236 {
6237 pDstProfile->MDID.mdiePresent = 1;
6238 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6239 }
6240#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006241 }while(0);
6242
6243 if(!HAL_STATUS_SUCCESS(status))
6244 {
6245 csrReleaseProfile(pMac, pDstProfile);
6246 pDstProfile = NULL;
6247 }
6248
6249 return (status);
6250}
Jeff Johnson295189b2012-06-20 16:38:30 -07006251eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6252{
6253 eHalStatus status = eHAL_STATUS_SUCCESS;
6254 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6255 do
6256 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306257 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 if(pSrcProfile->bssid)
6259 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306260 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6261 if ( NULL == pDstProfile->BSSIDs.bssid )
6262 status = eHAL_STATUS_FAILURE;
6263 else
6264 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006265 if(!HAL_STATUS_SUCCESS(status))
6266 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306267 smsLog( pMac, LOGE,
6268 FL("failed to allocate memory for BSSID"
6269 "%02x:%02x:%02x:%02x:%02x:%02x"),
6270 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6271 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006272 break;
6273 }
6274 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306275 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6276 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006277 }
6278 if(pSrcProfile->SSID.ssId)
6279 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306280 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6281 if ( NULL == pDstProfile->SSIDs.SSIDList )
6282 status = eHAL_STATUS_FAILURE;
6283 else
6284 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 if(!HAL_STATUS_SUCCESS(status))
6286 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306287 smsLog( pMac, LOGE,
6288 FL("failed to allocate memory for SSIDList"
6289 "%02x:%02x:%02x:%02x:%02x:%02x"),
6290 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6291 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 break;
6293 }
6294 pDstProfile->SSIDs.numOfSSIDs = 1;
6295 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6296 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306297 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6298 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006300 if(pSrcProfile->nAddIEAssocLength)
6301 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306302 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6303 if ( NULL == pDstProfile->pAddIEAssoc)
6304 status = eHAL_STATUS_FAILURE;
6305 else
6306 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006307 if(!HAL_STATUS_SUCCESS(status))
6308 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006309 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006310 break;
6311 }
6312 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306313 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6314 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006315 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306316 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6317 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6318 status = eHAL_STATUS_FAILURE;
6319 else
6320 status = eHAL_STATUS_SUCCESS;
6321
Jeff Johnson295189b2012-06-20 16:38:30 -07006322 if(!HAL_STATUS_SUCCESS(status))
6323 {
6324 break;
6325 }
6326 pDstProfile->ChannelInfo.numOfChannels = 1;
6327 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006328 pDstProfile->AuthType.numEntries = 1;
6329 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6330 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6331 pDstProfile->EncryptionType.numEntries = 1;
6332 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6333 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6334 pDstProfile->mcEncryptionType.numEntries = 1;
6335 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6336 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6337 pDstProfile->BSSType = pSrcProfile->BSSType;
6338 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306339 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6340 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006341#ifdef WLAN_FEATURE_VOWIFI_11R
6342 if (pSrcProfile->MDID.mdiePresent)
6343 {
6344 pDstProfile->MDID.mdiePresent = 1;
6345 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6346 }
6347#endif
6348
6349 }while(0);
6350
6351 if(!HAL_STATUS_SUCCESS(status))
6352 {
6353 csrReleaseProfile(pMac, pDstProfile);
6354 pDstProfile = NULL;
6355 }
6356
6357 return (status);
6358}
6359
Jeff Johnson295189b2012-06-20 16:38:30 -07006360eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6361 tScanResultHandle hBSSList,
6362 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6363 tANI_BOOLEAN fClearScan)
6364{
6365 eHalStatus status = eHAL_STATUS_SUCCESS;
6366 tSmeCmd *pCommand;
6367
6368 pCommand = csrGetCommandBuffer(pMac);
6369 if(NULL == pCommand)
6370 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006371 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 status = eHAL_STATUS_RESOURCES;
6373 }
6374 else
6375 {
6376 if( fClearScan )
6377 {
6378 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306379 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006380 }
6381 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6382 if(NULL == pProfile)
6383 {
6384 //We can roam now
6385 //Since pProfile is NULL, we need to build our own profile, set everything to default
6386 //We can only support open and no encryption
6387 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6388 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6389 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6390 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6391 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6392 }
6393 else
6394 {
6395 //make a copy of the profile
6396 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6397 if(HAL_STATUS_SUCCESS(status))
6398 {
6399 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6400 }
6401 }
6402 pCommand->command = eSmeCommandRoam;
6403 pCommand->sessionId = (tANI_U8)sessionId;
6404 pCommand->u.roamCmd.hBSSList = hBSSList;
6405 pCommand->u.roamCmd.roamId = roamId;
6406 pCommand->u.roamCmd.roamReason = reason;
6407 //We need to free the BssList when the command is done
6408 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6409 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6411 FL("CSR PERSONA=%d"),
6412 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6414 if( !HAL_STATUS_SUCCESS( status ) )
6415 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006416 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 csrReleaseCommandRoam( pMac, pCommand );
6418 }
6419 }
6420
6421 return (status);
6422}
Jeff Johnson295189b2012-06-20 16:38:30 -07006423eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6424 tCsrRoamModifyProfileFields *pMmodProfileFields,
6425 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6426{
6427 eHalStatus status = eHAL_STATUS_SUCCESS;
6428 tSmeCmd *pCommand;
6429
6430 pCommand = csrGetCommandBuffer(pMac);
6431 if(NULL == pCommand)
6432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006433 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 status = eHAL_STATUS_RESOURCES;
6435 }
6436 else
6437 {
6438 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306439 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 if(pProfile)
6441 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006442 //This is likely trying to reassoc to different profile
6443 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6444 //make a copy of the profile
6445 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6446 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006447 }
6448 else
6449 {
6450 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6451 //how to update WPA/WPA2 info in roamProfile??
6452 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 if(HAL_STATUS_SUCCESS(status))
6455 {
6456 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6457 }
6458 pCommand->command = eSmeCommandRoam;
6459 pCommand->sessionId = (tANI_U8)sessionId;
6460 pCommand->u.roamCmd.roamId = roamId;
6461 pCommand->u.roamCmd.roamReason = reason;
6462 //We need to free the BssList when the command is done
6463 //For reassoc there is no BSS list, so the boolean set to false
6464 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6465 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6466 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6468 if( !HAL_STATUS_SUCCESS( status ) )
6469 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006470 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6472 csrReleaseCommandRoam( pMac, pCommand );
6473 }
6474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 return (status);
6476}
6477
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006478eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6479 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306480// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006481{
6482 eHalStatus status = eHAL_STATUS_SUCCESS;
6483 tSmeCmd *pCommand;
6484
6485 pCommand = csrGetCommandBuffer(pMac);
6486 if(NULL == pCommand)
6487 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006488 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006489 status = eHAL_STATUS_RESOURCES;
6490 }
6491 else
6492 {
6493 if(pBssDescription)
6494 {
6495 //copy over the parameters we need later
6496 pCommand->command = eSmeCommandRoam;
6497 pCommand->sessionId = (tANI_U8)sessionId;
6498 pCommand->u.roamCmd.roamReason = reason;
6499 //this is the important parameter
6500 //in this case we are using this field for the "next" BSS
6501 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6502 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6503 if( !HAL_STATUS_SUCCESS( status ) )
6504 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006505 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006506 csrReleaseCommandPreauth( pMac, pCommand );
6507 }
6508 }
6509 else
6510 {
6511 //Return failure
6512 status = eHAL_STATUS_RESOURCES;
6513 }
6514 }
6515 return (status);
6516}
6517
6518eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6519{
6520 tListElem *pEntry;
6521 tSmeCmd *pCommand;
6522 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6523 if ( pEntry )
6524 {
6525 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6526 if ( (eSmeCommandRoam == pCommand->command) &&
6527 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6528 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006529 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006530 pCommand->command, pCommand->u.roamCmd.roamReason);
6531 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6532 csrReleaseCommandPreauth( pMac, pCommand );
6533 }
6534 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006535 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006536 pCommand->command, pCommand->u.roamCmd.roamReason);
6537 }
6538 }
6539 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006540 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006541 }
6542 smeProcessPendingQueue( pMac );
6543 return eHAL_STATUS_SUCCESS;
6544}
6545
Jeff Johnson295189b2012-06-20 16:38:30 -07006546eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6547 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6548{
6549 eHalStatus status = eHAL_STATUS_FAILURE;
6550 tScanResultHandle hBSSList;
6551 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006552 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6553 if(HAL_STATUS_SUCCESS(status))
6554 {
6555 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6556 if(pRoamId)
6557 {
6558 *pRoamId = roamId;
6559 }
6560 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6561 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6562 if(!HAL_STATUS_SUCCESS(status))
6563 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006564 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006565 csrScanResultPurge(pMac, hBSSList);
6566 }
6567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006568 return (status);
6569}
6570
Jeff Johnson295189b2012-06-20 16:38:30 -07006571eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6572 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6573{
6574 eHalStatus status = eHAL_STATUS_SUCCESS;
6575 tScanResultHandle hBSSList;
6576 tCsrScanResultFilter *pScanFilter;
6577 tANI_U32 roamId = 0;
6578 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6579 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006580 if (NULL == pProfile)
6581 {
6582 smsLog(pMac, LOGP, FL("No profile specified"));
6583 return eHAL_STATUS_FAILURE;
6584 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306585 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6586 "encryType = %d"),
6587 lim_BssTypetoString(pProfile->BSSType),
6588 pProfile->BSSType,
6589 pProfile->AuthType.authType[0],
6590 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006591 if( CSR_IS_WDS( pProfile ) &&
6592 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006594 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006595 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006596 return status;
6597 }
6598 csrRoamCancelRoaming(pMac, sessionId);
6599 csrScanRemoveFreshScanCommand(pMac, sessionId);
6600 csrScanCancelIdleScan(pMac);
6601 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306602 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306603
6604 if (!vos_concurrent_open_sessions_running() &&
6605 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306607 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 csrScanDisable(pMac);
6609 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306610
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6612 //Check whether ssid changes
6613 if(csrIsConnStateConnected(pMac, sessionId))
6614 {
6615 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6616 {
6617 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6618 }
6619 }
6620#ifdef FEATURE_WLAN_BTAMP_UT_RF
6621 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6622#endif
6623 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6624 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006625 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006626 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6627 if(pRoamId)
6628 {
6629 roamId = *pRoamId;
6630 }
6631 if(!HAL_STATUS_SUCCESS(status))
6632 {
6633 fCallCallback = eANI_BOOLEAN_TRUE;
6634 }
6635 }
6636 else
6637 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306638 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6639 if ( NULL == pScanFilter )
6640 status = eHAL_STATUS_FAILURE;
6641 else
6642 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006643 if(HAL_STATUS_SUCCESS(status))
6644 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306645 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 //Try to connect to any BSS
6647 if(NULL == pProfile)
6648 {
6649 //No encryption
6650 pScanFilter->EncryptionType.numEntries = 1;
6651 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6652 }//we don't have a profile
6653 else
6654 {
6655 //Here is the profile we need to connect to
6656 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6657 }//We have a profile
6658 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6659 if(pRoamId)
6660 {
6661 *pRoamId = roamId;
6662 }
6663
6664 if(HAL_STATUS_SUCCESS(status))
6665 {
6666 /*Save the WPS info*/
6667 if(NULL != pProfile)
6668 {
6669 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006670 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006671 }
6672 else
6673 {
6674 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006675 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006677 do
6678 {
6679 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 )
6682 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006683 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006684 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6685 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6686 if(!HAL_STATUS_SUCCESS(status))
6687 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006688 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006689 fCallCallback = eANI_BOOLEAN_TRUE;
6690 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006691 else
6692 {
6693 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6694 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006695 break;
6696 }
6697 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006698 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006699 if(HAL_STATUS_SUCCESS(status))
6700 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006701 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6702 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6703 if(!HAL_STATUS_SUCCESS(status))
6704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006705 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006706 csrScanResultPurge(pMac, hBSSList);
6707 fCallCallback = eANI_BOOLEAN_TRUE;
6708 }
6709 }//Have scan result
6710 else if(NULL != pProfile)
6711 {
6712 //Check whether it is for start ibss
6713 if(CSR_IS_START_IBSS(pProfile))
6714 {
6715 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6716 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6717 if(!HAL_STATUS_SUCCESS(status))
6718 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006719 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006720 fCallCallback = eANI_BOOLEAN_TRUE;
6721 }
6722 }
6723 else
6724 {
6725 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006726 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006727 if(!HAL_STATUS_SUCCESS(status))
6728 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006729 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 fCallCallback = eANI_BOOLEAN_TRUE;
6731 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006732 else
6733 {
6734 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 }
6737 }
6738 else
6739 {
6740 fCallCallback = eANI_BOOLEAN_TRUE;
6741 }
6742 } while (0);
6743 if(NULL != pProfile)
6744 {
6745 //we need to free memory for filter if profile exists
6746 csrFreeScanFilter(pMac, pScanFilter);
6747 }
6748 }//Got the scan filter from profile
6749
Kiet Lam64c1b492013-07-12 13:56:44 +05306750 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 }//allocated memory for pScanFilter
6752 }//No Bsslist coming in
6753 //tell the caller if we fail to trigger a join request
6754 if( fCallCallback )
6755 {
6756 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6757 }
6758
6759 return (status);
6760}
Jeff Johnson295189b2012-06-20 16:38:30 -07006761eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6762 tCsrRoamModifyProfileFields modProfileFields,
6763 tANI_U32 *pRoamId)
6764{
6765 eHalStatus status = eHAL_STATUS_SUCCESS;
6766 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6767 tANI_U32 roamId = 0;
6768 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006769 if (NULL == pProfile)
6770 {
6771 smsLog(pMac, LOGP, FL("No profile specified"));
6772 return eHAL_STATUS_FAILURE;
6773 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306774 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6775 "encryType = %d"),
6776 lim_BssTypetoString(pProfile->BSSType),
6777 pProfile->BSSType,
6778 pProfile->AuthType.authType[0],
6779 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 csrRoamCancelRoaming(pMac, sessionId);
6781 csrScanRemoveFreshScanCommand(pMac, sessionId);
6782 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306783 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006784 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 if(csrIsConnStateConnected(pMac, sessionId))
6786 {
6787 if(pProfile)
6788 {
6789 if(pProfile->SSIDs.numOfSSIDs &&
6790 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6791 {
6792 fCallCallback = eANI_BOOLEAN_FALSE;
6793 }
6794 else
6795 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006796 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006797 }
6798 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306799 else if (!vos_mem_compare(&modProfileFields,
6800 &pSession->connectedProfile.modifyProfileFields,
6801 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 {
6803 fCallCallback = eANI_BOOLEAN_FALSE;
6804 }
6805 else
6806 {
6807 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006808 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006809 }
6810 }
6811 else
6812 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006813 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006815 if(!fCallCallback)
6816 {
6817 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6818 if(pRoamId)
6819 {
6820 *pRoamId = roamId;
6821 }
6822
Jeff Johnson295189b2012-06-20 16:38:30 -07006823 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6824 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006825 }
6826 else
6827 {
6828 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6829 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 return status;
6832}
Jeff Johnson295189b2012-06-20 16:38:30 -07006833eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6834{
6835 eHalStatus status = eHAL_STATUS_FAILURE;
6836 tScanResultHandle hBSSList = NULL;
6837 tCsrScanResultFilter *pScanFilter = NULL;
6838 tANI_U32 roamId;
6839 tCsrRoamProfile *pProfile = NULL;
6840 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006841
6842 if(!pSession)
6843 {
6844 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6845 return eHAL_STATUS_FAILURE;
6846 }
6847
Jeff Johnson295189b2012-06-20 16:38:30 -07006848 do
6849 {
6850 if(pSession->pCurRoamProfile)
6851 {
6852 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306853 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006854 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306855 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6856 if ( NULL == pProfile )
6857 status = eHAL_STATUS_FAILURE;
6858 else
6859 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006860 if(!HAL_STATUS_SUCCESS(status))
6861 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306862 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306864 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306866 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6867 if ( NULL == pScanFilter )
6868 status = eHAL_STATUS_FAILURE;
6869 else
6870 status = eHAL_STATUS_SUCCESS;
6871
Jeff Johnson295189b2012-06-20 16:38:30 -07006872 if(!HAL_STATUS_SUCCESS(status))
6873 {
6874 break;
6875 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306876 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6878 if(!HAL_STATUS_SUCCESS(status))
6879 {
6880 break;
6881 }
6882 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6883 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6884 if(HAL_STATUS_SUCCESS(status))
6885 {
6886 //we want to put the last connected BSS to the very beginning, if possible
6887 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6888 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6889 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6890 if(!HAL_STATUS_SUCCESS(status))
6891 {
6892 csrScanResultPurge(pMac, hBSSList);
6893 break;
6894 }
6895 }
6896 else
6897 {
6898 //Do a scan on this profile
6899 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006900 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006901 if(!HAL_STATUS_SUCCESS(status))
6902 {
6903 break;
6904 }
6905 }
6906 }//We have a profile
6907 else
6908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006909 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006910 break;
6911 }
6912 }while(0);
6913 if(pScanFilter)
6914 {
6915 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306916 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006917 }
6918 if(NULL != pProfile)
6919 {
6920 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306921 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006922 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006923 return (status);
6924}
Jeff Johnson295189b2012-06-20 16:38:30 -07006925eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6926{
6927 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006928 if(csrIsConnStateConnected(pMac, sessionId))
6929 {
6930 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6931 if(HAL_STATUS_SUCCESS(status))
6932 {
6933 status = csrRoamJoinLastProfile(pMac, sessionId);
6934 }
6935 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006936 return (status);
6937}
6938
Jeff Johnson295189b2012-06-20 16:38:30 -07006939eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6940{
6941 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006942 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006943 csrRoamCancelRoaming(pMac, sessionId);
6944 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6945 if(csrIsConnStateDisconnected(pMac, sessionId))
6946 {
6947 status = csrRoamJoinLastProfile(pMac, sessionId);
6948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006949 return (status);
6950}
6951
Jeff Johnson295189b2012-06-20 16:38:30 -07006952eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6953{
6954 eHalStatus status = eHAL_STATUS_SUCCESS;
6955 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6956 eCsrRoamSubState NewSubstate;
6957 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05306958
6959 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6960 {
6961 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
6962 " eCSR_ROAM_SUBSTATE_NONE"));
6963 csrRoamStopWaitForKeyTimer( pMac );
6964 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006966 // change state to 'Roaming'...
6967 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6968
6969 if ( csrIsConnStateIbss( pMac, sessionId ) )
6970 {
6971 // If we are in an IBSS, then stop the IBSS...
6972 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6973 fComplete = (!HAL_STATUS_SUCCESS(status));
6974 }
6975 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6976 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006977 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 -07006978 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6979 //Restore AC weight in case we change it
6980 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6981 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6982 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6983 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6984 {
6985 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6986 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05306987 else
6988 {
6989 // If we are in neighbor preauth done state then on receiving
6990 // disassoc or deauth we dont roam instead we just disassoc
6991 // from current ap and then go to disconnected state
6992 // This happens for ESE and 11r FT connections ONLY.
6993#ifdef WLAN_FEATURE_VOWIFI_11R
6994 if (csrRoamIs11rAssoc(pMac) &&
6995 (csrNeighborRoamStatePreauthDone(pMac)))
6996 {
6997 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6998 }
6999#endif
7000#ifdef FEATURE_WLAN_ESE
7001 if (csrRoamIsESEAssoc(pMac) &&
7002 (csrNeighborRoamStatePreauthDone(pMac)))
7003 {
7004 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7005 }
7006#endif
7007#ifdef FEATURE_WLAN_LFR
7008 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7009 (csrNeighborRoamStatePreauthDone(pMac)))
7010 {
7011 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7012 }
7013#endif
7014 }
7015
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 if( fDisassoc )
7017 {
7018 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307019#ifdef DEBUG_ROAM_DELAY
7020 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7021#endif /* DEBUG_ROAM_DELAY */
Jeff Johnson295189b2012-06-20 16:38:30 -07007022 }
7023 else
7024 {
7025 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7026 }
7027 fComplete = (!HAL_STATUS_SUCCESS(status));
7028 }
7029 else if ( csrIsConnStateWds( pMac, sessionId ) )
7030 {
7031 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7032 {
7033 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7034 fComplete = (!HAL_STATUS_SUCCESS(status));
7035 }
7036 //This has to be WDS station
7037 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7038 {
7039
7040 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7041 if( fDisassoc )
7042 {
7043 status = csrRoamIssueDisassociate( pMac, sessionId,
7044 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7045 fComplete = (!HAL_STATUS_SUCCESS(status));
7046 }
7047 }
7048 } else {
7049 // we got a dis-assoc request while not connected to any peer
7050 // just complete the command
7051 fComplete = eANI_BOOLEAN_TRUE;
7052 status = eHAL_STATUS_FAILURE;
7053 }
7054 if(fComplete)
7055 {
7056 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7057 }
7058
7059 if(HAL_STATUS_SUCCESS(status))
7060 {
7061 if ( csrIsConnStateInfra( pMac, sessionId ) )
7062 {
7063 //Set the state to disconnect here
7064 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7065 }
7066 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007067 else
7068 {
7069 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7070 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007071 return (status);
7072}
7073
Jeff Johnson295189b2012-06-20 16:38:30 -07007074/* This is been removed from latest code base */
7075/*
7076static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7077{
7078 eHalStatus status;
7079 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007080 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7081 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007082 return ( status );
7083}
7084*/
7085
Jeff Johnson295189b2012-06-20 16:38:30 -07007086eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7087{
7088 eHalStatus status = eHAL_STATUS_SUCCESS;
7089 tSmeCmd *pCommand;
7090 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007091 do
7092 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08007093 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007094 pCommand = csrGetCommandBuffer( pMac );
7095 if ( !pCommand )
7096 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007097 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007098 status = eHAL_STATUS_RESOURCES;
7099 break;
7100 }
7101 //Change the substate in case it is wait-for-key
7102 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7103 {
7104 csrRoamStopWaitForKeyTimer( pMac );
7105 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7106 }
7107 pCommand->command = eSmeCommandRoam;
7108 pCommand->sessionId = (tANI_U8)sessionId;
7109 switch ( reason )
7110 {
7111 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7112 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7113 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007114 case eCSR_DISCONNECT_REASON_DEAUTH:
7115 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7116 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007117 case eCSR_DISCONNECT_REASON_HANDOFF:
7118 fHighPriority = eANI_BOOLEAN_TRUE;
7119 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7120 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007121 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7122 case eCSR_DISCONNECT_REASON_DISASSOC:
7123 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7124 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007125 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7126 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7127 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007128 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7129 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7130 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 default:
7132 break;
7133 }
7134 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7135 if( !HAL_STATUS_SUCCESS( status ) )
7136 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007137 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007138 csrReleaseCommandRoam( pMac, pCommand );
7139 }
7140 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 return( status );
7142}
7143
Jeff Johnson295189b2012-06-20 16:38:30 -07007144eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7145{
7146 eHalStatus status = eHAL_STATUS_SUCCESS;
7147 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007148 pCommand = csrGetCommandBuffer( pMac );
7149 if ( NULL != pCommand )
7150 {
7151 //Change the substate in case it is wait-for-key
7152 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7153 {
7154 csrRoamStopWaitForKeyTimer( pMac );
7155 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7156 }
7157 pCommand->command = eSmeCommandRoam;
7158 pCommand->sessionId = (tANI_U8)sessionId;
7159 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7160 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7161 if( !HAL_STATUS_SUCCESS( status ) )
7162 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007163 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007164 csrReleaseCommandRoam( pMac, pCommand );
7165 }
7166 }
7167 else
7168 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007169 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007170 status = eHAL_STATUS_RESOURCES;
7171 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 return ( status );
7173}
7174
Jeff Johnson295189b2012-06-20 16:38:30 -07007175eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7176{
7177 eHalStatus status = eHAL_STATUS_SUCCESS;
7178 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007179
7180 if(!pSession)
7181 {
7182 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7183 return eHAL_STATUS_FAILURE;
7184 }
7185
Jeff Johnson295189b2012-06-20 16:38:30 -07007186#ifdef FEATURE_WLAN_BTAMP_UT_RF
7187 //Stop te retry
7188 pSession->maxRetryCount = 0;
7189 csrRoamStopJoinRetryTimer(pMac, sessionId);
7190#endif
7191 //Not to call cancel roaming here
7192 //Only issue disconnect when necessary
7193 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7194 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7195 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7196
7197 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007198 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007199 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7200 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307201 else
7202 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307203 csrScanAbortScanForSSID(pMac, sessionId);
7204 status = eHAL_STATUS_CMD_NOT_QUEUED;
7205 smsLog( pMac, LOG1, FL(" Disconnect cmd not queued, Roam command is not present"
7206 " return with status %d"), status);
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307207 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 return (status);
7209}
7210
Jeff Johnson295189b2012-06-20 16:38:30 -07007211eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7212{
7213 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007214
7215 if(!pSession)
7216 {
7217 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7218 return eHAL_STATUS_FAILURE;
7219 }
7220
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007222 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7223
7224 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7225}
7226
Jeff Johnson295189b2012-06-20 16:38:30 -07007227eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7228 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7229{
7230 eHalStatus status = eHAL_STATUS_SUCCESS;
7231 tDot11fBeaconIEs *pIesTemp = pIes;
7232 tANI_U8 index;
7233 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7234 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007235
7236 if(!pSession)
7237 {
7238 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7239 return eHAL_STATUS_FAILURE;
7240 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007241 if(pConnectProfile->pAddIEAssoc)
7242 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307243 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007244 pConnectProfile->pAddIEAssoc = NULL;
7245 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307246 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007247 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7248 pConnectProfile->AuthInfo = pProfile->AuthType;
7249 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7250 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7251 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7252 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7253 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7254 pConnectProfile->BSSType = pProfile->BSSType;
7255 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7256 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007257 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307258 if (!pConnectProfile->beaconInterval)
7259 {
7260 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7261 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307262 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007263 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7264 if(pProfile->nAddIEAssocLength)
7265 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307266 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7267 if ( NULL == pConnectProfile->pAddIEAssoc )
7268 status = eHAL_STATUS_FAILURE;
7269 else
7270 status = eHAL_STATUS_SUCCESS;
7271 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007272 {
7273 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7274 return eHAL_STATUS_FAILURE;
7275 }
7276 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307277 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7278 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007279 }
7280
Jeff Johnson295189b2012-06-20 16:38:30 -07007281 //Save bssid
7282 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7283#ifdef WLAN_FEATURE_VOWIFI_11R
7284 if (pSirBssDesc->mdiePresent)
7285 {
7286 pConnectProfile->MDID.mdiePresent = 1;
7287 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7288 }
7289#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007290 if( NULL == pIesTemp )
7291 {
7292 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7293 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007294#ifdef FEATURE_WLAN_ESE
7295 if ((csrIsProfileESE(pProfile) ||
7296 ((pIesTemp->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +05307297 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007298 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007299 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007300 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007301 }
7302#endif
7303 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007304 if(HAL_STATUS_SUCCESS(status))
7305 {
7306 if(pIesTemp->SSID.present)
7307 {
7308 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307309 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7310 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007311 }
7312
7313 //Save the bss desc
7314 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307315
7316 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007317 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307318 //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 -07007319 pConnectProfile->qap = TRUE;
7320 }
7321 else
7322 {
7323 pConnectProfile->qap = FALSE;
7324 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007325 if ( NULL == pIes )
7326 {
7327 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307328 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007329 }
7330 }
7331 //Save Qos connection
7332 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7333
7334 if(!HAL_STATUS_SUCCESS(status))
7335 {
7336 csrFreeConnectBssDesc(pMac, sessionId);
7337 }
7338 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7339 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307340 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7341 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7342 pConnectProfile->SSID.ssId,
7343 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007344 {
7345 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7346 break;
7347 }
7348 pConnectProfile->handoffPermitted = FALSE;
7349 }
7350
7351 return (status);
7352}
7353
Jeff Johnson295189b2012-06-20 16:38:30 -07007354static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7355{
7356 tListElem *pEntry = NULL;
7357 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007358 //The head of the active list is the request we sent
7359 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7360 if(pEntry)
7361 {
7362 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007364 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7365 {
7366 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7367 {
7368#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7369 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7370#endif
7371 }
7372 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7373 }
7374 else
7375 {
7376 tANI_U32 roamId = 0;
7377 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007378 if(!pSession)
7379 {
7380 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7381 return;
7382 }
7383
Jeff Johnson295189b2012-06-20 16:38:30 -07007384
7385 //The head of the active list is the request we sent
7386 //Try to get back the same profile and roam again
7387 if(pCommand)
7388 {
7389 roamId = pCommand->u.roamCmd.roamId;
7390 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007391 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7392 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007393 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007394#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7395 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7396 if (csrRoamIsHandoffInProgress(pMac))
7397 {
7398 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7399 /* Should indicate neighbor roam algorithm about the connect failure here */
7400 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7401 }
7402#endif
7403 if (pCommand)
7404 {
7405 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7406 {
7407 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7408 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7409 csrRoamReissueRoamCommand(pMac);
7410 }
7411 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7412 {
7413 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7414 }
7415 else
7416 {
7417 csrRoam(pMac, pCommand);
7418 }
7419 }
7420 else
7421 {
7422 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7423 }
7424 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7425}
7426
Jeff Johnson295189b2012-06-20 16:38:30 -07007427eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7428 tDot11fBeaconIEs *pIes,
7429 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7430{
7431 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007432 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7433 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007434
7435 // Set the roaming substate to 'join attempt'...
7436 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007437 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007438 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007439 return (status);
7440}
7441
Jeff Johnson295189b2012-06-20 16:38:30 -07007442static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7443 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7444{
7445 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007446 // Set the roaming substate to 'join attempt'...
7447 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7448
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307449 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7450 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307451#ifdef DEBUG_ROAM_DELAY
7452 //HACK usign buff len as Auth type
7453 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7454 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7455#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007456 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007457 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007458}
7459
Jeff Johnson295189b2012-06-20 16:38:30 -07007460void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7461{
7462 tListElem *pEntry;
7463 tSmeCmd *pCommand;
7464 tCsrRoamInfo roamInfo;
7465 tANI_U32 sessionId;
7466 tCsrRoamSession *pSession;
7467
7468 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7469 if(pEntry)
7470 {
7471 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7472 if ( eSmeCommandRoam == pCommand->command )
7473 {
7474 sessionId = pCommand->sessionId;
7475 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007476
7477 if(!pSession)
7478 {
7479 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7480 return;
7481 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307482 /* While switching between two AP, csr will reissue roam command again
7483 to the nextbss if it was interrupted by the dissconnect req for the
7484 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7485 so reset the bRefAssocStartCnt.
7486 */
7487 if(pSession->bRefAssocStartCnt > 0)
7488 {
7489 pSession->bRefAssocStartCnt--;
7490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007491 if( pCommand->u.roamCmd.fStopWds )
7492 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307493 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007494 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7495 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7496 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007498 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7499 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7500 eCSR_ROAM_WDS_IND,
7501 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007502 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7503 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7504 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7505 eCSR_ROAM_INFRA_IND,
7506 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7507 }
7508
Jeff Johnson295189b2012-06-20 16:38:30 -07007509
Jeff Johnson295189b2012-06-20 16:38:30 -07007510 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7511 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007512 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007513 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7514 }
7515 }
7516 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7517 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007518 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007519 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7520 }
7521 }
7522 else
7523 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007524 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007525 }
7526 }
7527 else
7528 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007529 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007530 }
7531}
7532
Jeff Johnson295189b2012-06-20 16:38:30 -07007533tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7534{
7535 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7536 tListElem *pEntry;
7537 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007538 //alwasy lock active list before locking pending list
7539 csrLLLock( &pMac->sme.smeCmdActiveList );
7540 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7541 if(pEntry)
7542 {
7543 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7544 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7545 {
7546 fRet = eANI_BOOLEAN_TRUE;
7547 }
7548 }
7549 if(eANI_BOOLEAN_FALSE == fRet)
7550 {
7551 csrLLLock(&pMac->sme.smeCmdPendingList);
7552 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7553 while(pEntry)
7554 {
7555 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7556 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7557 {
7558 fRet = eANI_BOOLEAN_TRUE;
7559 break;
7560 }
7561 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7562 }
7563 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7564 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307565 if (eANI_BOOLEAN_FALSE == fRet)
7566 {
7567 csrLLLock(&pMac->roam.roamCmdPendingList);
7568 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7569 while (pEntry)
7570 {
7571 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7572 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7573 {
7574 fRet = eANI_BOOLEAN_TRUE;
7575 break;
7576 }
7577 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7578 }
7579 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007581 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 return (fRet);
7583}
7584
Jeff Johnson295189b2012-06-20 16:38:30 -07007585tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7586{
7587 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7588 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007589 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7590 {
7591 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7592 {
7593 break;
7594 }
7595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007596 return ( fRet );
7597}
7598
Jeff Johnson295189b2012-06-20 16:38:30 -07007599tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7600{
7601 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007602 //alwasy lock active list before locking pending list
7603 csrLLLock( &pMac->sme.smeCmdActiveList );
7604 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7605 if(eANI_BOOLEAN_FALSE == fRet)
7606 {
7607 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7608 }
7609 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007610 return (fRet);
7611}
7612
Jeff Johnson295189b2012-06-20 16:38:30 -07007613tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7614{
7615 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7616 tListElem *pEntry;
7617 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007618 //alwasy lock active list before locking pending list
7619 csrLLLock( &pMac->sme.smeCmdActiveList );
7620 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7621 if( pEntry )
7622 {
7623 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7624 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7625 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7626 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7627 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7628 {
7629 fRet = eANI_BOOLEAN_TRUE;
7630 }
7631 }
7632 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007633 return (fRet);
7634}
Jeff Johnson295189b2012-06-20 16:38:30 -07007635eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7636{
7637 eHalStatus status = eHAL_STATUS_SUCCESS;
7638 tSmeCmd *pCommand = NULL;
7639 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7640 tANI_BOOLEAN fRemoveCmd = FALSE;
7641 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007642 // Delete the old assoc command. All is setup for reassoc to be serialized
7643 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7644 if ( pEntry )
7645 {
7646 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7647 if ( !pCommand )
7648 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007649 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007650 return eHAL_STATUS_RESOURCES;
7651 }
7652 if ( eSmeCommandRoam == pCommand->command )
7653 {
7654 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7655 {
7656 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7657 }
7658 else
7659 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007660 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007661 }
7662 if (fRemoveCmd == FALSE)
7663 {
7664 // Implies we did not get the serialized assoc command we
7665 // were expecting
7666 pCommand = NULL;
7667 }
7668 }
7669 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007670 if(NULL == pCommand)
7671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007672 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007673 return eHAL_STATUS_RESOURCES;
7674 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007675 do
7676 {
7677 //Change the substate in case it is wait-for-key
7678 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7679 {
7680 csrRoamStopWaitForKeyTimer( pMac );
7681 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7682 }
7683 pCommand->command = eSmeCommandRoam;
7684 pCommand->sessionId = (tANI_U8)sessionId;
7685 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007686 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7687 if( !HAL_STATUS_SUCCESS( status ) )
7688 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007689 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007690 csrReleaseCommandRoam( pMac, pCommand );
7691 }
7692 } while( 0 );
7693
Jeff Johnson295189b2012-06-20 16:38:30 -07007694 return( status );
7695}
7696static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7697{
7698 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7699 tCsrScanResult *pScanResult = NULL;
7700 tSirBssDescription *pBssDesc = NULL;
7701 tSmeCmd *pCommand = NULL;
7702 tANI_U32 sessionId;
7703 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007704 if(NULL == pEntry)
7705 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307706 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007707 return;
7708 }
7709 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7710 sessionId = pCommand->sessionId;
7711 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007712
7713 if(!pSession)
7714 {
7715 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7716 return;
7717 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307718 smsLog(pMac, LOG1, FL("CFG return value is %d "
7719 " current state is : %d substate is : %d "),
7720 result, pMac->roam.curState[sessionId],
7721 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007722 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7723 {
7724 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007725 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007726 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7727 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007728 /* If the roaming has stopped, not to continue the roaming command*/
7729 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7730 {
7731 //No need to complete roaming here as it already completes
7732 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7733 pCommand->u.roamCmd.roamReason);
7734 csrSetAbortRoamingCommand( pMac, pCommand );
7735 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7736 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007737 else
7738 {
7739 if ( CCM_IS_RESULT_SUCCESS(result) )
7740 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307741 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007742 // Successfully set the configuration parameters for the new Bss. Attempt to
7743 // join the roaming Bss.
7744 if(pCommand->u.roamCmd.pRoamBssEntry)
7745 {
7746 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7747 pBssDesc = &pScanResult->Result.BssDescriptor;
7748 }
7749 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7750 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007751 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007752 )
7753 {
7754 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7755 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7756 pBssDesc, pCommand->u.roamCmd.roamId )))
7757 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307758 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007759 //We need to complete the command
7760 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7761 }
7762 }
7763 else
7764 {
7765 if (!pCommand->u.roamCmd.pRoamBssEntry)
7766 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307767 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007768 //We need to complete the command
7769 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7770 return;
7771 }
7772 // If we are roaming TO an Infrastructure BSS...
7773 VOS_ASSERT(pScanResult != NULL);
7774 if ( csrIsInfraBssDesc( pBssDesc ) )
7775 {
7776 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307777 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007778 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7779 {
7780 // ..and currently in an Infrastructure connection....
7781 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7782 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307783 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007784 // ...and the SSIDs are equal, then we Reassoc.
7785 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7786 pIesLocal ) )
7787 // ..and currently in an infrastructure connection
7788 {
7789 // then issue a Reassoc.
7790 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7791 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7792 &pCommand->u.roamCmd.roamProfile );
7793 }
7794 else
7795 {
7796
7797 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7798 // previously associated AP.
7799 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7800 pIesLocal,
7801 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7802 {
7803 //try something else
7804 csrRoam( pMac, pCommand );
7805 }
7806 }
7807 }
7808 else
7809 {
7810 eHalStatus status = eHAL_STATUS_SUCCESS;
7811
7812 /* We need to come with other way to figure out that this is because of HO in BMP
7813 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007814 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007815 * use join request */
7816#ifdef WLAN_FEATURE_VOWIFI_11R
7817 if (csrRoamIsHandoffInProgress(pMac) &&
7818 csrRoamIs11rAssoc(pMac))
7819 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307820 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007821 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7822 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7823 }
7824 else
7825#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007826#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007827 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007828 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07007829 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307830 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007831 // Now serialize the reassoc command.
7832 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7833 }
7834 else
7835#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007836#ifdef FEATURE_WLAN_LFR
7837 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307838 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007839 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307840 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007841 // Now serialize the reassoc command.
7842 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7843 }
7844 else
7845#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007846 // else we are not connected and attempting to Join. Issue the
7847 // Join request.
7848 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307849 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07007850 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7851 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7852 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7853 }
7854 if(!HAL_STATUS_SUCCESS(status))
7855 {
7856 //try something else
7857 csrRoam( pMac, pCommand );
7858 }
7859 }
7860 if( !pScanResult->Result.pvIes )
7861 {
7862 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307863 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007864 }
7865 }
7866 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7867 else
7868 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007869 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007870 }
7871 }//else
7872 }//if ( WNI_CFG_SUCCESS == result )
7873 else
7874 {
7875 // In the event the configuration failed, for infra let the roam processor
7876 //attempt to join something else...
7877 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7878 {
7879 csrRoam(pMac, pCommand);
7880 }
7881 else
7882 {
7883 //We need to complete the command
7884 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7885 {
7886 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7887 }
7888 else
7889 {
7890 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7891 }
7892 }
7893 }
7894 }//we have active entry
7895}
7896
Jeff Johnson295189b2012-06-20 16:38:30 -07007897static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7898{
7899 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007900 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007901 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7902 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007903 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007904 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7905 // join the new one...
7906 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007907 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7908 }
7909 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007910 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007911 /***profHandleLostLinkAfterReset(pAdapter);
7912 // In the event the authenticate fails, let the roam processor attempt to join something else...
7913 roamRoam( pAdapter );***/
7914 }
7915}
7916
Jeff Johnson295189b2012-06-20 16:38:30 -07007917static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7918{
7919 eCsrRoamCompleteResult result;
7920 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7921 tCsrRoamInfo roamInfo;
7922 tANI_U32 roamId = 0;
7923
7924 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7925 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007926 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007927 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007928 /* Defeaturize this part later if needed */
7929#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7930 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7931 * we need the response contents while processing the result in csrRoamProcessResults() */
7932 if (csrRoamIsHandoffInProgress(pMac))
7933 {
7934 /* Need to dig more on indicating events to SME QoS module */
7935 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7936 csrRoamComplete( pMac, result, pSmeJoinRsp);
7937 }
7938 else
7939#endif
7940 {
7941 csrRoamComplete( pMac, result, NULL );
7942 }
7943 }
7944 /* Should we handle this similar to handling the join failure? Is it ok
7945 * to call csrRoamComplete() with state as CsrJoinFailure */
7946 else
7947 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007948 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 result = eCsrReassocFailure;
7950#ifdef WLAN_FEATURE_VOWIFI_11R
7951 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05307952 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
7953 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07007954 {
7955 // Inform HDD to turn off FT flag in HDD
7956 if (pNeighborRoamInfo)
7957 {
7958 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7959 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7960 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007961 /*
7962 * Since the above callback sends a disconnect
7963 * to HDD, we should clean-up our state
7964 * machine as well to be in sync with the upper
7965 * layers. There is no need to send a disassoc
7966 * since: 1) we will never reassoc to the current
7967 * AP in LFR, and 2) there is no need to issue a
7968 * disassoc to the AP with which we were trying
7969 * to reassoc.
7970 */
7971 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7972 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007973 }
7974 }
7975#endif
7976 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7977 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7978 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7979 //The disassoc rsp message will remove the command from active list
7980 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7981 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7982 {
7983 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7984 }
7985 }
7986}
7987
Jeff Johnson295189b2012-06-20 16:38:30 -07007988static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7989{
Jeff Johnson295189b2012-06-20 16:38:30 -07007990#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7991 {
7992 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7994 if(pIbssLog)
7995 {
7996 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7997 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7998 {
7999 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8000 }
8001 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8002 }
8003 }
8004#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008005 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8006 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8007 {
8008 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8009 }
8010 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8011 {
8012 csrRoamReissueRoamCommand(pMac);
8013 }
8014}
8015
Jeff Johnson295189b2012-06-20 16:38:30 -07008016void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8017{
8018 tSirResultCodes statusCode;
8019#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8020 tScanResultHandle hBSSList;
8021 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8022 eHalStatus status;
8023 tCsrRoamInfo roamInfo;
8024 tCsrScanResultFilter *pScanFilter = NULL;
8025 tANI_U32 roamId = 0;
8026 tCsrRoamProfile *pCurRoamProfile = NULL;
8027 tListElem *pEntry = NULL;
8028 tSmeCmd *pCommand = NULL;
8029#endif
8030 tANI_U32 sessionId;
8031 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07008032
Jeff Johnson295189b2012-06-20 16:38:30 -07008033 tSirSmeDisassocRsp SmeDisassocRsp;
8034
8035 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8036 sessionId = SmeDisassocRsp.sessionId;
8037 statusCode = SmeDisassocRsp.statusCode;
8038
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008039 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008040
8041 if ( csrIsConnStateInfra( pMac, sessionId ) )
8042 {
8043 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008045 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008046
8047 if(!pSession)
8048 {
8049 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8050 return;
8051 }
8052
Jeff Johnson295189b2012-06-20 16:38:30 -07008053 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8054 {
8055 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8056 }
8057 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8058 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8059 {
8060 if ( eSIR_SME_SUCCESS == statusCode )
8061 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008062 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008063 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8064 }
8065 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8066 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008067 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8068 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308069 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8070 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008071#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008072 /*
8073 * First ensure if the roam profile is in the scan cache.
8074 * If not, post a reassoc failure and disconnect.
8075 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308076 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8077 if ( NULL == pScanFilter )
8078 status = eHAL_STATUS_FAILURE;
8079 else
8080 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008081 if(HAL_STATUS_SUCCESS(status))
8082 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308083 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008084 status = csrRoamPrepareFilterFromProfile(pMac,
8085 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8086 if(!HAL_STATUS_SUCCESS(status))
8087 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008088 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008089 __func__, status);
8090 goto POST_ROAM_FAILURE;
8091 }
8092 else
8093 {
8094 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8095 if (!HAL_STATUS_SUCCESS(status))
8096 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008097 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008098 __func__, status);
8099 goto POST_ROAM_FAILURE;
8100 }
8101 }
8102 }
8103 else
8104 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008105 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008106 __func__, status);
8107 goto POST_ROAM_FAILURE;
8108 }
8109
8110 /*
8111 * After ensuring that the roam profile is in the scan result list,
8112 * dequeue the command from the active list.
8113 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008114 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8115 if ( pEntry )
8116 {
8117 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008118 /* If the head of the queue is Active and it is a ROAM command, remove
8119 * and put this on the Free queue.
8120 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008121 if ( eSmeCommandRoam == pCommand->command )
8122 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008123
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008124 /*
8125 * we need to process the result first before removing it from active list
8126 * because state changes still happening insides roamQProcessRoamResults so
8127 * no other roam command should be issued.
8128 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008129 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8130 if(pCommand->u.roamCmd.fReleaseProfile)
8131 {
8132 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8133 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008135 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008136 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008137 else
8138 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008139 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008140 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008141 }
8142 }
8143 else
8144 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008145 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008146 }
8147 }
8148 else
8149 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008150 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008152
8153 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008154 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8155
Kiet Lam64c1b492013-07-12 13:56:44 +05308156 vos_mem_copy(roamInfo.bssid,
8157 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8158 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008159
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008160 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8161 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008162
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008163 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308164 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8165 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008166 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308167 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008168 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8169 //make sure to put it at the head of the cmd queue
8170 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8171 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8172 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8173
Jeff Johnson295189b2012-06-20 16:38:30 -07008174 if(!HAL_STATUS_SUCCESS(status))
8175 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008176 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008177 __func__, status);
8178 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008179 }
8180
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008181 /* Notify sub-modules like QoS etc. that handoff happening */
8182 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008183 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308184 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008185 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308186 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008187 return;
8188 }
8189
8190POST_ROAM_FAILURE:
8191 if (pScanFilter)
8192 {
8193 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308194 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008195 }
8196 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308197 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008198
8199 /* Inform the upper layers that the reassoc failed */
8200 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8201 csrRoamCallCallback(pMac, sessionId,
8202 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8203
8204 /*
8205 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8206 * Upon success, we would re-enter this routine after receiving the disassoc
8207 * response and will fall into the reassoc fail sub-state. And, eventually
8208 * call csrRoamComplete which would remove the roam command from SME active
8209 * queue.
8210 */
8211 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8212 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8213 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008214 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008215 __func__, status);
8216 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008217 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008218#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008219
Jeff Johnson295189b2012-06-20 16:38:30 -07008220 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8221 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8222 {
8223 // Disassoc due to Reassoc failure falls into this codepath....
8224 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8225 }
8226 else
8227 {
8228 if ( eSIR_SME_SUCCESS == statusCode )
8229 {
8230 // Successfully disassociated from the 'old' Bss...
8231 //
8232 // We get Disassociate response in three conditions.
8233 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8234 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8235 // Infrastructure network.
8236 // - Third is where we are doing an Infra to Infra roam between networks with different
8237 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8238
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008239 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008240 }
8241 else
8242 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008243 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008244 }
8245 //We are not done yet. Get the data and continue roaming
8246 csrRoamReissueRoamCommand(pMac);
8247 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008248}
8249
Jeff Johnson295189b2012-06-20 16:38:30 -07008250static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8251{
8252 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008253 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008254 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008255 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008256 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008257 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8258 {
8259 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8260 }
8261 else
8262 {
8263 if ( eSIR_SME_SUCCESS == statusCode )
8264 {
8265 // Successfully deauth from the 'old' Bss...
8266 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008267 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 }
8269 else
8270 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008271 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008272 }
8273 //We are not done yet. Get the data and continue roaming
8274 csrRoamReissueRoamCommand(pMac);
8275 }
8276}
8277
Jeff Johnson295189b2012-06-20 16:38:30 -07008278static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8279{
8280 eCsrRoamCompleteResult result;
8281
8282 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8283 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008284 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008285 result = eCsrStartBssSuccess;
8286 }
8287 else
8288 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008289 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008290 //Let csrRoamComplete decide what to do
8291 result = eCsrStartBssFailure;
8292 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008293 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008294}
8295
Jeff Johnson295189b2012-06-20 16:38:30 -07008296/*
8297 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8298 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8299 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8300 For the messages where sender allocates memory for specific structures, then it can be
8301 cast accordingly.
8302*/
8303void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8304{
8305 tSirSmeRsp *pSmeRsp;
8306 tSmeIbssPeerInd *pIbssPeerInd;
8307 tCsrRoamInfo roamInfo;
8308 // TODO Session Id need to be acquired in this function
8309 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008310 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308311 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8312 pSmeRsp->messageType, pSmeRsp->messageType,
8313 macTraceGetcsrRoamSubState(
8314 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008315 pSmeRsp->messageType = (pSmeRsp->messageType);
8316 pSmeRsp->length = (pSmeRsp->length);
8317 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008318 switch (pSmeRsp->messageType)
8319 {
8320
8321 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8322 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8323 {
8324 //We sent a JOIN_REQ
8325 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8326 }
8327 break;
8328
8329 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8330 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8331 {
8332 //We sent a AUTH_REQ
8333 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8334 }
8335 break;
8336
8337 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8338 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8339 {
8340 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8341 }
8342 break;
8343
8344 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8345 {
8346 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8347 }
8348 break;
8349
8350 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8351 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8352 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8353 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8354 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8355 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8356//HO
8357 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8358 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308359 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8360 macTraceGetcsrRoamSubState(
8361 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05308363#ifdef DEBUG_ROAM_DELAY
8364 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8365#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008366 }
8367 break;
8368
8369 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8370 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8371 {
8372 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8373 }
8374 break;
8375
8376 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8377 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8378 {
8379 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8380 }
8381 break;
8382
8383 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8384 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8385 {
8386 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008388 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008389 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8390 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8391 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008392 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308393 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8394 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008395 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8396 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308397 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8398 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008399 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8400 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8401 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8402 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008403 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308404 smsLog(pMac, LOG1,
8405 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8406 pSmeRsp->messageType, pSmeRsp->messageType,
8407 macTraceGetcsrRoamSubState(
8408 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008409
8410 //If we are connected, check the link status change
8411 if(!csrIsConnStateDisconnected(pMac, sessionId))
8412 {
8413 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8414 }
8415 break;
8416 }
8417}
8418
Jeff Johnson295189b2012-06-20 16:38:30 -07008419void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8420{
8421 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008422 switch (pSirMsg->messageType)
8423 {
8424 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008425 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008426 csrRoamStatsRspProcessor( pMac, pSirMsg );
8427 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008428 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8429 {
8430 tCsrRoamSession *pSession;
8431 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8432 tCsrRoamInfo roamInfo;
8433 tCsrRoamInfo *pRoamInfo = NULL;
8434 tANI_U32 sessionId;
8435 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008436 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308437 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8440 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8441 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008442
8443 if(!pSession)
8444 {
8445 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8446 return;
8447 }
8448
Jeff Johnson295189b2012-06-20 16:38:30 -07008449 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8450 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8452 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8453 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8455 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308456 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8457 sizeof(tSirMacAddr));
8458 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8459 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008460 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008461 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8462 {
8463 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8464 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8465 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8466 }
8467 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8468 {
8469 vos_sleep( 100 );
8470 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8471 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8472 }
8473
Jeff Johnson295189b2012-06-20 16:38:30 -07008474 }
8475 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008476 default:
8477 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8478 break;
8479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008480}
8481
Jeff Johnson295189b2012-06-20 16:38:30 -07008482eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8483 tSirBssDescription *pBssDescription,
8484 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8485 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8486 tANI_U8 keyId, tANI_U16 keyLength,
8487 tANI_U8 *pKey, tANI_U8 paeRole )
8488{
8489 eHalStatus status = eHAL_STATUS_SUCCESS;
8490 tAniEdType edType;
8491
8492 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8493 {
8494 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8495 }
8496
8497 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8498
8499 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8500 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8501 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8502 addKey )
8503 {
8504 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 setKey.encType = EncryptType;
8506 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308507 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 setKey.paeRole = paeRole; //0 for supplicant
8509 setKey.keyId = keyId; // Kye index
8510 setKey.keyLength = keyLength;
8511 if( keyLength )
8512 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308513 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008514 }
8515 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008517 return (status);
8518}
8519
Jeff Johnson295189b2012-06-20 16:38:30 -07008520static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8521 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8522{
8523 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8524 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008525#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008526 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008527#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008528
8529 do
8530 {
8531 pCommand = csrGetCommandBuffer(pMac);
8532 if(NULL == pCommand)
8533 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008534 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008535 status = eHAL_STATUS_RESOURCES;
8536 break;
8537 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05308538 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07008539 pCommand->command = eSmeCommandSetKey;
8540 pCommand->sessionId = (tANI_U8)sessionId;
8541 // validate the key length, Adjust if too long...
8542 // for static WEP the keys are not set thru' SetContextReq
8543 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8544 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8545 {
8546 //KeyLength maybe 0 for static WEP
8547 if( pSetKey->keyLength )
8548 {
8549 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8550 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008551 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008552 break;
8553 }
8554
8555 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308556 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8557 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008558 }
8559 }
8560 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8561 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8562 {
8563 //KeyLength maybe 0 for static WEP
8564 if( pSetKey->keyLength )
8565 {
8566 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008568 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008569 break;
8570 }
8571
8572 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308573 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8574 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008575 }
8576 }
8577 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8578 {
8579 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8580 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008581 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008582 break;
8583 }
8584 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308585 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8586 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008587 }
8588 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8589 {
8590 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008592 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008593 break;
8594 }
8595 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308596 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8597 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008598 }
8599#ifdef FEATURE_WLAN_WAPI
8600 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8601 {
8602 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008604 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008605 break;
8606 }
8607 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308608 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8609 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008610 }
8611#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008612#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008613 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8614 {
8615 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008617 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008618 break;
8619 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008620 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308621 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008622 pSession->eseCckmInfo.reassoc_req_num=1;
8623 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008624 status = eHAL_STATUS_SUCCESS;
8625 break;
8626 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008627#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008628
Jeff Johnson295189b2012-06-20 16:38:30 -07008629#ifdef WLAN_FEATURE_11W
8630 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008631 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008632 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008633 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008634 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008635 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008636 break;
8637 }
8638 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308639 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008640 }
8641#endif
8642 status = eHAL_STATUS_SUCCESS;
8643 pCommand->u.setKeyCmd.roamId = roamId;
8644 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8645 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308646 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8647 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008648 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8649 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308650 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008651 //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
8652
8653 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8654 if( !HAL_STATUS_SUCCESS( status ) )
8655 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008656 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008657 }
8658 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008659 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008660 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008661 if ( ( NULL != pCommand ) &&
8662 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008663#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008664 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008665#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008666 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008667 {
8668 csrReleaseCommandSetKey( pMac, pCommand );
8669 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008670 return( status );
8671}
8672
Jeff Johnson295189b2012-06-20 16:38:30 -07008673eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8674 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8675{
8676 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8677 tSmeCmd *pCommand = NULL;
8678 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008679 do
8680 {
8681 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8682 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008683 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008684 status = eHAL_STATUS_CSR_WRONG_STATE;
8685 break;
8686 }
8687 pCommand = csrGetCommandBuffer(pMac);
8688 if(NULL == pCommand)
8689 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008690 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008691 status = eHAL_STATUS_RESOURCES;
8692 break;
8693 }
8694 pCommand->command = eSmeCommandRemoveKey;
8695 pCommand->sessionId = (tANI_U8)sessionId;
8696 pCommand->u.removeKeyCmd.roamId = roamId;
8697 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308698 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8699 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008700 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8701 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8702 {
8703 //in this case, put it to the end of the Q incase there is a set key pending.
8704 fImediate = eANI_BOOLEAN_FALSE;
8705 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008706 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008707 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008708 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008709 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8710 if( !HAL_STATUS_SUCCESS( status ) )
8711 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008712 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008713 break;
8714 }
8715 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008716 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8717 {
8718 csrReleaseCommandRemoveKey( pMac, pCommand );
8719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008720 return (status );
8721}
8722
Jeff Johnson295189b2012-06-20 16:38:30 -07008723eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8724{
8725 eHalStatus status;
8726 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8727 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8728 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8729 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008730#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8731 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8732 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308733 if(!pSession)
8734 {
8735 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8736 return eHAL_STATUS_FAILURE;
8737 }
lukez3c809222013-05-03 10:23:02 -07008738 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008739 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308740 vos_mem_set(&setKeyEvent,
8741 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008742 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8743 {
8744 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8745 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8746 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8747 }
8748 else
8749 {
8750 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8751 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8752 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8753 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308754 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008755 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008756 {
8757 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008758 //It has to be static WEP here
8759 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8760 {
8761 setKeyEvent.keyId = (v_U8_t)defKeyId;
8762 }
8763 }
8764 else
8765 {
8766 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8767 }
8768 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8769 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8770 }
8771#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008772 if( csrIsSetKeyAllowed(pMac, sessionId) )
8773 {
8774 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8775 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8776 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8777 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8778 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8779 pCommand->u.setKeyCmd.keyRsc);
8780 }
8781 else
8782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008783 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008784 //Set this status so the error handling take care of the case.
8785 status = eHAL_STATUS_CSR_WRONG_STATE;
8786 }
8787 if( !HAL_STATUS_SUCCESS(status) )
8788 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008789 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008790 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008791#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008792 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008793 {
8794 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8795 {
8796 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8797 }
8798 else
8799 {
8800 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8801 }
8802 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8803 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8804 }
8805#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008807 return ( status );
8808}
8809
Jeff Johnson295189b2012-06-20 16:38:30 -07008810eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8811{
8812 eHalStatus status;
8813 tpSirSmeRemoveKeyReq pMsg = NULL;
8814 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8815 tANI_U8 *p;
8816 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008817#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8818 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8819 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308820 if(!pSession)
8821 {
8822 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8823 return eHAL_STATUS_FAILURE;
8824 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308825 vos_mem_set(&removeKeyEvent,
8826 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008827 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8828 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8829 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308830 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8832 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8833 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8834#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008835 if( csrIsSetKeyAllowed(pMac, sessionId) )
8836 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308837 pMsg = vos_mem_malloc(wMsgLen);
8838 if ( NULL == pMsg )
8839 status = eHAL_STATUS_FAILURE;
8840 else
8841 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008842 }
8843 else
8844 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008845 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008846 //Set the error status so error handling kicks in below
8847 status = eHAL_STATUS_CSR_WRONG_STATE;
8848 }
8849 if( HAL_STATUS_SUCCESS( status ) )
8850 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308851 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008852 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8853 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008854 pMsg->sessionId = (tANI_U8)sessionId;
8855 pMsg->transactionId = 0;
8856 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8857 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8858 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308859 vos_mem_copy(p,
8860 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8861 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008862 p += sizeof(tSirMacAddr);
8863 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308864 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008865 p += sizeof(tSirMacAddr);
8866 // edType
8867 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8868 p++;
8869 // weptype
8870 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8871 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8872 {
8873 *p = (tANI_U8)eSIR_WEP_STATIC;
8874 }
8875 else
8876 {
8877 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8878 }
8879 p++;
8880 //keyid
8881 *p = pCommand->u.removeKeyCmd.keyId;
8882 p++;
8883 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008884 status = palSendMBMessage(pMac->hHdd, pMsg);
8885 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008886 if( !HAL_STATUS_SUCCESS( status ) )
8887 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008888 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008889#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8890 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008891 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008892 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8893#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008894 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 return ( status );
8897}
8898
Jeff Johnson295189b2012-06-20 16:38:30 -07008899eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8900{
8901 eHalStatus status;
8902
8903 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8904 {
8905 status = eHAL_STATUS_CSR_WRONG_STATE;
8906 }
8907 else
8908 {
8909 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8910 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008911 return ( status );
8912}
8913
Jeff Johnson295189b2012-06-20 16:38:30 -07008914/*
8915 Prepare a filter base on a profile for parsing the scan results.
8916 Upon successful return, caller MUST call csrFreeScanFilter on
8917 pScanFilter when it is done with the filter.
8918*/
8919eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8920 tCsrScanResultFilter *pScanFilter)
8921{
8922 eHalStatus status = eHAL_STATUS_SUCCESS;
8923 tANI_U32 size = 0;
8924 tANI_U8 index = 0;
8925
8926 do
8927 {
8928 if(pProfile->BSSIDs.numOfBSSIDs)
8929 {
8930 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308931 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8932 if ( NULL == pScanFilter->BSSIDs.bssid )
8933 status = eHAL_STATUS_FAILURE;
8934 else
8935 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008936 if(!HAL_STATUS_SUCCESS(status))
8937 {
8938 break;
8939 }
8940 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308941 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008942 }
8943 if(pProfile->SSIDs.numOfSSIDs)
8944 {
8945 if( !CSR_IS_WDS_STA( pProfile ) )
8946 {
8947 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8948 }
8949 else
8950 {
8951 //For WDS station
8952 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8953 pScanFilter->SSIDs.numOfSSIDs = 1;
8954 }
8955 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308956 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8957 if ( NULL == pScanFilter->SSIDs.SSIDList )
8958 status = eHAL_STATUS_FAILURE;
8959 else
8960 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008961 if(!HAL_STATUS_SUCCESS(status))
8962 {
8963 break;
8964 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308965 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8966 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008967 }
8968 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8969 {
8970 pScanFilter->ChannelInfo.numOfChannels = 0;
8971 pScanFilter->ChannelInfo.ChannelList = NULL;
8972 }
8973 else if(pProfile->ChannelInfo.numOfChannels)
8974 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308975 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8976 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8977 pProfile->ChannelInfo.numOfChannels);
8978 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8979 status = eHAL_STATUS_FAILURE;
8980 else
8981 status = eHAL_STATUS_SUCCESS;
8982
Jeff Johnson295189b2012-06-20 16:38:30 -07008983 pScanFilter->ChannelInfo.numOfChannels = 0;
8984 if(HAL_STATUS_SUCCESS(status))
8985 {
8986 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8987 {
8988 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8989 {
8990 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8991 = pProfile->ChannelInfo.ChannelList[index];
8992 pScanFilter->ChannelInfo.numOfChannels++;
8993 }
8994 else
8995 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008996 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008998 }
8999 }
9000 else
9001 {
9002 break;
9003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009004 }
9005 else
9006 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309007 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009008 status = eHAL_STATUS_FAILURE;
9009 break;
9010 }
9011 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
9012 pScanFilter->authType = pProfile->AuthType;
9013 pScanFilter->EncryptionType = pProfile->EncryptionType;
9014 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9015 pScanFilter->BSSType = pProfile->BSSType;
9016 pScanFilter->phyMode = pProfile->phyMode;
9017#ifdef FEATURE_WLAN_WAPI
9018 //check if user asked for WAPI with 11n or auto mode, in that case modify
9019 //the phymode to 11g
9020 if(csrIsProfileWapi(pProfile))
9021 {
9022 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9023 {
9024 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9025 }
9026 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9027 {
9028 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9029 }
9030 if(!pScanFilter->phyMode)
9031 {
9032 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9033 }
9034 }
9035#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009036 /*Save the WPS info*/
9037 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009038 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009039 if( pProfile->countryCode[0] )
9040 {
9041 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309042 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9043 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009044 }
9045#ifdef WLAN_FEATURE_VOWIFI_11R
9046 if (pProfile->MDID.mdiePresent)
9047 {
9048 pScanFilter->MDID.mdiePresent = 1;
9049 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9050 }
9051#endif
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309052
9053#ifdef WLAN_FEATURE_11W
9054 // Management Frame Protection
9055 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9056 pScanFilter->MFPRequired = pProfile->MFPRequired;
9057 pScanFilter->MFPCapable = pProfile->MFPCapable;
9058#endif
9059
Jeff Johnson295189b2012-06-20 16:38:30 -07009060 }while(0);
9061
9062 if(!HAL_STATUS_SUCCESS(status))
9063 {
9064 csrFreeScanFilter(pMac, pScanFilter);
9065 }
9066
9067 return(status);
9068}
9069
Jeff Johnson295189b2012-06-20 16:38:30 -07009070tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9071 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9072{
9073 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9074 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009075 do
9076 {
9077 // Validate the type is ok...
9078 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9079 pCommand = csrGetCommandBuffer( pMac );
9080 if ( !pCommand )
9081 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009082 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009083 break;
9084 }
9085 //Change the substate in case it is waiting for key
9086 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9087 {
9088 csrRoamStopWaitForKeyTimer( pMac );
9089 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9090 }
9091 pCommand->command = eSmeCommandWmStatusChange;
9092 pCommand->sessionId = (tANI_U8)sessionId;
9093 pCommand->u.wmStatusChangeCmd.Type = Type;
9094 if ( eCsrDisassociated == Type )
9095 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309096 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9097 pSmeRsp,
9098 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009099 }
9100 else
9101 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309102 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9103 pSmeRsp,
9104 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009105 }
9106 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9107 {
9108 fCommandQueued = eANI_BOOLEAN_TRUE;
9109 }
9110 else
9111 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009112 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 csrReleaseCommandWmStatusChange( pMac, pCommand );
9114 }
9115
Jeff Johnson295189b2012-06-20 16:38:30 -07009116 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9117 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009118 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009119 return( fCommandQueued );
9120}
9121
Jeff Johnson295189b2012-06-20 16:38:30 -07009122static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9123{
9124 v_S7_t rssi = 0;
9125 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9126 if(pGetRssiReq)
9127 {
9128 if(NULL != pGetRssiReq->pVosContext)
9129 {
9130 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9131 }
9132 else
9133 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009134 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009135 return;
9136 }
9137
9138 if(NULL != pGetRssiReq->rssiCallback)
9139 {
9140 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9141 }
9142 else
9143 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009144 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009145 return;
9146 }
9147 }
9148 else
9149 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009150 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009151 }
9152 return;
9153}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309154
9155static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9156{
9157 tANI_S8 snr = 0;
9158 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9159
9160 if (pGetSnrReq)
9161 {
9162 if (VOS_STATUS_SUCCESS !=
9163 WDA_GetSnr(pGetSnrReq->staId, &snr))
9164 {
9165 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9166 return;
9167 }
9168
9169 if (pGetSnrReq->snrCallback)
9170 {
9171 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9172 pGetSnrReq->pDevContext);
9173 }
9174 else
9175 {
9176 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9177 return;
9178 }
9179 }
9180 else
9181 {
9182 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9183 }
9184 return;
9185}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009186#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009187void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9188{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009189 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9190
Jeff Johnson36d483b2013-04-08 11:08:53 -07009191 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009192 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009193 /* Get roam Rssi request is backed up and passed back to the response,
9194 Extract the request message to fetch callback */
9195 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9196 v_S7_t rssi = pRoamRssiRsp->rssi;
9197
9198 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009199 {
9200 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9201 reqBkp->rssiCallback = NULL;
9202 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009203 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009204 }
9205 else
9206 {
9207 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9208 if (NULL != reqBkp)
9209 {
9210 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009211 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009212 }
9213 }
9214 }
9215 else
9216 {
9217 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9218 }
9219 return;
9220}
9221#endif
9222
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009223
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009224#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009225void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9226{
9227 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9228
9229 if (NULL != pTsmStatsRsp)
9230 {
9231 /* Get roam Rssi request is backed up and passed back to the response,
9232 Extract the request message to fetch callback */
9233 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9234
9235 if (NULL != reqBkp)
9236 {
9237 if (NULL != reqBkp->tsmStatsCallback)
9238 {
9239 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9240 pTsmStatsRsp->staId, reqBkp->pDevContext);
9241 reqBkp->tsmStatsCallback = NULL;
9242 }
9243 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009244 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009245 }
9246 else
9247 {
9248 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9249 if (NULL != reqBkp)
9250 {
9251 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009252 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009253 }
9254 }
9255 }
9256 else
9257 {
9258 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9259 }
9260 return;
9261}
9262
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009263void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009264{
9265 tANI_U32 roamTS2 = 0;
9266 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009267 tpPESession pSessionEntry = NULL;
9268 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009269
9270 if (NULL == pSession)
9271 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009272 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009273 return;
9274 }
9275
9276 roamTS2 = vos_timer_get_system_time();
9277 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009278 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9279 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009280 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009281
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009282 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9283 if (NULL == pSessionEntry)
9284 {
9285 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9286 return;
9287 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009288 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009289 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009290 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009291}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009292#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009293
Jeff Johnsone7245742012-09-05 17:12:55 -07009294static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9295{
9296 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9297 if(pTlRssiInd)
9298 {
9299 if(NULL != pTlRssiInd->tlCallback)
9300 {
9301 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009302 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009303 }
9304 else
9305 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009306 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009307 }
9308 }
9309 else
9310 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009311 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009312 }
9313 return;
9314}
Jeff Johnson295189b2012-06-20 16:38:30 -07009315
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309316eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9317{
9318 tpSirResetAPCapsChange pMsg;
9319 tANI_U16 len;
9320 eHalStatus status = eHAL_STATUS_SUCCESS;
9321
9322 /* Create the message and send to lim */
9323 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309324 pMsg = vos_mem_malloc(len);
9325 if ( NULL == pMsg )
9326 status = eHAL_STATUS_FAILURE;
9327 else
9328 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309329 if (HAL_STATUS_SUCCESS(status))
9330 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309331 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309332 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9333 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309334 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009335 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9336 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309337 status = palSendMBMessage(pMac->hHdd, pMsg);
9338 }
9339 else
9340 {
9341 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9342 }
9343 return status;
9344}
9345
Jeff Johnson295189b2012-06-20 16:38:30 -07009346void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9347{
9348 tSirSmeAssocInd *pAssocInd;
9349 tSirSmeDisassocInd *pDisassocInd;
9350 tSirSmeDeauthInd *pDeauthInd;
9351 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9352 tSirSmeNewBssInfo *pNewBss;
9353 tSmeIbssPeerInd *pIbssPeerInd;
9354 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9355 tSirSmeApNewCaps *pApNewCaps;
9356 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9357 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9358 tCsrRoamInfo *pRoamInfo = NULL;
9359 tCsrRoamInfo roamInfo;
9360 eHalStatus status;
9361 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9362 tCsrRoamSession *pSession = NULL;
9363 tpSirSmeSwitchChannelInd pSwitchChnInd;
9364 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309365 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009366
9367
9368 if (NULL == pSirMsg)
9369 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9370 return;
9371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009372 switch( pSirMsg->messageType )
9373 {
9374 case eWNI_SME_ASSOC_IND:
9375 {
9376 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009377 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009378 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9379 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9380 if( HAL_STATUS_SUCCESS( status ) )
9381 {
9382 pSession = CSR_GET_SESSION(pMac, sessionId);
9383
Jeff Johnson32d95a32012-09-10 13:15:23 -07009384 if(!pSession)
9385 {
9386 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9387 return;
9388 }
9389
Jeff Johnson295189b2012-06-20 16:38:30 -07009390 pRoamInfo = &roamInfo;
9391
9392 // Required for indicating the frames to upper layer
9393 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9394 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9395
9396 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9397 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9398 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9399 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9400
9401 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9402 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9403 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9404
9405 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9406 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309407 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9408 sizeof(tSirMacAddr));
9409 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9410 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009411 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9412 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009413 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009414 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9415 {
9416 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9417 {
9418 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9419 pSession->pConnectBssDesc,
9420 &(pRoamInfo->peerMac),
9421 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9422 pRoamInfo->fAuthRequired = FALSE;
9423 }
9424 else
9425 {
9426 pRoamInfo->fAuthRequired = TRUE;
9427 }
9428 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9429 if (!HAL_STATUS_SUCCESS(status))
9430 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009432 /* Send Association completion message to PE */
9433 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9434
9435 /* send a message to CSR itself just to avoid the EAPOL frames going
9436 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009437 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9438 {
9439 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009441 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9442 {
9443 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9444 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9445 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 }
9448 }
9449 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009450 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009451 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309452 // Check if AP dis-associated us because of MIC failure. If so,
9453 // then we need to take action immediately and not wait till the
9454 // the WmStatusChange requests is pushed and processed
9455 tSmeCmd *pCommand;
9456
9457 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9458 status = csrRoamGetSessionIdFromBSSID( pMac,
9459 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9460 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009461 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309462 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9463 " for session %d "), sessionId);
9464 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9465 MAC_ADDRESS_STR " "
9466 " reason = %d status = %d "),
9467 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9468 pDisassocInd->reasonCode,
9469 pDisassocInd->statusCode);
9470 // If we are in neighbor preauth done state then on receiving
9471 // disassoc or deauth we dont roam instead we just disassoc
9472 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009473 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309474#ifdef WLAN_FEATURE_VOWIFI_11R
9475 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9476 {
9477 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009479#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009480#ifdef FEATURE_WLAN_ESE
9481 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309482 {
9483 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9484 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009485#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009486#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309487 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9488 {
9489 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9490 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009491#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309492 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009493
Agarwal Ashish4f616132013-12-30 23:32:50 +05309494 if (!pSession)
9495 {
9496 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9497 return;
9498 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009499
Agarwal Ashish4f616132013-12-30 23:32:50 +05309500 if ( csrIsConnStateInfra( pMac, sessionId ) )
9501 {
9502 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009504#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309505 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009506#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309507 csrRoamLinkDown(pMac, sessionId);
9508 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9509 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9510 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309511 pRoamInfo = &roamInfo;
9512 pRoamInfo->statusCode = pDisassocInd->statusCode;
9513 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9514 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009515
Agarwal Ashish4f616132013-12-30 23:32:50 +05309516 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9517 sizeof(tSirMacAddr));
9518 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9519 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009520
Agarwal Ashish4f616132013-12-30 23:32:50 +05309521 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9522 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009523
Agarwal Ashish4f616132013-12-30 23:32:50 +05309524 /*
9525 * STA/P2P client got disassociated so remove any pending deauth
9526 * commands in sme pending list
9527 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309528 pCommand = csrGetCommandBuffer(pMac);
9529 if (NULL == pCommand)
9530 {
9531 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9532 status = eHAL_STATUS_RESOURCES;
9533 return;
9534 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309535 pCommand->command = eSmeCommandRoam;
9536 pCommand->sessionId = (tANI_U8)sessionId;
9537 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9538 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9539 pDisassocInd->peerMacAddr,
9540 sizeof(tSirMacAddr));
9541 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9542 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009543
Agarwal Ashish4f616132013-12-30 23:32:50 +05309544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009545 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309546 else
9547 {
9548 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9549 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9550 }
Kiet Lam82004c62013-11-11 13:24:28 +05309551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009552 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009553 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009554 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009555 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9556 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9557 if( HAL_STATUS_SUCCESS( status ) )
9558 {
9559 // If we are in neighbor preauth done state then on receiving
9560 // disassoc or deauth we dont roam instead we just disassoc
9561 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009562 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009563#ifdef WLAN_FEATURE_VOWIFI_11R
9564 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9565 {
9566 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9567 }
9568#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009569#ifdef FEATURE_WLAN_ESE
9570 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009571 {
9572 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9573 }
9574#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009575#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309576 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009577 {
9578 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9579 }
9580#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009581 pSession = CSR_GET_SESSION( pMac, sessionId );
9582
Jeff Johnson32d95a32012-09-10 13:15:23 -07009583 if(!pSession)
9584 {
9585 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9586 return;
9587 }
9588
Jeff Johnson295189b2012-06-20 16:38:30 -07009589 if ( csrIsConnStateInfra( pMac, sessionId ) )
9590 {
9591 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009593#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9594 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9595#endif
9596 csrRoamLinkDown(pMac, sessionId);
9597 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009598 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9599 {
9600
9601 pRoamInfo = &roamInfo;
9602
9603 pRoamInfo->statusCode = pDeauthInd->statusCode;
9604 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9605
9606 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9607
Kiet Lam64c1b492013-07-12 13:56:44 +05309608 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9609 sizeof(tSirMacAddr));
9610 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9611 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009612
9613 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9614 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009615 }
9616 break;
9617
9618 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 -08009619 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009620 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9621 //Update with the new channel id.
9622 //The channel id is hidden in the statusCode.
9623 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9624 if( HAL_STATUS_SUCCESS( status ) )
9625 {
9626 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009627 if(!pSession)
9628 {
9629 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9630 return;
9631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009632 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9633 if(pSession->pConnectBssDesc)
9634 {
9635 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9636 }
9637 }
9638 break;
9639
9640 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009641 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009642 {
9643 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9644 sessionId = pDeauthRsp->sessionId;
9645 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9646 {
9647 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9649 {
9650 pRoamInfo = &roamInfo;
9651 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309652 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9653 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009654 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9655 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9656 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9657 }
9658 }
9659 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009660 break;
9661
9662 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009663 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009664 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009665 {
9666 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9667 sessionId = pDisassocRsp->sessionId;
9668 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9669 {
9670 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009671 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9672 {
9673 pRoamInfo = &roamInfo;
9674 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309675 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9676 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009677 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9678 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9679 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9680 }
9681 }
9682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009684 case eWNI_SME_MIC_FAILURE_IND:
9685 {
9686 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9687 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9688 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009689
9690 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9691 if( HAL_STATUS_SUCCESS( status ) )
9692 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309693 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009694 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9695 pRoamInfo = &roamInfo;
9696 if(pMicInd->info.multicast)
9697 {
9698 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9699 }
9700 else
9701 {
9702 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9703 }
9704 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9705 }
9706
Jeff Johnson295189b2012-06-20 16:38:30 -07009707#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9708 {
lukez3c809222013-05-03 10:23:02 -07009709 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009710 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009711 if(!pSession)
9712 {
9713 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9714 return;
9715 }
lukez3c809222013-05-03 10:23:02 -07009716
Kiet Lam64c1b492013-07-12 13:56:44 +05309717 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009718 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9719 secEvent.encryptionModeMulticast =
9720 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9721 secEvent.encryptionModeUnicast =
9722 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9723 secEvent.authMode =
9724 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309725 vos_mem_copy(secEvent.bssid,
9726 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009727 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9728 }
9729#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009730 }
9731 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009732 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9733 {
9734 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9735 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009736 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009737
9738 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9739 if( HAL_STATUS_SUCCESS( status ) )
9740 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309741 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009742 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9743 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9744 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9745 }
9746 }
9747 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009748
Jeff Johnson295189b2012-06-20 16:38:30 -07009749 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9750 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9751 switch( pStatusChangeMsg->statusChangeCode )
9752 {
9753 case eSIR_SME_IBSS_ACTIVE:
9754 sessionId = csrFindIbssSession( pMac );
9755 if( CSR_SESSION_ID_INVALID != sessionId )
9756 {
9757 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009758 if(!pSession)
9759 {
9760 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9761 return;
9762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009763 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9764 if(pSession->pConnectBssDesc)
9765 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309766 vos_mem_copy(&roamInfo.bssid,
9767 pSession->pConnectBssDesc->bssId,
9768 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009769 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9770 pRoamInfo = &roamInfo;
9771 }
9772 else
9773 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009774 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009775 }
9776 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9777 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9778 }
9779 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009780 case eSIR_SME_IBSS_INACTIVE:
9781 sessionId = csrFindIbssSession( pMac );
9782 if( CSR_SESSION_ID_INVALID != sessionId )
9783 {
9784 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009785 if(!pSession)
9786 {
9787 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9788 return;
9789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009790 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9791 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9792 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9793 }
9794 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009795 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9796 sessionId = csrFindIbssSession( pMac );
9797 if( CSR_SESSION_ID_INVALID != sessionId )
9798 {
9799 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009800 if(!pSession)
9801 {
9802 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9803 return;
9804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009805 // update the connection state information
9806 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009807#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9808 {
9809 vos_log_ibss_pkt_type *pIbssLog;
9810 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009811 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9812 if(pIbssLog)
9813 {
9814 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9815 if(pNewBss)
9816 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309817 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009818 if(pNewBss->ssId.length)
9819 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309820 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9821 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009822 }
9823 pIbssLog->operatingChannel = pNewBss->channelNumber;
9824 }
9825 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9826 {
9827 //***U8 is not enough for beacon interval
9828 pIbssLog->beaconInterval = (v_U8_t)bi;
9829 }
9830 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9831 }
9832 }
9833#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009834 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009835
9836 if ((eCSR_ENCRYPT_TYPE_NONE ==
9837 pSession->connectedProfile.EncryptionType ))
9838 {
9839 csrRoamIssueSetContextReq( pMac, sessionId,
9840 pSession->connectedProfile.EncryptionType,
9841 pSession->pConnectBssDesc,
9842 &Broadcastaddr,
9843 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009845 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9846 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309847 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9848 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009849 pRoamInfo = &roamInfo;
9850 //This BSSID is th ereal BSSID, let's save it
9851 if(pSession->pConnectBssDesc)
9852 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309853 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9854 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009855 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009856 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009857 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009858 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009859 // detection by LIM that the capabilities of the associated AP have changed.
9860 case eSIR_SME_AP_CAPS_CHANGED:
9861 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009862 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009863 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9864 if( HAL_STATUS_SUCCESS( status ) )
9865 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009866 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9867 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309868 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009869 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9870 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9871 )
9872 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309873 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9874 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009875 }
9876 else
9877 {
9878 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309879 FL("Skipping csrScanForCapabilityChange as "
9880 "CSR is in state %s and sub-state %s"),
9881 macTraceGetcsrRoamState(
9882 pMac->roam.curState[sessionId]),
9883 macTraceGetcsrRoamSubState(
9884 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309885 /* We ignore the caps change event if CSR is not in full connected state.
9886 * Send one event to PE to reset limSentCapsChangeNtf
9887 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9888 * otherwise lim cannot send any CAPS change events to SME */
9889 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009891 }
9892 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309893
Jeff Johnson295189b2012-06-20 16:38:30 -07009894 default:
9895 roamStatus = eCSR_ROAM_FAILED;
9896 result = eCSR_ROAM_RESULT_NONE;
9897 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009898 } // end switch on statusChangeCode
9899 if(eCSR_ROAM_RESULT_NONE != result)
9900 {
9901 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9902 }
9903 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009904 case eWNI_SME_IBSS_NEW_PEER_IND:
9905 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009906#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9907 {
9908 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009909 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9910 if(pIbssLog)
9911 {
9912 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309913 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009914 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9915 }
9916 }
9917#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 sessionId = csrFindIbssSession( pMac );
9919 if( CSR_SESSION_ID_INVALID != sessionId )
9920 {
9921 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009922
9923 if(!pSession)
9924 {
9925 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9926 return;
9927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009928 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9929 if(pSession->pConnectBssDesc)
9930 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309931 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9932 sizeof(tCsrBssid));
9933 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9934 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009935 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9936 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309937 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9938 - sizeof(tSmeIbssPeerInd)));
9939 if ( NULL == roamInfo.pbFrames )
9940 status = eHAL_STATUS_FAILURE;
9941 else
9942 status = eHAL_STATUS_SUCCESS;
9943 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009944 {
9945 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309946 vos_mem_copy(roamInfo.pbFrames,
9947 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9948 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009949 }
9950 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9951 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9952 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309953 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9954 if ( NULL == roamInfo.pBssDesc )
9955 status = eHAL_STATUS_FAILURE;
9956 else
9957 status = eHAL_STATUS_SUCCESS;
9958 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309960 vos_mem_copy(roamInfo.pBssDesc,
9961 pSession->pConnectBssDesc,
9962 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009963 }
9964 if(HAL_STATUS_SUCCESS(status))
9965 {
9966 pRoamInfo = &roamInfo;
9967 }
9968 else
9969 {
9970 if(roamInfo.pbFrames)
9971 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309972 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009973 }
9974 if(roamInfo.pBssDesc)
9975 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309976 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009977 }
9978 }
9979 }
9980 else
9981 {
9982 pRoamInfo = &roamInfo;
9983 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009984 if ((eCSR_ENCRYPT_TYPE_NONE ==
9985 pSession->connectedProfile.EncryptionType ))
9986 {
9987 csrRoamIssueSetContextReq( pMac, sessionId,
9988 pSession->connectedProfile.EncryptionType,
9989 pSession->pConnectBssDesc,
9990 &(pIbssPeerInd->peerAddr),
9991 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009993 }
9994 else
9995 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009996 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009997 }
9998 //send up the sec type for the new peer
9999 if (pRoamInfo)
10000 {
10001 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10002 }
10003 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10004 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10005 if(pRoamInfo)
10006 {
10007 if(roamInfo.pbFrames)
10008 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010009 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010010 }
10011 if(roamInfo.pBssDesc)
10012 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010013 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010014 }
10015 }
10016 }
10017 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010018 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10019 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10020 sessionId = csrFindIbssSession( pMac );
10021 if( CSR_SESSION_ID_INVALID != sessionId )
10022 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010023#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10024 {
10025 vos_log_ibss_pkt_type *pIbssLog;
10026
10027 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10028 if(pIbssLog)
10029 {
10030 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10031 if(pIbssPeerInd)
10032 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010033 vos_mem_copy(pIbssLog->peerMacAddr,
10034 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010035 }
10036 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10037 }
10038 }
10039#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010040 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010041 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10042 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10043 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010044 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10045 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010046 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10047 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10048 }
10049 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010050 case eWNI_SME_SETCONTEXT_RSP:
10051 {
10052 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10053 tListElem *pEntry;
10054 tSmeCmd *pCommand;
10055
10056 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10057 if ( pEntry )
10058 {
10059 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10060 if ( eSmeCommandSetKey == pCommand->command )
10061 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010062 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010063 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010064
10065 if(!pSession)
10066 {
10067 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10068 return;
10069 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010070
10071#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10072 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10073 {
10074 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010075 vos_mem_set(&setKeyEvent,
10076 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010077 if( pRsp->peerMacAddr[0] & 0x01 )
10078 {
10079 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
10080 }
10081 else
10082 {
10083 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
10084 }
10085 setKeyEvent.encryptionModeMulticast =
10086 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10087 setKeyEvent.encryptionModeUnicast =
10088 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010089 vos_mem_copy(setKeyEvent.bssid,
10090 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010091 setKeyEvent.authMode =
10092 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010093 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010094 {
10095 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10096 }
10097 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10098 }
10099#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10100 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10101 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010102 csrRoamStopWaitForKeyTimer( pMac );
10103
Jeff Johnson295189b2012-06-20 16:38:30 -070010104 //We are done with authentication, whethere succeed or not
10105 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010106 //We do it here because this linkup function is not called after association
10107 //when a key needs to be set.
10108 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10109 {
10110 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10111 }
10112 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010113 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010114 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010115 vos_mem_copy(&roamInfo.peerMac,
10116 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010117 //Make sure we install the GTK before indicating to HDD as authenticated
10118 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010119 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10120 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010121 {
Yathish9f22e662012-12-10 14:21:35 -080010122#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10123 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10124 {
10125 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010126 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010127 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
10128 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
10129 pMsg->seesionId = sessionId;
10130 status = palSendMBMessage(pMac->hHdd, pMsg );
10131 }
10132#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010133 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010134 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
10135 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE )
10136 {
10137 tpSirSmeHT40OBSSScanInd pMsg;
10138 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10139 pMsg->messageType =
10140 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10141 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010142 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10143 vos_mem_copy(pMsg->peerMacAddr,
10144 pSession->connectedProfile.bssid,
10145 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010146 status = palSendMBMessage(pMac->hHdd,
10147 pMsg );
10148 }
10149 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010150 }
10151 else
10152 {
10153 result = eCSR_ROAM_RESULT_NONE;
10154 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010155 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010156 }
10157 else
10158 {
10159 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010160 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10161 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10162 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010163 }
10164 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10165 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010166 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10167 // can go ahead and initiate the TSPEC if any are pending
10168 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010169#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010170 //Send Adjacent AP repot to new AP.
10171 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10172 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010173 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010174 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010175#ifdef FEATURE_WLAN_ESE_UPLOAD
10176 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010177#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010178 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010179#endif
10180 pSession->isPrevApInfoValid = FALSE;
10181 }
10182#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010183 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10184 {
10185 csrReleaseCommandSetKey( pMac, pCommand );
10186 }
10187 }
10188 else
10189 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010190 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010191 }
10192 }
10193 else
10194 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010195 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010196 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010197 smeProcessPendingQueue( pMac );
10198 }
10199 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010200 case eWNI_SME_REMOVEKEY_RSP:
10201 {
10202 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10203 tListElem *pEntry;
10204 tSmeCmd *pCommand;
10205
10206 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10207 if ( pEntry )
10208 {
10209 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10210 if ( eSmeCommandRemoveKey == pCommand->command )
10211 {
10212 sessionId = pCommand->sessionId;
10213 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010214
10215 if(!pSession)
10216 {
10217 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10218 return;
10219 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010220#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10221 {
10222 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010223 vos_mem_set(&removeKeyEvent,
10224 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010225 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10226 removeKeyEvent.encryptionModeMulticast =
10227 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10228 removeKeyEvent.encryptionModeUnicast =
10229 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010230 vos_mem_copy( removeKeyEvent.bssid,
10231 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010232 removeKeyEvent.authMode =
10233 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010234 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010235 {
10236 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10237 }
10238 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10239 }
10240#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010241 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010242 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010243 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10244 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010245 result = eCSR_ROAM_RESULT_NONE;
10246 pRoamInfo = &roamInfo;
10247 }
10248 else
10249 {
10250 result = eCSR_ROAM_RESULT_FAILURE;
10251 }
10252 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10253 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10254 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10255 {
10256 csrReleaseCommandRemoveKey( pMac, pCommand );
10257 }
10258 }
10259 else
10260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010261 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010262 }
10263 }
10264 else
10265 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010266 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010267 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010268 smeProcessPendingQueue( pMac );
10269 }
10270 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010271 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010272 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010273 csrRoamStatsRspProcessor( pMac, pSirMsg );
10274 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010275#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010276 case eWNI_SME_GET_ROAM_RSSI_RSP:
10277 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10278 csrRoamRssiRspProcessor( pMac, pSirMsg );
10279 break;
10280#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010281#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010282 case eWNI_SME_GET_TSM_STATS_RSP:
10283 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10284 csrTsmStatsRspProcessor( pMac, pSirMsg );
10285 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010286#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010287 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010288 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010289 csrUpdateRssi( pMac, pSirMsg );
10290 break;
10291
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010292 case eWNI_SME_GET_SNR_REQ:
10293 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10294 csrUpdateSnr(pMac, pSirMsg);
10295 break;
10296
Jeff Johnson295189b2012-06-20 16:38:30 -070010297#ifdef WLAN_FEATURE_VOWIFI_11R
10298 case eWNI_SME_FT_PRE_AUTH_RSP:
10299 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10300 break;
10301#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010302 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10303 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010304 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 -070010305 sessionId = pSmeMaxAssocInd->sessionId;
10306 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010307 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10308 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010309 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10310 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10311 break;
10312
10313 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010314 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010315 btampEstablishLogLinkHdlr( pSirMsg );
10316 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010317 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010318 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010319 csrRoamRssiIndHdlr( pMac, pSirMsg );
10320 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010321#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10322 case eWNI_SME_CANDIDATE_FOUND_IND:
10323 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10324 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10325 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010326 case eWNI_SME_HANDOFF_REQ:
10327 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10328 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10329 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010330#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010331
10332 default:
10333 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010334 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010335}
10336
Jeff Johnson295189b2012-06-20 16:38:30 -070010337void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10338 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10339{
10340 if(pSession)
10341 {
10342 if(pSession->bRefAssocStartCnt)
10343 {
10344 pSession->bRefAssocStartCnt--;
10345 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10346 //Need to call association_completion because there is an assoc_start pending.
10347 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10348 eCSR_ROAM_ASSOCIATION_COMPLETION,
10349 eCSR_ROAM_RESULT_FAILURE);
10350 }
10351 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10352 }
10353 else
10354 {
10355 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10356 }
10357}
10358
10359
10360eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10361{
10362 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010363 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10364 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10365 {
10366 status = csrScanRequestLostLink1( pMac, sessionId );
10367 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010368 return(status);
10369}
10370
Jeff Johnson295189b2012-06-20 16:38:30 -070010371//return a boolean to indicate whether roaming completed or continue.
10372tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10373 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10374{
10375 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10376 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10377 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10378 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010379 if(!pSession)
10380 {
10381 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10382 return eANI_BOOLEAN_FALSE;
10383 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010384 //Check whether time is up
10385 if(pSession->fCancelRoaming || fForce ||
10386 ((curTime - pSession->roamingStartTime) > roamTime) ||
10387 eCsrReassocRoaming == pSession->roamingReason ||
10388 eCsrDynamicRoaming == pSession->roamingReason)
10389 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010390 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010391 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10392 {
10393 //roaming is cancelled, tell HDD to indicate disconnect
10394 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10395 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10396 //to be eSIR_BEACON_MISSED
10397 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10398 {
10399 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10400 }
10401 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10402 {
10403 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10404 }
10405 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10406 {
10407 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10408 }
10409 else
10410 {
10411 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10412 }
10413 }
10414 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10415 pSession->roamingReason = eCsrNotRoaming;
10416 }
10417 else
10418 {
10419 pSession->roamResult = roamResult;
10420 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10421 {
10422 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10423 pSession->roamingReason = eCsrNotRoaming;
10424 }
10425 else
10426 {
10427 fCompleted = eANI_BOOLEAN_FALSE;
10428 }
10429 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010430 return(fCompleted);
10431}
10432
Jeff Johnson295189b2012-06-20 16:38:30 -070010433void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10434{
10435 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010436
10437 if(!pSession)
10438 {
10439 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10440 return;
10441 }
10442
Jeff Johnson295189b2012-06-20 16:38:30 -070010443 if(CSR_IS_ROAMING(pSession))
10444 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010445 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010446 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10447 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10448 {
10449 //No need to do anything in here because the handler takes care of it
10450 }
10451 else
10452 {
10453 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10454 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10455 //Roaming is stopped after here
10456 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10457 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010458 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010459 csrRoamStopRoamingTimer(pMac, sessionId);
10460 }
10461 }
10462}
10463
Jeff Johnson295189b2012-06-20 16:38:30 -070010464void csrRoamRoamingTimerHandler(void *pv)
10465{
10466 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10467 tpAniSirGlobal pMac = pInfo->pMac;
10468 tANI_U32 sessionId = pInfo->sessionId;
10469 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010470
10471 if(!pSession)
10472 {
10473 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10474 return;
10475 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010476
10477 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10478 {
10479 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10480 {
10481 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10482 pSession->roamingReason = eCsrNotRoaming;
10483 }
10484 }
10485}
10486
Jeff Johnson295189b2012-06-20 16:38:30 -070010487eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10488{
10489 eHalStatus status;
10490 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010491
10492 if(!pSession)
10493 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010494 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010495 return eHAL_STATUS_FAILURE;
10496 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010497
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010498 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010499 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010500 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010501
10502 return (status);
10503}
10504
Jeff Johnson295189b2012-06-20 16:38:30 -070010505eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10506{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010507 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010508}
10509
Jeff Johnson295189b2012-06-20 16:38:30 -070010510void csrRoamWaitForKeyTimeOutHandler(void *pv)
10511{
10512 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10513 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010514 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010515 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010516
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010517 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10518 macTraceGetNeighbourRoamState(
10519 pMac->roam.neighborRoamInfo.neighborRoamState),
10520 macTraceGetcsrRoamSubState(
10521 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010522
Jeff Johnson295189b2012-06-20 16:38:30 -070010523 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10524 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010525#ifdef FEATURE_WLAN_LFR
10526 if (csrNeighborRoamIsHandoffInProgress(pMac))
10527 {
10528 /*
10529 * Enable heartbeat timer when hand-off is in progress
10530 * and Key Wait timer expired.
10531 */
10532 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010533 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010534 pMac->roam.configParam.HeartbeatThresh24);
10535 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10536 pMac->roam.configParam.HeartbeatThresh24,
10537 NULL, eANI_BOOLEAN_FALSE);
10538 }
10539#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010540 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010541
Jeff Johnson295189b2012-06-20 16:38:30 -070010542 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010543 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10544 {
10545 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10546 pInfo->sessionId);
10547 }
10548
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010549 if (pSession)
10550 {
10551 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10552 {
10553 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10554 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010555 if( (pSession->connectedProfile.AuthType ==
10556 eCSR_AUTH_TYPE_SHARED_KEY) &&
10557 ( (pSession->connectedProfile.EncryptionType ==
10558 eCSR_ENCRYPT_TYPE_WEP40) ||
10559 (pSession->connectedProfile.EncryptionType ==
10560 eCSR_ENCRYPT_TYPE_WEP104) ))
10561 {
10562 status = sme_AcquireGlobalLock( &pMac->sme );
10563 if ( HAL_STATUS_SUCCESS( status ) )
10564 {
10565 csrRoamDisconnect( pMac, pInfo->sessionId,
10566 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10567 sme_ReleaseGlobalLock( &pMac->sme );
10568 }
10569 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010570 }
10571 else
10572 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010573 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010574 __func__);
10575 }
10576 }
10577 else
10578 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010579 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010580 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010581 }
10582
10583}
10584
Jeff Johnson295189b2012-06-20 16:38:30 -070010585eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10586{
10587 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010588#ifdef FEATURE_WLAN_LFR
10589 if (csrNeighborRoamIsHandoffInProgress(pMac))
10590 {
10591 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010592 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10593 macTraceGetNeighbourRoamState(
10594 pMac->roam.neighborRoamInfo.neighborRoamState),
10595 macTraceGetcsrRoamSubState(
10596 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10597 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010598 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10599 }
10600#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010601 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010602 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010603
10604 return (status);
10605}
10606
Jeff Johnson295189b2012-06-20 16:38:30 -070010607eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10608{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010609 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10610 macTraceGetNeighbourRoamState(
10611 pMac->roam.neighborRoamInfo.neighborRoamState),
10612 macTraceGetcsrRoamSubState(
10613 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010614#ifdef FEATURE_WLAN_LFR
10615 if (csrNeighborRoamIsHandoffInProgress(pMac))
10616 {
10617 /*
10618 * Enable heartbeat timer when hand-off is in progress
10619 * and Key Wait timer got stopped for some reason
10620 */
10621 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010622 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010623 pMac->roam.configParam.HeartbeatThresh24);
10624 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10625 pMac->roam.configParam.HeartbeatThresh24,
10626 NULL, eANI_BOOLEAN_FALSE);
10627 }
10628#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010629 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010630}
10631
Jeff Johnson295189b2012-06-20 16:38:30 -070010632void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10633 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10634{
10635 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10636 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010637 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10638 /* To silence the KW tool Null chaeck is added */
10639 if(!pSession)
10640 {
10641 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10642 return;
10643 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010644
10645 if(pCommand)
10646 {
10647 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010648 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010649 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010650 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10651 {
10652 //if success, force roaming completion
10653 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10654 }
10655 else
10656 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010657 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010658 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010659 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10660 }
10661}
10662
Jeff Johnson295189b2012-06-20 16:38:30 -070010663eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10664{
10665 eHalStatus status = eHAL_STATUS_SUCCESS;
10666 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10667 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10668 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10669 tCsrRoamInfo *pRoamInfo = NULL;
10670 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010671 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010672 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010673 /* To silence the KW tool Null chaeck is added */
10674 if(!pSession)
10675 {
10676 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10677 return eHAL_STATUS_FAILURE;
10678 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010679 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010680 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010681 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10682 if ( eWNI_SME_DISASSOC_IND == type )
10683 {
10684 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10685 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10686 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010687 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010688 }
10689 else if ( eWNI_SME_DEAUTH_IND == type )
10690 {
10691 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10692 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10693 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010694 /* Convert into proper reason code */
10695 pSession->joinFailStatusCode.reasonCode =
10696 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010697 0 : pDeauthIndMsg->reasonCode;
10698 /* cfg layer expects 0 as reason code if
10699 the driver dosent know the reason code
10700 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010701 }
10702 else
10703 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010704 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010705 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010706 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010707 }
10708
10709 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010710 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010711 {
10712 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10713 }
10714
10715 if ( eWNI_SME_DISASSOC_IND == type )
10716 {
10717 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10718 }
10719 else if ( eWNI_SME_DEAUTH_IND == type )
10720 {
10721 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10722 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010723 if(!HAL_STATUS_SUCCESS(status))
10724 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010725 //If fail to send confirmation to PE, not to trigger roaming
10726 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010727 }
10728
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010729 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010730 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010731 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10732 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010733 if( eWNI_SME_DISASSOC_IND == type)
10734 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010735 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010736 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10737 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010738 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10739 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010740 else if( eWNI_SME_DEAUTH_IND == type )
10741 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010742 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010743 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10744 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010745 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10746 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010747 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010748
10749 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10750 that we are roaming. But if we cannot possibly roam, or if we are unable to
10751 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010752 if(fToRoam)
10753 {
10754 //Only remove the connected BSS in infrastructure mode
10755 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10756 //Not to do anying for lostlink with WDS
10757 if( pMac->roam.configParam.nRoamingTime )
10758 {
10759 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10760 ( eWNI_SME_DEAUTH_IND == type ) ?
10761 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10762 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010763 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010764 //For IBSS, we need to give some more info to HDD
10765 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10766 {
10767 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10768 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10769 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10770 }
10771 else
10772 {
10773 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10774 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010775 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010776 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10777 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10778 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10779 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10780 }
10781 else
10782 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010783 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010784 fToRoam = eANI_BOOLEAN_FALSE;
10785 }
10786 }
10787 else
10788 {
10789 //We are told not to roam, indicate lostlink
10790 fToRoam = eANI_BOOLEAN_FALSE;
10791 }
10792 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010793 if(!fToRoam)
10794 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010795 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010796 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010797 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010798 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10799 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10800 * csrRoamCheckForLinkStatusChange API.
10801 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010802 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10803 }
10804
10805 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010806 Still enable idle scan for polling in case concurrent sessions are running */
10807 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10808 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010809 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010810 }
10811 }
10812
10813 return (status);
10814}
10815
Jeff Johnson295189b2012-06-20 16:38:30 -070010816eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10817{
10818 eHalStatus status = eHAL_STATUS_SUCCESS;
10819 tListElem *pEntry = NULL;
10820 tSmeCmd *pCommand = NULL;
10821 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010822
10823 if(!pSession)
10824 {
10825 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10826 return eHAL_STATUS_FAILURE;
10827 }
10828
Jeff Johnson295189b2012-06-20 16:38:30 -070010829 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010830 //Only remove the connected BSS in infrastructure mode
10831 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10832 if(pMac->roam.configParam.nRoamingTime)
10833 {
10834 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10835 {
10836 //before starting the lost link logic release the roam command for handoff
10837 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10838 if(pEntry)
10839 {
10840 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10841 }
10842 if(pCommand)
10843 {
10844 if (( eSmeCommandRoam == pCommand->command ) &&
10845 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10846 {
10847 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10848 {
10849 csrReleaseCommandRoam( pMac, pCommand );
10850 }
10851 }
10852 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010853 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010854 }
10855 }
10856 else
10857 {
10858 //We are told not to roam, indicate lostlink
10859 status = eHAL_STATUS_FAILURE;
10860 }
10861
10862 return (status);
10863}
Jeff Johnson295189b2012-06-20 16:38:30 -070010864void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10865{
10866 tListElem *pEntry;
10867 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010868 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10869 if ( pEntry )
10870 {
10871 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10872 if ( eSmeCommandWmStatusChange == pCommand->command )
10873 {
10874 // Nothing to process in a Lost Link completion.... It just kicks off a
10875 // roaming sequence.
10876 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10877 {
10878 csrReleaseCommandWmStatusChange( pMac, pCommand );
10879 }
10880 else
10881 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010882 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010883 }
10884
10885 }
10886 else
10887 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010888 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010889 }
10890 }
10891 else
10892 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010893 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010894 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010895 smeProcessPendingQueue( pMac );
10896}
10897
Jeff Johnson295189b2012-06-20 16:38:30 -070010898void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10899{
10900 eHalStatus status = eHAL_STATUS_FAILURE;
10901 tSirSmeRsp *pSirSmeMsg;
10902 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010903
10904 if(!pSession)
10905 {
10906 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10907 return;
10908 }
10909
Jeff Johnson295189b2012-06-20 16:38:30 -070010910 switch ( pCommand->u.wmStatusChangeCmd.Type )
10911 {
10912 case eCsrDisassociated:
10913 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10914 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10915 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010916 case eCsrDeauthenticated:
10917 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10918 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10919 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010920 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010921 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010922 break;
10923 }
10924 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10925 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10926 {
10927 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10928 {
10929 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010930 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010931 }
10932 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010933 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10934 // command here since there is nothing else to do.
10935 csrRoamWmStatusChangeComplete( pMac );
10936}
10937
Jeff Johnson295189b2012-06-20 16:38:30 -070010938//This function returns band and mode information.
10939//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10940//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010941static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10942 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010943{
Jeff Johnson295189b2012-06-20 16:38:30 -070010944 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10945 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10946 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010947 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010948
Jeff Johnson295189b2012-06-20 16:38:30 -070010949 //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 -070010950 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10951 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10952 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10953 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010954 {
10955 switch( pMac->roam.configParam.uCfgDot11Mode )
10956 {
10957 case eCSR_CFG_DOT11_MODE_11A:
10958 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10959 eBand = eCSR_BAND_5G;
10960 break;
10961 case eCSR_CFG_DOT11_MODE_11B:
10962 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10963 eBand = eCSR_BAND_24;
10964 break;
10965 case eCSR_CFG_DOT11_MODE_11G:
10966 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10967 eBand = eCSR_BAND_24;
10968 break;
10969 case eCSR_CFG_DOT11_MODE_11N:
10970 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010971 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10972 break;
10973#ifdef WLAN_FEATURE_11AC
10974 case eCSR_CFG_DOT11_MODE_11AC:
10975 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10976 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010977 /* If the operating channel is in 2.4 GHz band, check for
10978 * INI item to disable VHT operation in 2.4 GHz band
10979 */
10980 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10981 !pMac->roam.configParam.enableVhtFor24GHz)
10982 {
10983 /* Disable 11AC operation */
10984 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10985 }
10986 else
10987 {
10988 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10989 }
10990 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010991 }
10992 else
10993 {
10994 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10995 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10996 }
10997 break;
10998 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10999 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11000 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011001 /* If the operating channel is in 2.4 GHz band, check for
11002 * INI item to disable VHT operation in 2.4 GHz band
11003 */
11004 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11005 !pMac->roam.configParam.enableVhtFor24GHz)
11006 {
11007 /* Disable 11AC operation */
11008 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11009 }
11010 else
11011 {
11012 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11013 }
11014 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011015 }
11016 else
11017 {
11018 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11019 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11020 }
11021 break;
11022#endif
11023 case eCSR_CFG_DOT11_MODE_AUTO:
11024 eBand = pMac->roam.configParam.eBand;
11025 if (eCSR_BAND_24 == eBand)
11026 {
11027 // WiFi tests require IBSS networks to start in 11b mode
11028 // without any change to the default parameter settings
11029 // on the adapter. We use ACU to start an IBSS through
11030 // creation of a startIBSS profile. This startIBSS profile
11031 // has Auto MACProtocol and the adapter property setting
11032 // for dot11Mode is also AUTO. So in this case, let's
11033 // start the IBSS network in 11b mode instead of 11g mode.
11034 // So this is for Auto=profile->MacProtocol && Auto=Global.
11035 // dot11Mode && profile->channel is < 14, then start the IBSS
11036 // in b mode.
11037 //
11038 // Note: we used to have this start as an 11g IBSS for best
11039 // performance... now to specify that the user will have to
11040 // set the do11Mode in the property page to 11g to force it.
11041 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11042 }
11043 else
11044 {
11045#ifdef WLAN_FEATURE_11AC
11046 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11047 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011048 /* If the operating channel is in 2.4 GHz band, check for
11049 * INI item to disable VHT operation in 2.4 GHz band
11050 */
11051 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11052 !pMac->roam.configParam.enableVhtFor24GHz)
11053 {
11054 /* Disable 11AC operation */
11055 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11056 }
11057 else
11058 {
11059 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11060 }
11061 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011062 }
11063 else
11064 {
11065 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11066 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11067 }
11068#else
11069 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11070 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11071#endif
11072 }
11073 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011074 default:
11075 // Global dot11 Mode setting is 11a/b/g.
11076 // use the channel number to determine the Mode setting.
11077 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11078 {
11079 eBand = pMac->roam.configParam.eBand;
11080 if(eCSR_BAND_24 == eBand)
11081 {
11082 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11083 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11084 }
11085 else
11086 {
11087 //prefer 5GHz
11088 eBand = eCSR_BAND_5G;
11089 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11090 }
11091 }
11092 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11093 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011094 // WiFi tests require IBSS networks to start in 11b mode
11095 // without any change to the default parameter settings
11096 // on the adapter. We use ACU to start an IBSS through
11097 // creation of a startIBSS profile. This startIBSS profile
11098 // has Auto MACProtocol and the adapter property setting
11099 // for dot11Mode is also AUTO. So in this case, let's
11100 // start the IBSS network in 11b mode instead of 11g mode.
11101 // So this is for Auto=profile->MacProtocol && Auto=Global.
11102 // dot11Mode && profile->channel is < 14, then start the IBSS
11103 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011104 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011105 // Note: we used to have this start as an 11g IBSS for best
11106 // performance... now to specify that the user will have to
11107 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011108 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11109 eBand = eCSR_BAND_24;
11110 }
11111 else
11112 {
11113 // else, it's a 5.0GHz channel. Set mode to 11a.
11114 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11115 eBand = eCSR_BAND_5G;
11116 }
11117 break;
11118 }//switch
11119 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11120 else
11121 {
11122 //dot11 mode is set, lets pick the band
11123 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11124 {
11125 // channel is Auto also.
11126 eBand = pMac->roam.configParam.eBand;
11127 if(eCSR_BAND_ALL == eBand)
11128 {
11129 //prefer 5GHz
11130 eBand = eCSR_BAND_5G;
11131 }
11132 }
11133 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11134 {
11135 eBand = eCSR_BAND_24;
11136 }
11137 else
11138 {
11139 eBand = eCSR_BAND_5G;
11140 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011141 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011142 if(pBand)
11143 {
11144 *pBand = eBand;
11145 }
11146
11147 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011148 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011149 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11150 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011151
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011152 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11153 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 -070011154 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011155#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011156 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011157#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011158 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11159 {
11160 //We cannot do 11n here
11161 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11162 {
11163 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11164 }
11165 else
11166 {
11167 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11168 }
11169 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011170 return( cfgDot11Mode );
11171}
11172
Jeff Johnson295189b2012-06-20 16:38:30 -070011173eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11174{
11175 eHalStatus status;
11176 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011177
11178 if(!pSession)
11179 {
11180 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11181 return eHAL_STATUS_FAILURE;
11182 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011183
11184#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11185 {
11186 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011187 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11188 if(pIbssLog)
11189 {
11190 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11191 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11192 }
11193 }
11194#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011195 // Set the roaming substate to 'stop Bss request'...
11196 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11197
11198 // attempt to stop the Bss (reason code is ignored...)
11199 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011200 if(!HAL_STATUS_SUCCESS(status))
11201 {
11202 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11203 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011204 return (status);
11205}
11206
Jeff Johnson295189b2012-06-20 16:38:30 -070011207//pNumChan is a caller allocated space with the sizeof pChannels
11208eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11209{
11210
11211 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11212 (tANI_U8 *)pChannels,
11213 pNumChan));
11214}
11215
Kiran4a17ebe2013-01-31 10:43:43 -080011216tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11217{
11218 tANI_U32 cfgLength = 0;
11219 tANI_U16 cfgId = 0;
11220 tPowerdBm maxTxPwr = 0;
11221 tANI_U8 *pCountryInfo = NULL;
11222 eHalStatus status;
11223 tANI_U8 count = 0;
11224 tANI_U8 firstChannel;
11225 tANI_U8 maxChannels;
11226
11227 if (CSR_IS_CHANNEL_5GHZ(channel))
11228 {
11229 cfgId = WNI_CFG_MAX_TX_POWER_5;
11230 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11231 }
11232 else if (CSR_IS_CHANNEL_24GHZ(channel))
11233 {
11234 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11235 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11236 }
11237 else
11238 return maxTxPwr;
11239
Kiet Lam64c1b492013-07-12 13:56:44 +053011240 pCountryInfo = vos_mem_malloc(cfgLength);
11241 if ( NULL == pCountryInfo )
11242 status = eHAL_STATUS_FAILURE;
11243 else
11244 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011245 if (status != eHAL_STATUS_SUCCESS)
11246 {
11247 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011248 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011249 __FUNCTION__, status);
11250 goto error;
11251 }
11252 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11253 if (status != eHAL_STATUS_SUCCESS)
11254 {
11255 goto error;
11256 }
11257 /* Identify the channel and maxtxpower */
11258 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11259 {
11260 firstChannel = pCountryInfo[count++];
11261 maxChannels = pCountryInfo[count++];
11262 maxTxPwr = pCountryInfo[count++];
11263
11264 if ((channel >= firstChannel) &&
11265 (channel < (firstChannel + maxChannels)))
11266 {
11267 break;
11268 }
11269 }
11270
11271error:
11272 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011273 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011274
11275 return maxTxPwr;
11276}
11277
11278
Jeff Johnson295189b2012-06-20 16:38:30 -070011279tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11280{
11281 tANI_BOOLEAN fValid = FALSE;
11282 tANI_U32 idxValidChannels;
11283 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11284
11285 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11286 {
11287 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11288 {
11289 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11290 {
11291 fValid = TRUE;
11292 break;
11293 }
11294 }
11295 }
11296 pMac->roam.numValidChannels = len;
11297 return fValid;
11298}
11299
Jeff Johnson295189b2012-06-20 16:38:30 -070011300tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11301{
11302 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11303 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011304 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11305 {
11306 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11307 {
11308 fValid = eANI_BOOLEAN_TRUE;
11309 break;
11310 }
11311 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011312 return (fValid);
11313}
11314
Jeff Johnson295189b2012-06-20 16:38:30 -070011315//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011316 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011317{
Jeff Johnsone7245742012-09-05 17:12:55 -070011318 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011319 tANI_U8 centerChn;
11320 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011321
Jeff Johnson295189b2012-06-20 16:38:30 -070011322 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11323 {
11324 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11325 }
11326 else
11327 {
11328 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11329 }
11330 //Figure what the other side's CB mode
11331 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11332 {
11333 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11334 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011335 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11336 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11337 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11338 "\x00\x0f\xac\x02",4))
11339 //In Case WPA1 and TKIP is the only one cipher suite in Unicast.
11340 ||(pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
11341 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
11342 "\x00\x50\xf2\x02",4)))
11343
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011344 {
11345 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11346 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11347 }
11348
11349 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011350 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011351 /* This is called during INFRA STA/CLIENT and should use the merged value of
11352 * supported channel width and recommended tx width as per standard
11353 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011354 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011355 pIes->HTCaps.supportedChannelWidthSet,
11356 pIes->HTInfo.recommendedTxWidthSet,
11357 pIes->HTInfo.secondaryChannelOffset);
11358
11359 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11360 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011361 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011362 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11363 switch (eRet) {
11364 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11365 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11366 break;
11367 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11368 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11369 break;
11370 case PHY_SINGLE_CHANNEL_CENTERED:
11371 default:
11372 centerChn = primaryChn;
11373 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011375 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011376 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011377 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053011378 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011379 }
11380 }
11381 }
11382 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011383 return eRet;
11384}
Jeff Johnson295189b2012-06-20 16:38:30 -070011385tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11386{
11387 tANI_BOOLEAN fFound = FALSE;
11388 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011389 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11390 {
11391 if( pCipherList->encryptionType[idx] == encryptionType )
11392 {
11393 fFound = TRUE;
11394 break;
11395 }
11396 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011397 return fFound;
11398}
Jeff Johnson295189b2012-06-20 16:38:30 -070011399tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11400{
11401 tANI_BOOLEAN fFound = FALSE;
11402 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011403 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11404 {
11405 if( pAuthList->authType[idx] == authType )
11406 {
11407 fFound = TRUE;
11408 break;
11409 }
11410 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011411 return fFound;
11412}
Jeff Johnson295189b2012-06-20 16:38:30 -070011413tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11414{
11415 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11416 tCsrScanResultFilter *pScanFilter = NULL;
11417 eHalStatus status = eHAL_STATUS_SUCCESS;
11418
11419 if(pProfile1 && pProfile2)
11420 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011421 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11422 if ( NULL == pScanFilter )
11423 status = eHAL_STATUS_FAILURE;
11424 else
11425 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011426 if(HAL_STATUS_SUCCESS(status))
11427 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011428 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011429 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11430 if(HAL_STATUS_SUCCESS(status))
11431 {
11432 fCheck = eANI_BOOLEAN_FALSE;
11433 do
11434 {
11435 tANI_U32 i;
11436 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11437 {
11438 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11439 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11440 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11441 if ( fCheck ) break;
11442 }
11443 if(!fCheck)
11444 {
11445 break;
11446 }
11447 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11448 || pProfile2->BSSType != pProfile1->BSSType
11449 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11450 )
11451 {
11452 fCheck = eANI_BOOLEAN_FALSE;
11453 break;
11454 }
11455#ifdef WLAN_FEATURE_VOWIFI_11R
11456 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11457 {
11458 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11459 {
11460 fCheck = eANI_BOOLEAN_FALSE;
11461 break;
11462 }
11463 }
11464#endif
11465 //Match found
11466 fCheck = eANI_BOOLEAN_TRUE;
11467 }while(0);
11468 csrFreeScanFilter(pMac, pScanFilter);
11469 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011470 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011471 }
11472 }
11473
11474 return (fCheck);
11475}
11476
Jeff Johnson295189b2012-06-20 16:38:30 -070011477tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11478{
11479 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11480 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011481 do
11482 {
11483 //Only check for static WEP
11484 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11485 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11486 {
11487 fCheck = eANI_BOOLEAN_TRUE;
11488 break;
11489 }
11490 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11491 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11492 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11493 {
11494 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011495 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11496 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011497 {
11498 break;
11499 }
11500 }
11501 if( i == CSR_MAX_NUM_KEY)
11502 {
11503 fCheck = eANI_BOOLEAN_TRUE;
11504 }
11505 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011506 return (fCheck);
11507}
11508
Jeff Johnson295189b2012-06-20 16:38:30 -070011509//IBSS
11510
Jeff Johnson295189b2012-06-20 16:38:30 -070011511tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11512{
11513 tANI_U8 channel = 0;
11514 tANI_U32 idx;
11515 tANI_U32 idxValidChannels;
11516 tANI_BOOLEAN fFound = FALSE;
11517 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11518
11519 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11520 {
11521 channel = pMac->roam.configParam.AdHocChannel5G;
11522 if(!csrRoamIsChannelValid(pMac, channel))
11523 {
11524 channel = 0;
11525 }
11526 }
11527 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11528 {
11529 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11530 {
11531 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11532 {
11533 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11534 {
11535 fFound = TRUE;
11536 channel = csrStartIbssChannels50[ idx ];
11537 }
11538 }
11539 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011540 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11541 if (!fFound)
11542 {
11543 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11544 {
11545 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11546 {
11547 channel = csrStartIbssChannels50[ idx ];
11548 break;
11549 }
11550 }
11551 }
11552 }//if
11553
11554 return( channel );
11555}
11556
Jeff Johnson295189b2012-06-20 16:38:30 -070011557tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11558{
11559 tANI_U8 channel = 1;
11560 tANI_U32 idx;
11561 tANI_U32 idxValidChannels;
11562 tANI_BOOLEAN fFound = FALSE;
11563 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11564
11565 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11566 {
11567 channel = pMac->roam.configParam.AdHocChannel24;
11568 if(!csrRoamIsChannelValid(pMac, channel))
11569 {
11570 channel = 0;
11571 }
11572 }
11573
11574 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11575 {
11576 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11577 {
11578 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11579 {
11580 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11581 {
11582 fFound = TRUE;
11583 channel = csrStartIbssChannels24[ idx ];
11584 }
11585 }
11586 }
11587 }
11588
11589 return( channel );
11590}
11591
Jeff Johnson295189b2012-06-20 16:38:30 -070011592static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11593 tCsrRoamStartBssParams *pParam )
11594{
11595 eCsrCfgDot11Mode cfgDot11Mode;
11596 eCsrBand eBand;
11597 tANI_U8 channel = 0;
11598 tSirNwType nwType;
11599 tANI_U8 operationChannel = 0;
11600
11601 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11602 {
11603 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11604 }
11605
Jeff Johnson295189b2012-06-20 16:38:30 -070011606 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011607
Jeff Johnson295189b2012-06-20 16:38:30 -070011608 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11609 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11610 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11611 )
11612 {
11613 /* This should never happen */
11614 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011615 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011616 pProfile->csrPersona);
11617 VOS_ASSERT(0);
11618 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011619 switch( cfgDot11Mode )
11620 {
11621 case eCSR_CFG_DOT11_MODE_11G:
11622 nwType = eSIR_11G_NW_TYPE;
11623 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011624 case eCSR_CFG_DOT11_MODE_11B:
11625 nwType = eSIR_11B_NW_TYPE;
11626 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011627 case eCSR_CFG_DOT11_MODE_11A:
11628 nwType = eSIR_11A_NW_TYPE;
11629 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011630 default:
11631 case eCSR_CFG_DOT11_MODE_11N:
11632 case eCSR_CFG_DOT11_MODE_TAURUS:
11633 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11634 if(eCSR_BAND_24 == eBand)
11635 {
11636 nwType = eSIR_11G_NW_TYPE;
11637 }
11638 else
11639 {
11640 nwType = eSIR_11A_NW_TYPE;
11641 }
11642 break;
11643 }
11644
11645 pParam->extendedRateSet.numRates = 0;
11646
11647 switch ( nwType )
11648 {
11649 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011650 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011651 case eSIR_11A_NW_TYPE:
11652
11653 pParam->operationalRateSet.numRates = 8;
11654
11655 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11656 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11657 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11658 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11659 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11660 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11661 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11662 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11663
11664 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11665 {
11666 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11667 if( 0 == channel &&
11668 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11669 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11670 )
11671 {
11672 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11673 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11674 nwType = eSIR_11B_NW_TYPE;
11675 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11676 pParam->operationalRateSet.numRates = 4;
11677 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11678 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11679 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11680 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11681 }
11682 }
11683 else
11684 {
11685 channel = operationChannel;
11686 }
11687 break;
11688
11689 case eSIR_11B_NW_TYPE:
11690 pParam->operationalRateSet.numRates = 4;
11691 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11692 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11693 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11694 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011695 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11696 {
11697 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11698 }
11699 else
11700 {
11701 channel = operationChannel;
11702 }
11703
11704 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011705 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011706 /* For P2P Client and P2P GO, disable 11b rates */
11707 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11708 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11709 )
11710 {
11711 pParam->operationalRateSet.numRates = 8;
11712
11713 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11714 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11715 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11716 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11717 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11718 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11719 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11720 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11721 }
11722 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011723 {
11724 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011725 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11726 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11727 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11728 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11729
11730 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011731 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11732 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11733 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11734 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11735 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11736 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11737 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11738 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11739 }
11740
11741 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11742 {
11743 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11744 }
11745 else
11746 {
11747 channel = operationChannel;
11748 }
11749
11750 break;
11751 }
11752 pParam->operationChn = channel;
11753 pParam->sirNwType = nwType;
11754}
11755
Jeff Johnson295189b2012-06-20 16:38:30 -070011756static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11757 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11758{
11759
11760 if( pParam )
11761 {
11762 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011763 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011764 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011765 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011766
11767 if( pIes )
11768 {
11769 if(pIes->SuppRates.present)
11770 {
11771 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11772 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11773 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011774 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 -070011775 pIes->SuppRates.num_rates);
11776 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11777 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011778 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11779 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011780 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011781 if (pIes->ExtSuppRates.present)
11782 {
11783 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011784 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011785 {
11786 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11787 SIR_MAC_RATESET_EID_MAX, resetting to \
11788 SIR_MAC_RATESET_EID_MAX"),
11789 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011790 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011791 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011792 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011793 pIes->ExtSuppRates.rates,
11794 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11795 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011796 if( pIes->SSID.present )
11797 {
11798 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011799 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11800 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011801 }
11802 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011803 }
11804 else
11805 {
11806 pParam->ssId.length = 0;
11807 pParam->operationalRateSet.numRates = 0;
11808 }
11809 }
11810}
11811
Jeff Johnson295189b2012-06-20 16:38:30 -070011812static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11813{
11814 tANI_U8 MaxRate = 0;
11815 tANI_U32 i;
11816 tANI_U8 *pRate;
11817
11818 pRate = pSirRateSet->rate;
11819 for ( i = 0; i < pSirRateSet->numRates; i++ )
11820 {
11821 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11822 }
11823
11824 // Save the max rate in the connected state information...
11825
11826 // modify LastRates variable as well
11827
11828 return;
11829}
11830
Jeff Johnson295189b2012-06-20 16:38:30 -070011831eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11832 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11833{
11834 eHalStatus status = eHAL_STATUS_SUCCESS;
11835 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011836 // Set the roaming substate to 'Start BSS attempt'...
11837 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011838#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11839 //Need to figure out whether we need to log WDS???
11840 if( CSR_IS_IBSS( pProfile ) )
11841 {
11842 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011843 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11844 if(pIbssLog)
11845 {
11846 if(pBssDesc)
11847 {
11848 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011849 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011850 }
11851 else
11852 {
11853 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11854 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011855 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011856 if(pProfile->ChannelInfo.numOfChannels == 0)
11857 {
11858 pIbssLog->channelSetting = AUTO_PICK;
11859 }
11860 else
11861 {
11862 pIbssLog->channelSetting = SPECIFIED;
11863 }
11864 pIbssLog->operatingChannel = pParam->operationChn;
11865 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11866 }
11867 }
11868#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11869 //Put RSN information in for Starting BSS
Abhishek Singh3f9cbb72014-06-04 15:16:27 +053011870 if (pProfile->nRSNReqIELength && pProfile->pRSNReqIE) {
11871 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11872 pParam->pRSNIE = pProfile->pRSNReqIE;
11873 } else if (pProfile->nWPAReqIELength && pProfile->pWPAReqIE) {
11874 pParam->nRSNIELength = (tANI_U16)pProfile->nWPAReqIELength;
11875 pParam->pRSNIE = pProfile->pWPAReqIE;
11876 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011877
Jeff Johnson295189b2012-06-20 16:38:30 -070011878 pParam->privacy = pProfile->privacy;
11879 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11880 pParam->authType = pProfile->csr80211AuthType;
11881 pParam->beaconInterval = pProfile->beaconInterval;
11882 pParam->dtimPeriod = pProfile->dtimPeriod;
11883 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11884 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11885 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11886 {
11887 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11888 {
11889 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11890 }
11891 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011892 pParam->protEnabled = pProfile->protEnabled;
11893 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11894 pParam->ht_protection = pProfile->cfg_protection;
11895 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011896
Jeff Johnson295189b2012-06-20 16:38:30 -070011897 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11898 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011899 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080011900
11901#ifdef WLAN_FEATURE_11W
11902 pParam->mfpCapable = (0 != pProfile->MFPCapable);
11903 pParam->mfpRequired = (0 != pProfile->MFPRequired);
11904#endif
11905
Jeff Johnson295189b2012-06-20 16:38:30 -070011906 // When starting an IBSS, start on the channel from the Profile.
11907 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011908 return (status);
11909}
11910
Jeff Johnson295189b2012-06-20 16:38:30 -070011911static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011912 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011913{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011914 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011915 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011916 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011917
11918 if(!pSession)
11919 {
11920 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11921 return;
11922 }
11923
Jeff Johnson295189b2012-06-20 16:38:30 -070011924 if( pBssDesc )
11925 {
11926 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11927 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11928 //The following code has to be do after that.
11929 //For WDS station, use selfMac as the self BSSID
11930 if( CSR_IS_WDS_STA( pProfile ) )
11931 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011932 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11933 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011934 }
11935 }
11936 else
11937 {
11938 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011939 //Use the first SSID
11940 if(pProfile->SSIDs.numOfSSIDs)
11941 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011942 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11943 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011944 }
11945 //For WDS station, use selfMac as the self BSSID
11946 if( CSR_IS_WDS_STA( pProfile ) )
11947 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011948 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11949 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011950 }
11951 //Use the first BSSID
11952 else if( pProfile->BSSIDs.numOfBSSIDs )
11953 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011954 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11955 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011956 }
11957 else
11958 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011959 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011960 }
11961 }
11962 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011963 //Set operating channel in pProfile which will be used
11964 //in csrRoamSetBssConfigCfg() to determine channel bonding
11965 //mode and will be configured in CFG later
11966 pProfile->operationChannel = Channel;
11967
11968 if(Channel == 0)
11969 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053011970 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011971 }
11972 else
11973 {
11974
11975 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011976 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011977 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011978 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011979 {
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053011980 /* TODO- SAP: HT40 Support in SAP 2.4Ghz mode is not enabled.
11981 so channel bonding in 2.4Ghz is configured as 20MHZ
11982 irrespective of the 'channelBondingMode24GHz' Parameter */
11983 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -070011984 }
11985 else
11986 {
11987 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11988 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011989 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011990 pBssConfig->cbMode = cbMode;
11991 pSession->bssParams.cbMode = cbMode;
11992 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011993 }
11994}
11995
Jeff Johnson295189b2012-06-20 16:38:30 -070011996static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11997 tANI_BOOLEAN *pfSameIbss )
11998{
11999 eHalStatus status = eHAL_STATUS_SUCCESS;
12000 tANI_BOOLEAN fSameIbss = FALSE;
12001
12002 if ( csrIsConnStateIbss( pMac, sessionId ) )
12003 {
12004 // Check if any profile parameter has changed ? If any profile parameter
12005 // has changed then stop old BSS and start a new one with new parameters
12006 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12007 {
12008 fSameIbss = TRUE;
12009 }
12010 else
12011 {
12012 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12013 }
12014 }
12015 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12016 {
12017 // Disassociate from the connected Infrastructure network...
12018 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12019 }
12020 else
12021 {
12022 tBssConfigParam *pBssConfig;
12023
Kiet Lam64c1b492013-07-12 13:56:44 +053012024 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12025 if ( NULL == pBssConfig )
12026 status = eHAL_STATUS_FAILURE;
12027 else
12028 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012029 if(HAL_STATUS_SUCCESS(status))
12030 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012031 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012032 // there is no Bss description before we start an IBSS so we need to adopt
12033 // all Bss configuration parameters from the Profile.
12034 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12035 if(HAL_STATUS_SUCCESS(status))
12036 {
12037 //save dotMode
12038 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12039 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012040 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012041 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12042 NULL, pBssConfig,
12043 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012044 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012045
12046 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012047 }//Allocate memory
12048 }
12049
12050 if(pfSameIbss)
12051 {
12052 *pfSameIbss = fSameIbss;
12053 }
12054 return( status );
12055}
12056
Jeff Johnson295189b2012-06-20 16:38:30 -070012057static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12058 tSirSmeNewBssInfo *pNewBss )
12059{
12060 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012061
12062 if(!pSession)
12063 {
12064 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12065 return;
12066 }
12067
Jeff Johnson295189b2012-06-20 16:38:30 -070012068 if( pNewBss )
12069 {
12070 // Set the operating channel.
12071 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12072 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012073 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12074 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012075 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012076 return;
12077}
12078
Jeff Johnson295189b2012-06-20 16:38:30 -070012079#ifdef FEATURE_WLAN_WAPI
12080eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12081 tANI_U32 numItems )
12082{
12083 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12084 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012085 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12086 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012087 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012088 return status;
12089 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012090 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012091 pSession = CSR_GET_SESSION( pMac, sessionId );
12092 if(numItems <= CSR_MAX_BKID_ALLOWED)
12093 {
12094 status = eHAL_STATUS_SUCCESS;
12095 //numItems may be 0 to clear the cache
12096 pSession->NumBkidCache = (tANI_U16)numItems;
12097 if(numItems && pBKIDCache)
12098 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012099 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12100 sizeof(tBkidCacheInfo) * numItems);
12101 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012102 }
12103 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012104 return (status);
12105}
Jeff Johnson295189b2012-06-20 16:38:30 -070012106eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12107 tBkidCacheInfo *pBkidCache)
12108{
12109 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12110 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012111 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12112 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012113 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012114 return status;
12115 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012116 pSession = CSR_GET_SESSION( pMac, sessionId );
12117 if(pNum && pBkidCache)
12118 {
12119 if(pSession->NumBkidCache == 0)
12120 {
12121 *pNum = 0;
12122 status = eHAL_STATUS_SUCCESS;
12123 }
12124 else if(*pNum >= pSession->NumBkidCache)
12125 {
12126 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
12127 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012128 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 -070012129 pSession->NumBkidCache);
12130 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
12131 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012132 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12133 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012134 *pNum = pSession->NumBkidCache;
12135 status = eHAL_STATUS_SUCCESS;
12136 }
12137 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012138 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012139}
Jeff Johnson295189b2012-06-20 16:38:30 -070012140tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12141{
12142 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012143}
12144#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012145eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12146 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
12147{
12148 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12149 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012150
12151 if(!pSession)
12152 {
12153 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12154 return eHAL_STATUS_FAILURE;
12155 }
12156
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012157 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012158 if(numItems <= CSR_MAX_PMKID_ALLOWED)
12159 {
12160#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12161 {
12162 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012163 vos_mem_set(&secEvent,
12164 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012165 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12166 secEvent.encryptionModeMulticast =
12167 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12168 secEvent.encryptionModeUnicast =
12169 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012170 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012171 secEvent.authMode =
12172 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12173 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12174 }
12175#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012176 status = eHAL_STATUS_SUCCESS;
12177 //numItems may be 0 to clear the cache
12178 pSession->NumPmkidCache = (tANI_U16)numItems;
12179 if(numItems && pPMKIDCache)
12180 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012181 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12182 sizeof(tPmkidCacheInfo) * numItems);
12183 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012184 }
12185 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012186 return (status);
12187}
12188
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012189eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12190 tANI_U8 *pBSSId )
12191{
12192 eHalStatus status = eHAL_STATUS_FAILURE;
12193 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12194 tANI_BOOLEAN fMatchFound = FALSE;
12195 tANI_U32 Index;
12196 if(!pSession)
12197 {
12198 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12199 return eHAL_STATUS_FAILURE;
12200 }
12201 do
12202 {
12203 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
12204 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080012205 smsLog(pMac, LOGW, "Delete PMKID for "
12206 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Kiet Lamf2f201e2013-11-16 21:24:16 +053012207 if( vos_mem_compare( pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012208 {
12209 fMatchFound = TRUE;
12210 break;
12211 }
12212 }
12213 if( !fMatchFound ) break;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012214 vos_mem_set(pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid), 0);
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012215 status = eHAL_STATUS_SUCCESS;
12216 }
12217 while( 0 );
12218 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
12219 fMatchFound, status);
12220 return status;
12221}
Jeff Johnson295189b2012-06-20 16:38:30 -070012222tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12223{
12224 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12225}
12226
Jeff Johnson295189b2012-06-20 16:38:30 -070012227eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12228{
12229 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12230 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012231
12232 if(!pSession)
12233 {
12234 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12235 return eHAL_STATUS_FAILURE;
12236 }
12237
Jeff Johnson295189b2012-06-20 16:38:30 -070012238 if(pNum && pPmkidCache)
12239 {
12240 if(pSession->NumPmkidCache == 0)
12241 {
12242 *pNum = 0;
12243 status = eHAL_STATUS_SUCCESS;
12244 }
12245 else if(*pNum >= pSession->NumPmkidCache)
12246 {
12247 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12248 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012249 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 -070012250 pSession->NumPmkidCache);
12251 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12252 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012253 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12254 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012255 *pNum = pSession->NumPmkidCache;
12256 status = eHAL_STATUS_SUCCESS;
12257 }
12258 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012259 return (status);
12260}
12261
Jeff Johnson295189b2012-06-20 16:38:30 -070012262eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12263{
12264 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12265 tANI_U32 len;
12266 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012267
12268 if(!pSession)
12269 {
12270 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12271 return eHAL_STATUS_FAILURE;
12272 }
12273
Jeff Johnson295189b2012-06-20 16:38:30 -070012274 if(pLen)
12275 {
12276 len = *pLen;
12277 *pLen = pSession->nWpaRsnReqIeLength;
12278 if(pBuf)
12279 {
12280 if(len >= pSession->nWpaRsnReqIeLength)
12281 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012282 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12283 pSession->nWpaRsnReqIeLength);
12284 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012285 }
12286 }
12287 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012288 return (status);
12289}
12290
Jeff Johnson295189b2012-06-20 16:38:30 -070012291eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12292{
12293 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12294 tANI_U32 len;
12295 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012296
12297 if(!pSession)
12298 {
12299 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12300 return eHAL_STATUS_FAILURE;
12301 }
12302
Jeff Johnson295189b2012-06-20 16:38:30 -070012303 if(pLen)
12304 {
12305 len = *pLen;
12306 *pLen = pSession->nWpaRsnRspIeLength;
12307 if(pBuf)
12308 {
12309 if(len >= pSession->nWpaRsnRspIeLength)
12310 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012311 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12312 pSession->nWpaRsnRspIeLength);
12313 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012314 }
12315 }
12316 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012317 return (status);
12318}
Jeff Johnson295189b2012-06-20 16:38:30 -070012319#ifdef FEATURE_WLAN_WAPI
12320eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12321{
12322 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12323 tANI_U32 len;
12324 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012325
12326 if(!pSession)
12327 {
12328 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12329 return eHAL_STATUS_FAILURE;
12330 }
12331
Jeff Johnson295189b2012-06-20 16:38:30 -070012332 if(pLen)
12333 {
12334 len = *pLen;
12335 *pLen = pSession->nWapiReqIeLength;
12336 if(pBuf)
12337 {
12338 if(len >= pSession->nWapiReqIeLength)
12339 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012340 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12341 pSession->nWapiReqIeLength);
12342 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012343 }
12344 }
12345 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012346 return (status);
12347}
Jeff Johnson295189b2012-06-20 16:38:30 -070012348eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12349{
12350 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12351 tANI_U32 len;
12352 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012353
12354 if(!pSession)
12355 {
12356 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12357 return eHAL_STATUS_FAILURE;
12358 }
12359
Jeff Johnson295189b2012-06-20 16:38:30 -070012360 if(pLen)
12361 {
12362 len = *pLen;
12363 *pLen = pSession->nWapiRspIeLength;
12364 if(pBuf)
12365 {
12366 if(len >= pSession->nWapiRspIeLength)
12367 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012368 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12369 pSession->nWapiRspIeLength);
12370 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012371 }
12372 }
12373 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012374 return (status);
12375}
12376#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012377eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12378{
12379 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12380 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012381
12382 if(!pSession)
12383 {
12384 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12385 return (retStatus);
12386 }
12387
Jeff Johnson295189b2012-06-20 16:38:30 -070012388 if(CSR_IS_ROAMING(pSession))
12389 {
12390 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12391 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12392 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012393 return (retStatus);
12394}
12395
Jeff Johnson295189b2012-06-20 16:38:30 -070012396//This function remove the connected BSS from te cached scan result
12397eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12398 tCsrRoamConnectedProfile *pConnProfile)
12399{
12400 eHalStatus status = eHAL_STATUS_FAILURE;
12401 tCsrScanResultFilter *pScanFilter = NULL;
12402 tListElem *pEntry;
12403 tCsrScanResult *pResult;
12404 tDot11fBeaconIEs *pIes;
12405 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012406 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12407 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12408 {
12409 do
12410 {
12411 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012412 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12413 if ( NULL == pScanFilter )
12414 status = eHAL_STATUS_FAILURE;
12415 else
12416 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012417 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012418 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12419 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12420 if ( NULL == pScanFilter->BSSIDs.bssid )
12421 status = eHAL_STATUS_FAILURE;
12422 else
12423 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012424 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012425 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12426 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012427 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12428 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12429 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012430 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12431 if ( NULL == pScanFilter->SSIDs.SSIDList )
12432 status = eHAL_STATUS_FAILURE;
12433 else
12434 status = eHAL_STATUS_SUCCESS;
12435 if (!HAL_STATUS_SUCCESS(status)) break;
12436 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12437 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012438 }
12439 pScanFilter->authType.numEntries = 1;
12440 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12441 pScanFilter->BSSType = pConnProfile->BSSType;
12442 pScanFilter->EncryptionType.numEntries = 1;
12443 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12444 pScanFilter->mcEncryptionType.numEntries = 1;
12445 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12446 //We ignore the channel for now, BSSID should be enough
12447 pScanFilter->ChannelInfo.numOfChannels = 0;
12448 //Also ignore the following fields
12449 pScanFilter->uapsd_mask = 0;
12450 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012451 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012452 pScanFilter->countryCode[0] = 0;
12453 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012454 csrLLLock(&pMac->scan.scanResultList);
12455 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12456 while( pEntry )
12457 {
12458 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12459 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12460 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12461 pScanFilter, NULL, NULL, NULL, &pIes);
12462 //Release the IEs allocated by csrMatchBSS is needed
12463 if( !pResult->Result.pvIes )
12464 {
12465 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012466 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012467 }
12468 if(fMatch)
12469 {
12470 //We found the one
12471 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12472 {
12473 //Free the memory
12474 csrFreeScanResultEntry( pMac, pResult );
12475 }
12476 break;
12477 }
12478 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12479 }//while
12480 csrLLUnlock(&pMac->scan.scanResultList);
12481 }while(0);
12482 if(pScanFilter)
12483 {
12484 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012485 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012486 }
12487 }
12488 return (status);
12489}
12490
Jeff Johnson295189b2012-06-20 16:38:30 -070012491//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012492eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12493{
12494 eHalStatus status = eHAL_STATUS_SUCCESS;
12495 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012496 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12497 {
12498 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12499 {
12500 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12501 {
12502 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012503 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012504 status = eHAL_STATUS_CSR_WRONG_STATE;
12505 break;
12506 }
12507 if( csrIsConnStateInfra( pMac, sessionId ) )
12508 {
12509 if( chnId &&
12510 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12511 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012512 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012513 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12514 status = eHAL_STATUS_CSR_WRONG_STATE;
12515 break;
12516 }
12517 }
12518 }
12519 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012520 return ( status );
12521}
12522
Jeff Johnson295189b2012-06-20 16:38:30 -070012523static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12524{
12525 eHalStatus status = eHAL_STATUS_SUCCESS;
12526 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12527 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012528
12529 if(!pSession)
12530 {
12531 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12532 return eHAL_STATUS_FAILURE;
12533 }
12534
Jeff Johnson295189b2012-06-20 16:38:30 -070012535 if ( csrIsConnStateIbss( pMac, sessionId ) )
12536 {
12537 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12538 }
12539 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12540 {
12541 // Disassociate from the connected Infrastructure network...
12542 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12543 }
12544 else
12545 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012546 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12547 //Otherwise we need to add code to handle the
12548 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12549 //send stop_bss to PE, before we can continue.
12550 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012551 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012552 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012553 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12554 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012555 // there is no Bss description before we start an WDS so we need
12556 // to adopt all Bss configuration parameters from the Profile.
12557 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12558 if(HAL_STATUS_SUCCESS(status))
12559 {
12560 //Save profile for late use
12561 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012562 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12563 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012564 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012565 vos_mem_set(pSession->pCurRoamProfile,
12566 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012567 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12568 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012569 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012570 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012571 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12572 NULL, &bssConfig,
12573 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 }
12575 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012576
Jeff Johnson295189b2012-06-20 16:38:30 -070012577 return( status );
12578}
12579
Jeff Johnson295189b2012-06-20 16:38:30 -070012580////////////////////Mail box
12581
Jeff Johnson295189b2012-06-20 16:38:30 -070012582//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12583//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012584static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12585 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012586 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12587{
12588 tCsrChannelSet channelGroup;
12589 tSirMacCapabilityInfo *pAP_capabilityInfo;
12590 tAniBool fTmp;
12591 tANI_BOOLEAN found = FALSE;
12592 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012593 tANI_S8 pwrLimit = 0;
12594 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012595 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12596 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12597 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12598 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012599 // 802.11h
12600 //We can do this because it is in HOST CPU order for now.
12601 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012602 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12603 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12604 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 fTmp = (tAniBool)pal_cpu_to_be32(1);
12606 }
12607 else
12608 fTmp = (tAniBool)0;
12609
12610 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012611 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012612 pBuf += sizeof(tAniBool);
12613 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012614 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012615 // This is required for 11k test VoWiFi Ent: Test 2.
12616 // We need the power capabilities for Assoc Req.
12617 // This macro is provided by the halPhyCfg.h. We pick our
12618 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012619 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12620 if (0 != pwrLimit)
12621 {
12622 *pBuf++ = pwrLimit;
12623 }
12624 else
12625 {
12626 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12627 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012628 size = sizeof(pMac->roam.validChannelList);
12629 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12630 {
12631 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12632 for ( i = 0; i < size; i++)
12633 {
12634 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12635
12636 }
12637 }
12638 else
12639 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012640 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012641 *pBuf++ = 0; //tSirSupChnl->numChnl
12642 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012643 //Check whether it is ok to enter UAPSD
12644#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12645 if( btcIsReadyForUapsd(pMac) )
12646#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12647 {
12648 *pBuf++ = uapsdMask;
12649 }
12650#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12651 else
12652 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012653 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012654 *pBuf++ = 0;
12655 }
12656#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12657
Jeff Johnson295189b2012-06-20 16:38:30 -070012658 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012659 vos_mem_copy(pBuf, pBssDescription,
12660 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012661 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12662}
12663
Jeff Johnson295189b2012-06-20 16:38:30 -070012664/*
12665 * The communication between HDD and LIM is thru mailbox (MB).
12666 * Both sides will access the data structure "tSirSmeJoinReq".
12667 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12668 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12669 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12670 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12671 */
12672eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012673 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012674{
12675 eHalStatus status = eHAL_STATUS_SUCCESS;
12676 tSirSmeJoinReq *pMsg;
12677 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012678 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012679 tANI_U16 msgLen, wTmp, ieLen;
12680 tSirMacRateSet OpRateSet;
12681 tSirMacRateSet ExRateSet;
12682 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12683 tANI_U32 dwTmp;
12684 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012685 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012686
12687 if(!pSession)
12688 {
12689 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12690 return eHAL_STATUS_FAILURE;
12691 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012692 /* To satisfy klockworks */
12693 if (NULL == pBssDescription)
12694 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012695 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012696 return eHAL_STATUS_FAILURE;
12697 }
12698
Jeff Johnson295189b2012-06-20 16:38:30 -070012699 do {
12700 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12701 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053012702 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012703 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12704 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12705 // IE fields, but the length field in the bssDescription needs to be interpreted to
12706 // determine length of the IE fields.
12707 //
12708 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12709 // add in the length from the bssDescription (then add the size of the 'length' field
12710 // itself because that is NOT included in the length field).
12711 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12712 pBssDescription->length + sizeof( pBssDescription->length ) +
12713 sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 ); // add in the size of the WPA IE that we may build.
Kiet Lam64c1b492013-07-12 13:56:44 +053012714 pMsg = vos_mem_malloc(msgLen);
12715 if (NULL == pMsg)
12716 status = eHAL_STATUS_FAILURE;
12717 else
12718 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012719 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012720 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012721 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012722 pMsg->length = pal_cpu_to_be16(msgLen);
12723 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012724 // sessionId
12725 *pBuf = (tANI_U8)sessionId;
12726 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012727 // transactionId
12728 *pBuf = 0;
12729 *( pBuf + 1 ) = 0;
12730 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012731 // ssId
12732 if( pIes->SSID.present && pIes->SSID.num_ssid )
12733 {
12734 // ssId len
12735 *pBuf = pIes->SSID.num_ssid;
12736 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012737 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012738 pBuf += pIes->SSID.num_ssid;
12739 }
12740 else
12741 {
12742 *pBuf = 0;
12743 pBuf++;
12744 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012745 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012746 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12747 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012748 pBuf += sizeof(tSirMacAddr);
12749 // bsstype
12750 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12751 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012752 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012753 pBuf += sizeof(tSirBssType);
12754 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012755 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12756 if (pBssDescription->channelId <= 14 &&
12757 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12758 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12759 {
12760 //Need to disable VHT operation in 2.4 GHz band
12761 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12762 }
12763 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012764 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012765 //Persona
12766 *pBuf = (tANI_U8)pProfile->csrPersona;
12767 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012768 //CBMode
12769 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12770 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012771
12772 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012773 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12774
Jeff Johnson295189b2012-06-20 16:38:30 -070012775 // uapsdPerAcBitmask
12776 *pBuf = pProfile->uapsd_mask;
12777 pBuf++;
12778
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012779
12780
Jeff Johnson295189b2012-06-20 16:38:30 -070012781 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012782 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012783 {
12784 // OperationalRateSet
12785 if (OpRateSet.numRates) {
12786 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012787 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012788 pBuf += OpRateSet.numRates;
12789 } else *pBuf++ = 0;
12790 // ExtendedRateSet
12791 if (ExRateSet.numRates) {
12792 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012793 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012794 pBuf += ExRateSet.numRates;
12795 } else *pBuf++ = 0;
12796 }
12797 else
12798 {
12799 *pBuf++ = 0;
12800 *pBuf++ = 0;
12801 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012802 // rsnIE
12803 if ( csrIsProfileWpa( pProfile ) )
12804 {
12805 // Insert the Wpa IE into the join request
12806 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12807 (tCsrWpaIe *)( wpaRsnIE ) );
12808 }
12809 else if( csrIsProfileRSN( pProfile ) )
12810 {
12811 // Insert the RSN IE into the join request
12812 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12813 (tCsrRSNIe *)( wpaRsnIE ) );
12814 }
12815#ifdef FEATURE_WLAN_WAPI
12816 else if( csrIsProfileWapi( pProfile ) )
12817 {
12818 // Insert the WAPI IE into the join request
12819 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12820 (tCsrWapiIe *)( wpaRsnIE ) );
12821 }
12822#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012823 else
12824 {
12825 ieLen = 0;
12826 }
12827 //remember the IE for future use
12828 if( ieLen )
12829 {
12830 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12831 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012832 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 -070012833 ieLen = DOT11F_IE_RSN_MAX_LEN;
12834 }
12835#ifdef FEATURE_WLAN_WAPI
12836 if( csrIsProfileWapi( pProfile ) )
12837 {
12838 //Check whether we need to allocate more memory
12839 if(ieLen > pSession->nWapiReqIeLength)
12840 {
12841 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12842 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012843 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012844 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012845 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12846 if (NULL == pSession->pWapiReqIE)
12847 status = eHAL_STATUS_FAILURE;
12848 else
12849 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012850 if(!HAL_STATUS_SUCCESS(status)) break;
12851 }
12852 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012853 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012854 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012855 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012856 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012857 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012858 pBuf += ieLen;
12859 }
12860 else//should be WPA/WPA2 otherwise
12861#endif /* FEATURE_WLAN_WAPI */
12862 {
12863 //Check whether we need to allocate more memory
12864 if(ieLen > pSession->nWpaRsnReqIeLength)
12865 {
12866 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12867 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012868 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012870 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12871 if (NULL == pSession->pWpaRsnReqIE)
12872 status = eHAL_STATUS_FAILURE;
12873 else
12874 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012875 if(!HAL_STATUS_SUCCESS(status)) break;
12876 }
12877 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012878 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012879 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012880 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012881 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012882 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012883 pBuf += ieLen;
12884 }
12885 }
12886 else
12887 {
12888 //free whatever old info
12889 pSession->nWpaRsnReqIeLength = 0;
12890 if(pSession->pWpaRsnReqIE)
12891 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012892 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012893 pSession->pWpaRsnReqIE = NULL;
12894 }
12895#ifdef FEATURE_WLAN_WAPI
12896 pSession->nWapiReqIeLength = 0;
12897 if(pSession->pWapiReqIE)
12898 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012899 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012900 pSession->pWapiReqIE = NULL;
12901 }
12902#endif /* FEATURE_WLAN_WAPI */
12903 //length is two bytes
12904 *pBuf = 0;
12905 *(pBuf + 1) = 0;
12906 pBuf += 2;
12907 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012908#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012909 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012910 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012911 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012912 //length is two bytes
12913 *pBuf = 0;
12914 *(pBuf + 1) = 0;
12915 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012916 }
12917 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012918 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012919 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012920 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012921 {
12922 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012923#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012924 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080012925 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012926 pSession->suppCckmIeInfo.cckmIe, ieLen);
12927#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012928 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012929 pSession,
12930 pProfile,
12931 pBssDescription,
12932 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012933 pSession->nWpaRsnReqIeLength,
12934 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012935#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012936 }
12937 else
12938 {
12939 ieLen = 0;
12940 }
12941 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12942 if( ieLen )
12943 {
12944 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12945 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012946 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012947 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012948 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012949 pBuf += ieLen;
12950 }
12951 else
12952 {
12953 //Indicate you have no CCKM IE
12954 //length is two bytes
12955 *pBuf = 0;
12956 *(pBuf + 1) = 0;
12957 pBuf += 2;
12958 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012959 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012960#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070012961 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053012962 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070012963 {
12964 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012965 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012966 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012967 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012968 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012969 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012970 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053012971 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012972 pBuf += ieLen;
12973 }
12974 else
12975 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053012976 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012977 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012978 *pBuf = 0;
12979 *(pBuf + 1) = 0;
12980 pBuf += 2;
12981 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012982 // addIEAssoc
12983 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12984 {
12985 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012986 if(ieLen > pSession->nAddIEAssocLength)
12987 {
12988 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012989 {
12990 vos_mem_free(pSession->pAddIEAssoc);
12991 }
12992 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12993 if (NULL == pSession->pAddIEAssoc)
12994 status = eHAL_STATUS_FAILURE;
12995 else
12996 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012997 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012998 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012999 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013000 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013001 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013002 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013003 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013004 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013005 pBuf += ieLen;
13006 }
13007 else
13008 {
13009 pSession->nAddIEAssocLength = 0;
13010 if(pSession->pAddIEAssoc)
13011 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013012 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013013 pSession->pAddIEAssoc = NULL;
13014 }
13015 *pBuf = 0;
13016 *(pBuf + 1) = 0;
13017 pBuf += 2;
13018 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013019
13020 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013022 //Unmask any AC in reassoc that is ACM-set
13023 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13024 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013025 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013026 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13027 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013028#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013029 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013030#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013031 }
13032 else
13033 {
13034 uapsd_mask = 0;
13035 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013036 }
13037 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013038
Jeff Johnson295189b2012-06-20 16:38:30 -070013039 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013040 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013041 pBuf += sizeof(tANI_U32);
13042
Jeff Johnson295189b2012-06-20 16:38:30 -070013043 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013044 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013045 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013046#ifdef WLAN_FEATURE_11W
13047 //MgmtEncryption
13048 if (pProfile->MFPEnabled)
13049 {
13050 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13051 }
13052 else
13053 {
13054 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13055 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013056 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013057 pBuf += sizeof(tANI_U32);
13058#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013059#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013060 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013061 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013062#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013063 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013064 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013065#endif
13066 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013067 {
13068 // is11Rconnection;
13069 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013070 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013071 pBuf += sizeof(tAniBool);
13072 }
13073 else
13074 {
13075 // is11Rconnection;
13076 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013077 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013078 pBuf += sizeof(tAniBool);
13079 }
13080#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013081#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013082
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013083 // isESEFeatureIniEnabled
13084 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013085 {
13086 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013087 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013088 pBuf += sizeof(tAniBool);
13089 }
13090 else
13091 {
13092 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013093 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013094 pBuf += sizeof(tAniBool);
13095 }
13096
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013097 /* A profile can not be both ESE and 11R. But an 802.11R AP
13098 * may be advertising support for ESE as well. So if we are
13099 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013100 * If we are associating explictly 11R only then we will get
13101 * 11R.
13102 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013103 if ((csrIsProfileESE(pProfile) ||
13104 ((pIes->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +053013105 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013106 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013107 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013108 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013109 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013110 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013111 pBuf += sizeof(tAniBool);
13112 }
13113 else
13114 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013115 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013116 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013117 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013118 pBuf += sizeof(tAniBool);
13119 }
13120
13121 if (eWNI_SME_JOIN_REQ == messageType)
13122 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013123 tESETspecInfo eseTspec;
13124 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013125 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013126 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13127 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13128 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013129 }
13130 else if (eWNI_SME_REASSOC_REQ == messageType)
13131 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013132 if ((csrIsProfileESE(pProfile) ||
13133 ((pIes->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +053013134 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013135 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013136 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013137 tESETspecInfo eseTspec;
13138 // ESE Tspec information
13139 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13140 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13141 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013142 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013143 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013144 if (eseTspec.numTspecs) {
13145 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13146 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013147 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013148 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013149 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013150 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013151 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013152 tESETspecInfo eseTspec;
13153 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013154 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013155 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13156 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13157 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013158 }
13159 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013160#endif // FEATURE_WLAN_ESE
13161#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013162 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013163 if (pMac->roam.configParam.isFastTransitionEnabled
13164#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013165 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013166#endif
13167 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013168 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013169 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013170 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013171 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013172 }
13173 else
13174 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013175 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013176 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013177 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013178 }
13179#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013180#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013181 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013182 {
13183 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013184 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013185 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013186 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013187 }
13188 else
13189 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013190 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013191 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013192 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013193 }
13194#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013195
13196 // txLdpcIniFeatureEnabled
13197 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13198 pBuf++;
13199
Kiran4a17ebe2013-01-31 10:43:43 -080013200 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13201 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13202 {
13203 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13204 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13205 csrApplyPower2Current(pMac);
13206 }
13207
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013208#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013209 // txBFIniFeatureEnabled
13210 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13211 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013212
13213 // txBFCsnValue
13214 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13215 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053013216
13217 /* Only enable MuBf if no other MuBF session exist
13218 * and FW and HOST is MuBF capable.
13219 */
13220 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
13221 {
13222 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
13223 pBuf++;
13224 }
13225 else
13226 {
13227 *pBuf = 0;
13228 pBuf++;
13229 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013230#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013231 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13232 pBuf++;
13233
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013234 // WME
13235 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13236 {
13237 //WME enabled
13238 dwTmp = pal_cpu_to_be32(TRUE);
13239 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13240 pBuf += sizeof(tAniBool);
13241 }
13242 else
13243 {
13244 dwTmp = pal_cpu_to_be32(FALSE);
13245 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13246 pBuf += sizeof(tAniBool);
13247 }
13248
13249 // QOS
13250 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13251 {
13252 //QOS enabled
13253 dwTmp = pal_cpu_to_be32(TRUE);
13254 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13255 pBuf += sizeof(tAniBool);
13256 }
13257 else
13258 {
13259 dwTmp = pal_cpu_to_be32(FALSE);
13260 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13261 pBuf += sizeof(tAniBool);
13262 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013263 //BssDesc
13264 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13265 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013266
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013267 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053013268 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
13269 pMsg = NULL;
13270
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013271 if(!HAL_STATUS_SUCCESS(status))
13272 {
13273 break;
13274 }
13275 else
13276 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013277#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013278 if (eWNI_SME_JOIN_REQ == messageType)
13279 {
13280 //Tush-QoS: notify QoS module that join happening
13281 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13282 }
13283 else if (eWNI_SME_REASSOC_REQ == messageType)
13284 {
13285 //Tush-QoS: notify QoS module that reassoc happening
13286 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13287 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013288#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013289 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013290 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053013291
13292 if (pMsg != NULL)
13293 {
13294 vos_mem_free( pMsg );
13295 }
13296
Jeff Johnson295189b2012-06-20 16:38:30 -070013297 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013298}
13299
Jeff Johnson295189b2012-06-20 16:38:30 -070013300//
13301eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13302{
13303 eHalStatus status = eHAL_STATUS_SUCCESS;
13304 tSirSmeDisassocReq *pMsg;
13305 tANI_U8 *pBuf;
13306 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013307 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13308 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13309 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013311 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13312 if (NULL == pMsg)
13313 status = eHAL_STATUS_FAILURE;
13314 else
13315 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013317 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013318 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13319 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013320 pBuf = &pMsg->sessionId;
13321 // sessionId
13322 *pBuf++ = (tANI_U8)sessionId;
13323 // transactionId
13324 *pBuf = 0;
13325 *( pBuf + 1 ) = 0;
13326 pBuf += sizeof(tANI_U16);
13327
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013328 if ( (pSession->pCurRoamProfile != NULL) &&
13329 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13330 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013331 {
13332 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013333 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13334 sizeof( tSirMacAddr ));
13335 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013336 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013337 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013338 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13339 //perMacAddr is passed as bssId for softAP
13340 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013341 pBuf = pBuf + sizeof ( tSirMacAddr );
13342 }
13343 else
13344 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013345 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013346 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13347 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013348 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013349 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13350 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013351 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013352 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013353 if(!HAL_STATUS_SUCCESS(status))
13354 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013355 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013356 break;
13357 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013358 // reasonCode
13359 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013360 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13361 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013362 if(!HAL_STATUS_SUCCESS(status))
13363 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013364 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013365 break;
13366 }
13367 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013368 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13369 Here we should not send the disassoc over the air to the AP */
13370 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13371#ifdef WLAN_FEATURE_VOWIFI_11R
13372 && csrRoamIs11rAssoc(pMac)
13373#endif
13374 )
13375 {
13376 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13377 }
13378 pBuf += sizeof(tANI_U8);
13379 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013380 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013381 return( status );
13382}
Jeff Johnson295189b2012-06-20 16:38:30 -070013383eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13384{
13385 eHalStatus status = eHAL_STATUS_SUCCESS;
13386 tSirSmeTkipCntrMeasReq *pMsg;
13387 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013388 do
13389 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013390 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13391 if ( NULL == pMsg )
13392 status = eHAL_STATUS_FAILURE;
13393 else
13394 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013395 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013396 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013397 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13398 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013399 pBuf = &pMsg->sessionId;
13400 // sessionId
13401 *pBuf++ = (tANI_U8)sessionId;
13402 // transactionId
13403 *pBuf = 0;
13404 *( pBuf + 1 ) = 0;
13405 pBuf += sizeof(tANI_U16);
13406 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013407 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13408 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013409 pBuf = pBuf + sizeof ( tSirMacAddr );
13410 // bEnable
13411 *pBuf = (tANI_BOOLEAN)bEnable;
13412 if(!HAL_STATUS_SUCCESS(status))
13413 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013414 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013415 break;
13416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013417 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013418 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013419 return( status );
13420}
Jeff Johnson295189b2012-06-20 16:38:30 -070013421eHalStatus
13422csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13423 VOS_MODULE_ID modId, tSirMacAddr bssId,
13424 void *pUsrContext, void *pfnSapEventCallback,
13425 tANI_U8 *pAssocStasBuf )
13426{
13427 eHalStatus status = eHAL_STATUS_SUCCESS;
13428 tSirSmeGetAssocSTAsReq *pMsg;
13429 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13430 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013431 do
13432 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013433 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13434 if ( NULL == pMsg )
13435 status = eHAL_STATUS_FAILURE;
13436 else
13437 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013438 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013439 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013440 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013441 pBuf = (tANI_U8 *)&pMsg->bssId;
13442 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013443 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013444 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013445 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013446 // modId
13447 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013448 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013449 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013450 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013451 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13452 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013453 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013454 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13455 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013456 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013457 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13458 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013459 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013460 status = palSendMBMessage( pMac->hHdd, pMsg );
13461 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013462 return( status );
13463 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013464eHalStatus
13465csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13466 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13467 {
13468 eHalStatus status = eHAL_STATUS_SUCCESS;
13469 tSirSmeGetWPSPBCSessionsReq *pMsg;
13470 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013471
Jeff Johnson295189b2012-06-20 16:38:30 -070013472 do
13473 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013474 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13475 if ( NULL == pMsg )
13476 status = eHAL_STATUS_FAILURE;
13477 else
13478 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013479 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013480 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013483 VOS_ASSERT(pBuf);
13484
Jeff Johnson295189b2012-06-20 16:38:30 -070013485 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013486 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013487 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13488 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013489 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013490 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13491 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013493 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013494 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013496 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013497 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013498 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013499 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013500 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013501 return( status );
13502}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013503
13504eHalStatus
13505csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13506{
13507 tpSirChangeBIParams pMsg;
13508 tANI_U16 len = 0;
13509 eHalStatus status = eHAL_STATUS_SUCCESS;
13510 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13511
13512 if(!pSession)
13513 {
13514 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13515 return eHAL_STATUS_FAILURE;
13516 }
13517
13518 //NO need to update the Beacon Params if update beacon parameter flag is not set
13519 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13520 return eHAL_STATUS_SUCCESS;
13521
13522 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13523
13524 /* Create the message and send to lim */
13525 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013526 pMsg = vos_mem_malloc(len);
13527 if ( NULL == pMsg )
13528 status = eHAL_STATUS_FAILURE;
13529 else
13530 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013531 if(HAL_STATUS_SUCCESS(status))
13532 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013533 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013534 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13535 pMsg->length = len;
13536
13537 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013538 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13539 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013540 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13541 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013542 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013543 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013544 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13545 status = palSendMBMessage(pMac->hHdd, pMsg);
13546 }
13547 return status;
13548}
13549
Jeff Johnson295189b2012-06-20 16:38:30 -070013550eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13551{
13552 eHalStatus status = eHAL_STATUS_SUCCESS;
13553 tSirSmeDeauthReq *pMsg;
13554 tANI_U8 *pBuf;
13555 tANI_U16 wTmp;
13556 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13557 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13558 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013559 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013560 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13561 if ( NULL == pMsg )
13562 status = eHAL_STATUS_FAILURE;
13563 else
13564 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013565 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013566 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013567 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13568 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13569 //sessionId
13570 pBuf = &pMsg->sessionId;
13571 *pBuf++ = (tANI_U8)sessionId;
13572
13573 //tansactionId
13574 *pBuf = 0;
13575 *(pBuf + 1 ) = 0;
13576 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013578 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013579 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13580 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013581 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13582 sizeof( pMsg->peerMacAddr ) );
13583 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013584 pBuf = pBuf + sizeof(tSirMacAddr);
13585 }
13586 else
13587 {
13588 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013589 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13590 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013591 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013592 }
13593 if(!HAL_STATUS_SUCCESS(status))
13594 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013595 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013596 break;
13597 }
13598 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013599 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13600 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013601 pBuf = pBuf + sizeof(tSirMacAddr);
13602 if(!HAL_STATUS_SUCCESS(status))
13603 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013604 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013605 break;
13606 }
13607 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013608 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13609 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013610 if(!HAL_STATUS_SUCCESS(status))
13611 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013612 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013613 break;
13614 }
13615 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013616 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013617 return( status );
13618}
13619
Jeff Johnson295189b2012-06-20 16:38:30 -070013620eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13621{
13622 eHalStatus status = eHAL_STATUS_SUCCESS;
13623 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013624 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013625 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13626 if ( NULL == pMsg )
13627 status = eHAL_STATUS_FAILURE;
13628 else
13629 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013630 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013631 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13633 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13634 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013635 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13636 sizeof(pMsg->peerMacAddr));
13637 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013638 if(!HAL_STATUS_SUCCESS(status))
13639 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013640 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013641 break;
13642 }
13643//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013644 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13645 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013646 if(!HAL_STATUS_SUCCESS(status))
13647 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013648 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013649 break;
13650 }
13651//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013652 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013653 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013654 return( status );
13655}
13656
Jeff Johnson295189b2012-06-20 16:38:30 -070013657eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13658{
13659 eHalStatus status = eHAL_STATUS_SUCCESS;
13660 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013661 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013662 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13663 if ( NULL == pMsg )
13664 status = eHAL_STATUS_FAILURE;
13665 else
13666 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013667 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013668 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013669 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13670 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13671 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013672 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13673 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 if(!HAL_STATUS_SUCCESS(status))
13675 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013676 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013677 break;
13678 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013679 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13680 sizeof(pMsg->peerMacAddr));
13681 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013682 if(!HAL_STATUS_SUCCESS(status))
13683 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013684 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 break;
13686 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013689 return( status );
13690}
Jeff Johnson295189b2012-06-20 16:38:30 -070013691eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13692{
13693 eHalStatus status = eHAL_STATUS_SUCCESS;
13694 tSirSmeAssocCnf *pMsg;
13695 tANI_U8 *pBuf;
13696 tSirResultCodes statusCode;
13697 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013698 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013699 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13700 if ( NULL == pMsg )
13701 status = eHAL_STATUS_FAILURE;
13702 else
13703 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013704 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013705 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13707 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013708 pBuf = (tANI_U8 *)&pMsg->statusCode;
13709 if(HAL_STATUS_SUCCESS(Halstatus))
13710 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13711 else
13712 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013713 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013714 pBuf += sizeof(tSirResultCodes);
13715 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013716 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13717 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013718 pBuf += sizeof (tSirMacAddr);
13719 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013720 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13721 sizeof(tSirMacAddr));
13722 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013723 pBuf += sizeof (tSirMacAddr);
13724 // aid
13725 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013726 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013727 pBuf += sizeof (tANI_U16);
13728 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013729 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13730 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013731 pBuf += sizeof (tSirMacAddr);
13732 // alternateChannelId
13733 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013734 status = palSendMBMessage( pMac->hHdd, pMsg );
13735 if(!HAL_STATUS_SUCCESS(status))
13736 {
13737 //pMsg is freed by palSendMBMessage
13738 break;
13739 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013740 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013741 return( status );
13742}
Jeff Johnson295189b2012-06-20 16:38:30 -070013743eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13744 tpSirSmeAssocInd pAssocInd,
13745 eHalStatus Halstatus,
13746 tANI_U8 sessionId)
13747{
13748 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013749 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13750 tANI_U8 *pBuf;
13751 tSirResultCodes statusCode;
13752 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013753 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013754 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13755 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13756 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013757
Jeff Johnson295189b2012-06-20 16:38:30 -070013758 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13759 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13760
13761 pMsg->sessionId = sessionId;
13762
13763 pBuf = (tANI_U8 *)&pMsg->statusCode;
13764 if(HAL_STATUS_SUCCESS(Halstatus))
13765 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13766 else
13767 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013768 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013769 pBuf += sizeof(tSirResultCodes);
13770 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013771 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 pBuf += sizeof (tSirMacAddr);
13773 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013774 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13775 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013776 pBuf += sizeof (tSirMacAddr);
13777 // StaId
13778 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013779 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013780 pBuf += sizeof (tANI_U16);
13781 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013782 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 pBuf += sizeof (tSirMacAddr);
13784 // alternateChannelId
13785 *pBuf = 11;
13786 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013787 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013788 //Wmm
13789 *pBuf = pAssocInd->wmmEnabledSta;
13790 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013791 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013792 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013793 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013794 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013795 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013796 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013797 //reassocReq
13798 *pBuf = pAssocInd->reassocReq;
13799 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013800 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13801 msgQ.bodyptr = pMsg;
13802 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013803 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013805 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013806}
Jeff Johnson295189b2012-06-20 16:38:30 -070013807
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013808eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13810 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13811 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13812 tANI_U8 *pKeyRsc )
13813{
13814 tSirSmeSetContextReq *pMsg;
13815 tANI_U16 msgLen;
13816 eHalStatus status = eHAL_STATUS_FAILURE;
13817 tAniEdType tmpEdType;
13818 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013819 tANI_U8 *pBuf = NULL;
13820 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013821 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Sushant Kaushike7de85f2014-06-16 17:13:30 +053013822 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
13823 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013824 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013825 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013826 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13827 // key set. Since we only support upto one key, we always allocate memory for 1 key
13828 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13829 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13830 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13831 ( sizeof( pMsg->keyMaterial.key ) );
13832
Kiet Lam64c1b492013-07-12 13:56:44 +053013833 pMsg = vos_mem_malloc(msgLen);
13834 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13835 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13837 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013838 //sessionId
13839 pBuf = &pMsg->sessionId;
13840 *pBuf = (tANI_U8)sessionId;
13841 pBuf++;
13842 // transactionId
13843 *pBuf = 0;
13844 *(pBuf + 1) = 0;
13845 pBuf += sizeof(tANI_U16);
13846 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013847 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013848
13849 pBuf += sizeof(tSirMacAddr);
13850
13851 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013852 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13853 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013854
13855 pBuf += sizeof(tSirMacAddr);
13856
13857 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013858 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13859 // in the tSirKeyMaterial keyMaterial; field).
13860 //
13861 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13862 // shorter than this max size. Is LIM interpreting this ok ?
13863 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 -070013864 // set pMsg->keyMaterial.edType
13865 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013866 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013867 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013868 // set the pMsg->keyMaterial.numKeys field
13869 *p = numKeys;
13870 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 // set pSirKey->keyId = keyId;
13872 *p = keyId;
13873 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 // set pSirKey->unicast = (tANI_U8)fUnicast;
13875 *p = (tANI_U8)fUnicast;
13876 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013877 // set pSirKey->keyDirection = aniKeyDirection;
13878 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013879 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013880 p += sizeof(tAniKeyDirection);
13881 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013882 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013883 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013884 // set pSirKey->paeRole
13885 *p = paeRole; // 0 is Supplicant
13886 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013887 // set pSirKey->keyLength = keyLength;
13888 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013889 if ( keyLength && pKey )
13890 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013891 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013892 if(keyLength == 16)
13893 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013894 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 -070013895 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13896 pKey[5], pKey[6], pKey[7], pKey[8],
13897 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13898 }
13899 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013900 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013901 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013902 return( status );
13903}
13904
Jeff Johnson295189b2012-06-20 16:38:30 -070013905eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13906 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13907{
13908 eHalStatus status;
13909 tSirSmeStartBssReq *pMsg;
13910 tANI_U8 *pBuf = NULL;
13911 tANI_U8 *wTmpBuf = NULL;
13912 tANI_U16 msgLen, wTmp;
13913 tANI_U32 dwTmp;
13914 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013915 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013916 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013917 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013918
13919 if(!pSession)
13920 {
13921 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13922 return eHAL_STATUS_FAILURE;
13923 }
13924
Jeff Johnson295189b2012-06-20 16:38:30 -070013925 do {
13926 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13927 pSession->joinFailStatusCode.reasonCode = 0;
13928 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013929 pMsg = vos_mem_malloc(msgLen);
13930 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13931 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013932 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013933 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013934 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013935 //sessionId
13936 *pBuf = (tANI_U8)sessionId;
13937 pBuf++;
13938 // transactionId
13939 *pBuf = 0;
13940 *(pBuf + 1) = 0;
13941 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013942 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013943 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013944 pBuf += sizeof(tSirMacAddr);
13945 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013946 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013947 pBuf += sizeof(tSirMacAddr);
13948 // beaconInterval
13949 if( pBssDesc && pBssDesc->beaconInterval )
13950 {
13951 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13952 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013953 else if(pParam->beaconInterval)
13954 {
13955 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13956 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013957 else
13958 {
13959 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13960 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013961 if(csrIsconcurrentsessionValid (pMac, sessionId,
13962 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013963 == eHAL_STATUS_SUCCESS )
13964 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013965 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013966 pParam->bssPersona);
13967 //Update the beacon Interval
13968 pParam->beaconInterval = wTmp;
13969 }
13970 else
13971 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013972 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013973 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013974 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013975 return status;
13976 }
13977
Kiet Lam64c1b492013-07-12 13:56:44 +053013978 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 pBuf += sizeof(tANI_U16);
13980 // dot11mode
13981 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13982 pBuf += 1;
13983 // bssType
13984 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013985 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013986 pBuf += sizeof(tSirBssType);
13987 // ssId
13988 if( pParam->ssId.length )
13989 {
13990 // ssId len
13991 *pBuf = pParam->ssId.length;
13992 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013993 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013994 pBuf += pParam->ssId.length;
13995 }
13996 else
13997 {
13998 *pBuf = 0;
13999 pBuf++;
14000 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014001 // set the channel Id
14002 *pBuf = pParam->operationChn;
14003 pBuf++;
14004 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070014005 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014006 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070014007 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014008
Jeff Johnson295189b2012-06-20 16:38:30 -070014009 // Set privacy
14010 *pBuf = pParam->privacy;
14011 pBuf++;
14012
14013 //Set Uapsd
14014 *pBuf = pParam->ApUapsdEnable;
14015 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014016 //Set SSID hidden
14017 *pBuf = pParam->ssidHidden;
14018 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
14020 pBuf++;
14021
14022 //Ht protection Enable/Disable
14023 *pBuf = (tANI_U8)pParam->protEnabled;
14024 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014025 //Enable Beacons to Receive for OBSS protection Enable/Disable
14026 *pBuf = (tANI_U8)pParam->obssProtEnabled;
14027 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014028 //set cfg related to protection
14029 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053014030 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014031 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014032 // Set Auth type
14033 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014034 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014035 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014036 // Set DTIM
14037 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053014038 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014039 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014040 // Set wps_state
14041 *pBuf = pParam->wps_state;
14042 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080014043 // set isCoalesingInIBSSAllowed
14044 *pBuf = pMac->isCoalesingInIBSSAllowed;
14045 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014046 //Persona
14047 *pBuf = (tANI_U8)pParam->bssPersona;
14048 pBuf++;
14049
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080014050 //txLdpcIniFeatureEnabled
14051 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
14052 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070014053
Chet Lanctot8cecea22014-02-11 19:09:36 -080014054#ifdef WLAN_FEATURE_11W
14055 // Set MFP capable/required
14056 *pBuf = (tANI_U8)pParam->mfpCapable;
14057 pBuf++;
14058 *pBuf = (tANI_U8)pParam->mfpRequired;
14059 pBuf++;
14060#endif
14061
krunal soni4f087d22013-07-29 16:32:26 -070014062 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070014063 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
14064 {
14065 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053014066 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014067 break;
14068 }
14069 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053014070 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014071 pBuf += sizeof(tANI_U16);
14072 if( wTmp )
14073 {
14074 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053014075 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014076 pBuf += wTmp;
14077 }
14078 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014079 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014080 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014081 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
14082 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014083 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
14084 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070014085 pBuf += pParam->operationalRateSet.numRates ;
14086 *pBuf++ = pParam->extendedRateSet.numRates;
14087 if(0 != pParam->extendedRateSet.numRates)
14088 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014089 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
14090 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070014091 pBuf += pParam->extendedRateSet.numRates;
14092 }
krunal sonie9002db2013-11-25 14:24:17 -080014093
Jeff Johnson295189b2012-06-20 16:38:30 -070014094 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
14095 pMsg->length = pal_cpu_to_be16(msgLen);
14096
14097 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014098 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014099 return( status );
14100}
14101
Jeff Johnson295189b2012-06-20 16:38:30 -070014102eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
14103{
14104 eHalStatus status = eHAL_STATUS_FAILURE;
14105 tSirSmeStopBssReq *pMsg;
14106 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14107 tANI_U8 *pBuf;
14108 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070014109
14110 if(!pSession)
14111 {
14112 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14113 return eHAL_STATUS_FAILURE;
14114 }
14115
Jeff Johnson295189b2012-06-20 16:38:30 -070014116 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014117 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14118 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14119 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014120 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14121 pBuf = &pMsg->sessionId;
14122 //sessionId
14123 *pBuf = (tANI_U8)sessionId;
14124 pBuf++;
14125 // transactionId
14126 *pBuf = 0;
14127 pBuf += sizeof(tANI_U16);
14128 //reason code
14129 *pBuf = 0;
14130 pBuf += sizeof(tSirResultCodes);
14131 // bssid
14132 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14133 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14134 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014135 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
14136 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014137 }
14138 else
14139 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014140 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14141 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014142 }
14143 pBuf += sizeof(tSirMacAddr);
14144 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
14145 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014146 status = palSendMBMessage( pMac->hHdd, pMsg );
14147#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053014148 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14149 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14150 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014151 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14152 pMsg->reasonCode = 0;
14153 // bssid
14154 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14155 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14156 {
14157 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
14158 }
14159 else
14160 {
14161 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
14162 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014163 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014164 pMsg->transactionId = 0;
14165 pMsg->sessionId = (tANI_U8)sessionId;
14166 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
14167 status = palSendMBMessage( pMac->hHdd, pMsg );
14168#endif
14169 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014170 return( status );
14171}
14172
Jeff Johnson295189b2012-06-20 16:38:30 -070014173eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14174 tCsrRoamModifyProfileFields *pModProfileFields,
14175 tANI_U32 *pRoamId, v_BOOL_t fForce)
14176{
Jeff Johnson295189b2012-06-20 16:38:30 -070014177 eHalStatus status = eHAL_STATUS_FAILURE;
14178 tANI_U32 roamId = 0;
14179 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014180 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014181 (fForce || (!vos_mem_compare( &pModProfileFields,
14182 &pSession->connectedProfile.modifyProfileFields,
14183 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014184 {
14185 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14186 if(pRoamId)
14187 {
14188 *pRoamId = roamId;
14189 }
14190
Jeff Johnson295189b2012-06-20 16:38:30 -070014191 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14192 eCsrSmeIssuedReassocToSameAP, roamId,
14193 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014194 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014195 return status;
14196}
Jeff Johnson295189b2012-06-20 16:38:30 -070014197static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14198{
14199 eHalStatus status = eHAL_STATUS_SUCCESS;
14200 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014201 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014202 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14203 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14204 return (status);
14205}
Jeff Johnson295189b2012-06-20 16:38:30 -070014206eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14207{
14208 eHalStatus status = eHAL_STATUS_SUCCESS;
14209 tListElem *pEntry = NULL;
14210 tSmeCmd *pCommand = NULL;
14211 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014212 do
14213 {
14214 if(pMsg == NULL)
14215 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014216 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014217 status = eHAL_STATUS_FAILURE;
14218 break;
14219 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014220 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14221 if(pEntry)
14222 {
14223 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14224 if(eSmeCommandAddStaSession == pCommand->command)
14225 {
14226 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014227 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053014228 if (pRsp->status == eSIR_FAILURE) {
14229 VOS_ASSERT( 0 );
14230 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014231 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014232 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014233 //Remove this command out of the active list
14234 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14235 {
14236 //Now put this command back on the avilable command list
14237 csrReleaseCommand(pMac, pCommand);
14238 }
14239 smeProcessPendingQueue( pMac );
14240 }
14241 else
14242 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014243 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 -070014244 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014245 status = eHAL_STATUS_FAILURE;
14246 break;
14247 }
14248 }
14249 else
14250 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014251 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 -070014252 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014253 status = eHAL_STATUS_FAILURE;
14254 break;
14255 }
14256 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014257 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014258}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014259eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14260 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014261{
14262 tSirSmeAddStaSelfReq *pMsg;
14263 tANI_U16 msgLen;
14264 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014265 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014266 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014267 pMsg = vos_mem_malloc(msgLen);
14268 if ( NULL == pMsg ) break;
14269 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014270 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14271 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014272 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014273 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014274 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14275
14276 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14277
Arif Hussain24bafea2013-11-15 15:10:03 -080014278 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14279 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014280 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014281 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014282 return( status );
14283}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014284eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14285 tANI_U32 sessionId,
14286 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014287{
14288 eHalStatus status = eHAL_STATUS_SUCCESS;
14289 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014290 pCommand = csrGetCommandBuffer(pMac);
14291 if(NULL == pCommand)
14292 {
14293 status = eHAL_STATUS_RESOURCES;
14294 }
14295 else
14296 {
14297 pCommand->command = eSmeCommandAddStaSession;
14298 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014299 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14300 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014301 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014302 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14303 if( !HAL_STATUS_SUCCESS( status ) )
14304 {
14305 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014306 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014307 }
14308 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014309 return (status);
14310}
Jeff Johnson295189b2012-06-20 16:38:30 -070014311eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14312{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014313 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014314}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014315eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14316 csrRoamCompleteCallback callback,
14317 void *pContext, tANI_U8 *pSelfMacAddr,
14318 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014319{
14320 eHalStatus status = eHAL_STATUS_SUCCESS;
14321 tANI_U32 i;
14322 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014323 *pbSessionId = CSR_SESSION_ID_INVALID;
14324 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14325 {
14326 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14327 {
14328 pSession = CSR_GET_SESSION( pMac, i );
14329 status = eHAL_STATUS_SUCCESS;
14330 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14331 pSession->sessionId = (tANI_U8)i;
14332 pSession->callback = callback;
14333 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014334 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014335 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014336 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14337 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014338 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014339 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014340 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014341 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014342 break;
14343 }
14344#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014345 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14346 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014347 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014348 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014349 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014350 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014351 break;
14352 }
14353#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014354 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014355 break;
14356 }
14357 }
14358 if( CSR_ROAM_SESSION_MAX == i )
14359 {
14360 //No session is available
14361 status = eHAL_STATUS_RESOURCES;
14362 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014363 return ( status );
14364}
Jeff Johnson295189b2012-06-20 16:38:30 -070014365eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14366{
14367 eHalStatus status = eHAL_STATUS_SUCCESS;
14368 tListElem *pEntry = NULL;
14369 tSmeCmd *pCommand = NULL;
14370 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014371 do
14372 {
14373 if(pMsg == NULL)
14374 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014375 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014376 status = eHAL_STATUS_FAILURE;
14377 break;
14378 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014379 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14380 if(pEntry)
14381 {
14382 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14383 if(eSmeCommandDelStaSession == pCommand->command)
14384 {
14385 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014386 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014387 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014388 //This session is done.
14389 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014390 if(pCommand->u.delStaSessionCmd.callback)
14391 {
14392
14393 status = sme_ReleaseGlobalLock( &pMac->sme );
14394 if ( HAL_STATUS_SUCCESS( status ) )
14395 {
14396 pCommand->u.delStaSessionCmd.callback(
14397 pCommand->u.delStaSessionCmd.pContext);
14398 status = sme_AcquireGlobalLock( &pMac->sme );
14399 if (! HAL_STATUS_SUCCESS( status ) )
14400 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014401 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014402 return status;
14403 }
14404 }
14405 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014406 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014407 }
14408 }
14409
14410 //Remove this command out of the active list
14411 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14412 {
14413 //Now put this command back on the avilable command list
14414 csrReleaseCommand(pMac, pCommand);
14415 }
14416 smeProcessPendingQueue( pMac );
14417 }
14418 else
14419 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014420 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 -070014421 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014422 status = eHAL_STATUS_FAILURE;
14423 break;
14424 }
14425 }
14426 else
14427 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014428 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 -070014429 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014430 status = eHAL_STATUS_FAILURE;
14431 break;
14432 }
14433 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014434 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014435}
Jeff Johnson295189b2012-06-20 16:38:30 -070014436eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14437{
14438 tSirSmeDelStaSelfReq *pMsg;
14439 tANI_U16 msgLen;
14440 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014441 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014442 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14443 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014444 pMsg = vos_mem_malloc(msgLen);
14445 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14446 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014447 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14448 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014449 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014450 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14451 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014452 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014453 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014454 return( status );
14455}
Jeff Johnson295189b2012-06-20 16:38:30 -070014456eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14457 tSirMacAddr sessionMacAddr,
14458 csrRoamSessionCloseCallback callback,
14459 void *pContext)
14460{
14461 eHalStatus status = eHAL_STATUS_SUCCESS;
14462 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014463 pCommand = csrGetCommandBuffer(pMac);
14464 if(NULL == pCommand)
14465 {
14466 status = eHAL_STATUS_RESOURCES;
14467 }
14468 else
14469 {
14470 pCommand->command = eSmeCommandDelStaSession;
14471 pCommand->sessionId = (tANI_U8)sessionId;
14472 pCommand->u.delStaSessionCmd.callback = callback;
14473 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014474 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14475 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014476 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14477 if( !HAL_STATUS_SUCCESS( status ) )
14478 {
14479 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014480 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014481 }
14482 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014483 return (status);
14484}
Jeff Johnson295189b2012-06-20 16:38:30 -070014485eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14486{
14487 return csrSendMBDelSelfStaReqMsg( pMac,
14488 pCommand->u.delStaSessionCmd.selfMacAddr );
14489}
Jeff Johnson295189b2012-06-20 16:38:30 -070014490static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14491{
14492 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14493 tListElem *pEntry, *pNext;
14494 tSmeCmd *pCommand;
14495 tDblLinkList localList;
14496
14497 vos_mem_zero(&localList, sizeof(tDblLinkList));
14498 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14499 {
14500 smsLog(pMac, LOGE, FL(" failed to open list"));
14501 return;
14502 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014503 csrLLLock(pList);
14504 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14505 while(pEntry != NULL)
14506 {
14507 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14508 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14509 if(pCommand->sessionId == sessionId)
14510 {
14511 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14512 {
14513 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14514 }
14515 }
14516 pEntry = pNext;
14517 }
14518 csrLLUnlock(pList);
14519
14520 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14521 {
14522 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14523 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14524 }
14525 csrLLClose(&localList);
14526}
14527
Jeff Johnson295189b2012-06-20 16:38:30 -070014528void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14529{
14530 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14531 {
14532 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014533 csrRoamStop(pMac, sessionId);
14534 csrFreeConnectBssDesc(pMac, sessionId);
14535 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14536 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014537 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014538#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014539 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014540#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014541 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14542 if (pMac->fScanOffload)
14543 {
14544 purgeSmeSessionCmdList(pMac, sessionId,
14545 &pMac->sme.smeScanCmdPendingList);
14546 }
14547
Jeff Johnson295189b2012-06-20 16:38:30 -070014548 purgeCsrSessionCmdList(pMac, sessionId);
14549 csrInitSession(pMac, sessionId);
14550 }
14551}
14552
Jeff Johnson295189b2012-06-20 16:38:30 -070014553eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14554 tANI_BOOLEAN fSync,
14555 csrRoamSessionCloseCallback callback,
14556 void *pContext )
14557{
14558 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014559 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14560 {
14561 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14562 if(fSync)
14563 {
14564 csrCleanupSession(pMac, sessionId);
14565 }
14566 else
14567 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014568 purgeSmeSessionCmdList(pMac, sessionId,
14569 &pMac->sme.smeCmdPendingList);
14570 if (pMac->fScanOffload)
14571 {
14572 purgeSmeSessionCmdList(pMac, sessionId,
14573 &pMac->sme.smeScanCmdPendingList);
14574 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014575 purgeCsrSessionCmdList(pMac, sessionId);
14576 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14577 pSession->selfMacAddr, callback, pContext);
14578 }
14579 }
14580 else
14581 {
14582 status = eHAL_STATUS_INVALID_PARAMETER;
14583 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014584 return ( status );
14585}
14586
Jeff Johnson295189b2012-06-20 16:38:30 -070014587static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14588{
14589 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014590
14591 if(!pSession)
14592 {
14593 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14594 return;
14595 }
14596
Jeff Johnson295189b2012-06-20 16:38:30 -070014597 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14598 pSession->sessionId = CSR_SESSION_ID_INVALID;
14599 pSession->callback = NULL;
14600 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014601 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14602 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14603 csrFreeRoamProfile( pMac, sessionId );
14604 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14605 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14606 csrFreeConnectBssDesc(pMac, sessionId);
14607 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014608 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14609 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014610 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014611 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014612 pSession->pWpaRsnReqIE = NULL;
14613 }
14614 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014615 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014616 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014617 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014618 pSession->pWpaRsnRspIE = NULL;
14619 }
14620 pSession->nWpaRsnRspIeLength = 0;
14621#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014622 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014623 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014624 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014625 pSession->pWapiReqIE = NULL;
14626 }
14627 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014628 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014629 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014630 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014631 pSession->pWapiRspIE = NULL;
14632 }
14633 pSession->nWapiRspIeLength = 0;
14634#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014635 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014636 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014637 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014638 }
14639 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014640
Kiet Lam64c1b492013-07-12 13:56:44 +053014641 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014642 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014643 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014644 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014645 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014646 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014647}
14648
Jeff Johnson295189b2012-06-20 16:38:30 -070014649eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14650{
14651 eHalStatus status = eHAL_STATUS_FAILURE;
14652 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014653 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14654 {
14655 if( CSR_IS_SESSION_VALID( pMac, i ) )
14656 {
14657 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14658 {
14659 //Found it
14660 status = eHAL_STATUS_SUCCESS;
14661 *pSessionId = i;
14662 break;
14663 }
14664 }
14665 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014666 return( status );
14667}
14668
Jeff Johnson295189b2012-06-20 16:38:30 -070014669//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14670//session because for IBSS, the bssid changes.
14671static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14672{
14673 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14674 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014675 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14676 {
14677 if( CSR_IS_SESSION_VALID( pMac, i ) )
14678 {
14679 pSession = CSR_GET_SESSION( pMac, i );
14680 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14681 {
14682 //Found it
14683 nRet = i;
14684 break;
14685 }
14686 }
14687 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014688 return (nRet);
14689}
Jeff Johnson295189b2012-06-20 16:38:30 -070014690static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14691{
Mukul Sharma20aa6582014-08-07 21:36:12 +053014692 VOS_STATUS status = VOS_STATUS_SUCCESS;
14693
14694 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070014695 profile info from pmac global structure */
14696
Arif Hussain24bafea2013-11-15 15:10:03 -080014697 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14698 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014699 /* Check for user misconfig of RSSI trigger threshold */
14700 pMac->roam.configParam.vccRssiThreshold =
14701 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14702 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14703 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014704 /* Check for user misconfig of UL MAC Loss trigger threshold */
14705 pMac->roam.configParam.vccUlMacLossThreshold =
14706 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14707 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014708#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14709 {
14710 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014711 /* Indicate the neighbor roal algorithm about the connect indication */
14712 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14713 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053014714
14715 // Making sure we are roaming force fully to 5GHz AP only once and
14716 // only when we connected to 2.4GH AP only during initial association.
14717 if(pMac->roam.neighborRoamInfo.cfgParams.neighborInitialForcedRoamTo5GhEnable &&
14718 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel) == SIR_BAND_2_4_GHZ)
14719 {
14720 //Making ini value to false here only so we just roam to
14721 //only once for whole driver load to unload tenure
14722 pMac->roam.neighborRoamInfo.cfgParams.neighborInitialForcedRoamTo5GhEnable = VOS_FALSE;
14723
14724 status = vos_timer_start(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer,
14725 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
14726 //MUKUL TODO: change the neighborResultsRefreshPeriod to some ini value reuqired ??
14727 if ( status != VOS_STATUS_SUCCESS )
14728 {
14729 smsLog(pMac, LOGE, FL("%s Neighbor forcedInitialRoamTo5GHTimer start failed with status %d"), __func__, status);
14730 }
14731 smsLog(pMac, LOGE, FL("%s: Forced roam to 5G started Timer"), __func__);
14732 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014733 }
14734#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014735}
14736
Jeff Johnson295189b2012-06-20 16:38:30 -070014737static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14738{
14739 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014740
14741 if(!pSession)
14742 {
14743 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14744 return;
14745 }
14746
Jeff Johnson295189b2012-06-20 16:38:30 -070014747 //Only to handle the case for Handover on infra link
14748 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14749 {
14750 return;
14751 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014752 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14753 csrRoamDeregStatisticsReq(pMac);
14754 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14755#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14756 /* Indicate the neighbor roal algorithm about the disconnect indication */
14757 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14758#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014759
14760 //Remove this code once SLM_Sessionization is supported
14761 //BMPS_WORKAROUND_NOT_NEEDED
14762 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014763 csrIsInfraApStarted( pMac ) &&
14764 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014765 {
14766 pMac->roam.configParam.doBMPSWorkaround = 0;
14767 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014768}
14769
Jeff Johnson295189b2012-06-20 16:38:30 -070014770void csrRoamTlStatsTimerHandler(void *pv)
14771{
14772 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14773 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014774 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14775
Jeff Johnsone7245742012-09-05 17:12:55 -070014776 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14777
Jeff Johnson295189b2012-06-20 16:38:30 -070014778#if 0
14779 // TODO Persession .???
14780 //req TL for stats
14781 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014783 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014784 }
14785 else
14786 {
14787 //save in SME
14788 csrRoamSaveStatsFromTl(pMac, tlStats);
14789 }
14790#endif
14791 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14792 {
14793 if(pMac->roam.tlStatsReqInfo.periodicity)
14794 {
14795 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014796 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14797 pMac->roam.tlStatsReqInfo.periodicity);
14798 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014799 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014800 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014801 return;
14802 }
14803 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14804 }
14805 }
14806}
Jeff Johnson295189b2012-06-20 16:38:30 -070014807void csrRoamPeStatsTimerHandler(void *pv)
14808{
14809 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14810 eHalStatus status;
14811 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14812 VOS_STATUS vosStatus;
14813 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014814 pPeStatsReqListEntry->timerRunning = FALSE;
14815 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14816 {
14817 // If we entered here, meaning the timer could not be successfully
14818 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14819
14820 /* Destroy the timer */
14821 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14822 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14823 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014824 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014825 }
14826
14827 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014828 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014829 pPeStatsReqListEntry = NULL;
14830 }
14831 else
14832 {
14833 if(!pPeStatsReqListEntry->rspPending)
14834 {
14835 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14836 pPeStatsReqListEntry->staId);
14837 if(!HAL_STATUS_SUCCESS(status))
14838 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014839 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014840 }
14841 else
14842 {
14843 pPeStatsReqListEntry->rspPending = TRUE;
14844 }
14845 }
14846
14847 //send down a req
14848 if(pPeStatsReqListEntry->periodicity &&
14849 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14850 {
14851 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14852 if(ePMC_FULL_POWER == powerState)
14853 {
14854 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14855 {
14856 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14857 }
14858 }
14859 else
14860 {
14861 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14862 {
14863 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14864 }
14865 }
14866 //start timer
14867 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14868 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14869 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014870 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014871 return;
14872 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014873 pPeStatsReqListEntry->timerRunning = TRUE;
14874
14875 }
14876
14877 }
14878}
Jeff Johnson295189b2012-06-20 16:38:30 -070014879void csrRoamStatsClientTimerHandler(void *pv)
14880{
14881 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014882 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14883 {
14884#if 0
14885 // TODO Stats fix for multisession
14886 //start the timer
14887 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14888
14889 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14890 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014891 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014892 }
14893#endif
14894 }
14895#if 0
14896 //send up the stats report
14897 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14898 pStaEntry->staId, pStaEntry->pContext);
14899#endif
14900}
14901
14902
14903
Jeff Johnson295189b2012-06-20 16:38:30 -070014904eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14905{
14906 tAniGetPEStatsReq *pMsg;
14907 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014908 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14909 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014910 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014911 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053014912 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014913 }
14914 // need to initiate a stats request to PE
14915 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14916 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14917 pMsg->staId = staId;
14918 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014919 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014920 if(!HAL_STATUS_SUCCESS(status))
14921 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014922 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070014923 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014924 return status;
14925}
Jeff Johnson295189b2012-06-20 16:38:30 -070014926void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14927{
14928 tAniGetPEStatsRsp *pSmeStatsRsp;
14929 eHalStatus status = eHAL_STATUS_FAILURE;
14930 tListElem *pEntry = NULL;
14931 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14932 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14933 tANI_U32 tempMask = 0;
14934 tANI_U8 counter = 0;
14935 tANI_U8 *pStats = NULL;
14936 tANI_U32 length = 0;
14937 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014938 v_S7_t rssi = 0, snr = 0;
14939 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014940 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014941 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14942 if(pSmeStatsRsp->rc)
14943 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014944 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014945 goto post_update;
14946 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014947 tempMask = pSmeStatsRsp->statsMask;
14948 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014949 /* subtract all statistics from this length, and after processing the entire
14950 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14951 * in this 'stats' message.
14952 */
14953 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014954 //new stats info from PE, fill up the stats strucutres in PMAC
14955 while(tempMask)
14956 {
14957 if(tempMask & 1)
14958 {
14959 switch(counter)
14960 {
14961 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014962 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014963 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14964 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014965 pStats += sizeof(tCsrSummaryStatsInfo);
14966 length -= sizeof(tCsrSummaryStatsInfo);
14967 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014968 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014969 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014970 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14971 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14973 length -= sizeof(tCsrGlobalClassAStatsInfo);
14974 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014975 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014976 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014977 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14978 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014979 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14980 length -= sizeof(tCsrGlobalClassBStatsInfo);
14981 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014982 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014983 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014984 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14985 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014986 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14987 length -= sizeof(tCsrGlobalClassCStatsInfo);
14988 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014989 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014990 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014991 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14992 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014993 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14994 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014995 }
14996 else
14997 {
14998 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014999 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015000 VOS_ASSERT( 0 );
15001 }
15002 if(!HAL_STATUS_SUCCESS(status))
15003 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015004 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015005 }
15006 pStats += sizeof(tCsrPerStaStatsInfo);
15007 length -= sizeof(tCsrPerStaStatsInfo);
15008 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015009 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015010 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015011 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015012 }
15013 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015014 tempMask >>=1;
15015 counter++;
15016 }
15017 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
15018 if (length != 0)
15019 {
15020 pRssi = (tANI_U32*)pStats;
15021 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015022 pStats += sizeof(tANI_U32);
15023 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015024 }
15025 else
15026 {
15027 /* If riva is not sending rssi, continue to use the hack */
15028 rssi = RSSI_HACK_BMPS;
15029 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015030
Jeff Johnson295189b2012-06-20 16:38:30 -070015031 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015032
15033 if (length != 0)
15034 {
15035 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015036 pStats += sizeof(tANI_U32);
15037 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015038 }
15039 else
15040 {
15041 linkCapacity = 0;
15042 }
15043
15044 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015045
15046 if (length != 0)
15047 {
15048 pSnr = (tANI_U32*)pStats;
15049 snr = (v_S7_t)*pSnr;
15050 }
15051 else
15052 {
15053 snr = SNR_HACK_BMPS;
15054 }
15055
15056 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015057post_update:
15058 //make sure to update the pe stats req list
15059 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
15060 if(pEntry)
15061 {
15062 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
15063 pPeStaEntry->rspPending = FALSE;
15064
15065 }
15066 //check the one timer cases
15067 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
15068 if(pEntry)
15069 {
Jeff Johnson295189b2012-06-20 16:38:30 -070015070 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015071 if(pTempStaEntry->timerExpired)
15072 {
15073 //send up the stats report
15074 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15075 pTempStaEntry->staId, pTempStaEntry->pContext);
15076 //also remove from the client list
15077 csrRoamRemoveStatListEntry(pMac, pEntry);
15078 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015079 }
15080 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015081}
Jeff Johnson295189b2012-06-20 16:38:30 -070015082tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15083{
15084 tListElem *pEntry = NULL;
15085 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015086 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015087 if(!pEntry)
15088 {
15089 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015090 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015091 return NULL;
15092 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015093 while( pEntry )
15094 {
15095 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015096 if(pTempStaEntry->statsMask == statsMask)
15097 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015098 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015099 break;
15100 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015101 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15102 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015103 return pEntry;
15104}
15105
Jeff Johnson295189b2012-06-20 16:38:30 -070015106tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
15107 tANI_BOOLEAN update)
15108{
15109 tListElem *pEntry;
15110 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015111 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015112 if(!pEntry)
15113 {
15114 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015115 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015116 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015117 return NULL;
15118 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015119 while( pEntry )
15120 {
15121 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015122 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
15123 (pTempStaEntry->statsMask == pStaEntry->statsMask))
15124 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015125 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015126 if(update)
15127 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015128 pTempStaEntry->periodicity = pStaEntry->periodicity;
15129 pTempStaEntry->callback = pStaEntry->callback;
15130 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015131 }
15132 break;
15133 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015134 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015136 return pEntry;
15137}
Jeff Johnson295189b2012-06-20 16:38:30 -070015138tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15139{
15140 tListElem *pEntry;
15141 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015142 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015143 if(!pEntry)
15144 {
15145 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015146 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015147 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015148 return NULL;
15149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015150 while( pEntry )
15151 {
15152 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015153 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
15154 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015155 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015156 break;
15157 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015158 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15159 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015160 return pEntry;
15161}
Jeff Johnson295189b2012-06-20 16:38:30 -070015162eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
15163 csrRoamLinkQualityIndCallback callback,
15164 void *pContext)
15165{
15166 pMac->roam.linkQualityIndInfo.callback = callback;
15167 pMac->roam.linkQualityIndInfo.context = pContext;
15168 if( NULL == callback )
15169 {
15170 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
15171 }
15172 else
15173 {
15174 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070015175 /* do we need to invoke the callback to notify client of initial value ?? */
15176 }
15177 return eHAL_STATUS_SUCCESS;
15178}
Jeff Johnson295189b2012-06-20 16:38:30 -070015179void csrRoamVccTrigger(tpAniSirGlobal pMac)
15180{
15181 eCsrRoamLinkQualityInd newVccLinkQuality;
15182 tANI_U32 ul_mac_loss = 0;
15183 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015184 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15185 /*-------------------------------------------------------------------------
15186 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015187 Check for a change in link quality and notify client if necessary
15188 -------------------------------------------------------------------------*/
15189 ul_mac_loss_trigger_threshold =
15190 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015191 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015192 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015193 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015194 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15195 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015196 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015197 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15198 }
15199 else
15200 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015201 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015202 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15203 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015204 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15205 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015206 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15207 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015208 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015209 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15210 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015211 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015212 newVccLinkQuality );
15213
15214 /* we now invoke the callback once to notify client of initial value */
15215 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15216 pMac->roam.linkQualityIndInfo.context );
15217 //event: EVENT_WLAN_VCC
15218 }
15219 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015220 pMac->roam.vccLinkQuality = newVccLinkQuality;
15221
Jeff Johnson295189b2012-06-20 16:38:30 -070015222}
Jeff Johnson295189b2012-06-20 16:38:30 -070015223VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15224 v_U8_t rssiNotification,
15225 void * context)
15226{
15227 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15228 eCsrRoamLinkQualityInd newVccLinkQuality;
15229 // TODO : Session info unavailable
15230 tANI_U32 sessionId = 0;
15231 VOS_STATUS status = VOS_STATUS_SUCCESS;
15232 /*-------------------------------------------------------------------------
15233 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015234 Check for a change in link quality and notify client if necessary
15235 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015236 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015237 pMac->roam.configParam.vccRssiThreshold);
15238 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15239 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015240 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015241 return VOS_STATUS_SUCCESS;
15242 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015243 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15244 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015245 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015246 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15247 }
15248 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15249 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015250 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015251 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15252 }
15253 else
15254 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015255 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015256 //Set to this so the code below won't do anything
15257 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015258 VOS_ASSERT(0);
15259 }
15260
Jeff Johnson295189b2012-06-20 16:38:30 -070015261 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15262 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015263 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015264 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15265 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015266 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015267 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015268 /* we now invoke the callback once to notify client of initial value */
15269 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15270 pMac->roam.linkQualityIndInfo.context );
15271 //event: EVENT_WLAN_VCC
15272 }
15273 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015274 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015275 return status;
15276}
Jeff Johnson295189b2012-06-20 16:38:30 -070015277tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15278 tDblLinkList *pStaList,
15279 tCsrStatsClientReqInfo *pStaEntry)
15280{
15281 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015282 //if same entity requested for same set of stats with different periodicity &
15283 // callback update it
15284 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15285 {
15286
Kiet Lam64c1b492013-07-12 13:56:44 +053015287 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15288 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015289 {
15290 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015291 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015292 return NULL;
15293 }
15294
Jeff Johnson295189b2012-06-20 16:38:30 -070015295 pNewStaEntry->callback = pStaEntry->callback;
15296 pNewStaEntry->pContext = pStaEntry->pContext;
15297 pNewStaEntry->periodicity = pStaEntry->periodicity;
15298 pNewStaEntry->requesterId = pStaEntry->requesterId;
15299 pNewStaEntry->statsMask = pStaEntry->statsMask;
15300 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15301 pNewStaEntry->pMac = pStaEntry->pMac;
15302 pNewStaEntry->staId = pStaEntry->staId;
15303 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15304
15305 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15306 }
15307 return pNewStaEntry;
15308}
15309
Jeff Johnson295189b2012-06-20 16:38:30 -070015310tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15311 tDblLinkList *pStaList,
15312 tCsrPeStatsReqInfo *pStaEntry)
15313{
15314 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015315 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15316 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015317 {
15318 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015319 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015320 return NULL;
15321 }
15322
Jeff Johnson295189b2012-06-20 16:38:30 -070015323 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15324 pNewStaEntry->numClient = pStaEntry->numClient;
15325 pNewStaEntry->periodicity = pStaEntry->periodicity;
15326 pNewStaEntry->statsMask = pStaEntry->statsMask;
15327 pNewStaEntry->pMac = pStaEntry->pMac;
15328 pNewStaEntry->staId = pStaEntry->staId;
15329 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15330 pNewStaEntry->rspPending = pStaEntry->rspPending;
15331
15332 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015333 return pNewStaEntry;
15334}
Jeff Johnson295189b2012-06-20 16:38:30 -070015335eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15336 tCsrRssiCallback callback,
15337 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15338{
15339 eHalStatus status = eHAL_STATUS_SUCCESS;
15340 vos_msg_t msg;
15341 tANI_U32 sessionId;
15342
15343 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015344 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015345 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15346 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015347 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015348 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015349 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015350 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015351 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15352
15353 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15354 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15355 pMsg->sessionId = sessionId;
15356 pMsg->staId = staId;
15357 pMsg->rssiCallback = callback;
15358 pMsg->pDevContext = pContext;
15359 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015360 msg.type = eWNI_SME_GET_RSSI_REQ;
15361 msg.bodyptr = pMsg;
15362 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015363 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15364 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015365 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015366 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015367 status = eHAL_STATUS_FAILURE;
15368 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015369 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015370 return status;
15371}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015372
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015373eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15374 tCsrSnrCallback callback,
15375 tANI_U8 staId, tCsrBssid bssId,
15376 void *pContext)
15377{
15378 eHalStatus status = eHAL_STATUS_SUCCESS;
15379 vos_msg_t msg;
15380 tANI_U32 sessionId;
15381
15382 tAniGetSnrReq *pMsg;
15383
15384 smsLog(pMac, LOG2, FL("called"));
15385
15386 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15387 if (NULL == pMsg )
15388 {
15389 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15390 return status;
15391 }
15392
15393 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15394
15395 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15396 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15397 pMsg->sessionId = sessionId;
15398 pMsg->staId = staId;
15399 pMsg->snrCallback = callback;
15400 pMsg->pDevContext = pContext;
15401 msg.type = eWNI_SME_GET_SNR_REQ;
15402 msg.bodyptr = pMsg;
15403 msg.reserved = 0;
15404
15405 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15406 {
15407 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15408 vos_mem_free((v_VOID_t *)pMsg);
15409 status = eHAL_STATUS_FAILURE;
15410 }
15411
15412 smsLog(pMac, LOG2, FL("returned"));
15413 return status;
15414}
15415
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015416#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015417eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15418 tCsrRssiCallback callback,
15419 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15420{
15421 eHalStatus status = eHAL_STATUS_SUCCESS;
15422 tAniGetRssiReq *pMsg;
15423
Kiet Lam64c1b492013-07-12 13:56:44 +053015424 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15425 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015426 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015427 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015428 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015429 }
15430 // need to initiate a stats request to PE
15431 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15432 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15433 pMsg->staId = staId;
15434 pMsg->rssiCallback = callback;
15435 pMsg->pDevContext = pContext;
15436 pMsg->pVosContext = pVosContext;
15437 status = palSendMBMessage(pMac->hHdd, pMsg );
15438 if(!HAL_STATUS_SUCCESS(status))
15439 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015440 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015441 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015442 status = eHAL_STATUS_FAILURE;
15443 }
15444 return status;
15445}
15446#endif
15447
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015448
15449
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015450#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015451eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15452 tCsrTsmStatsCallback callback,
15453 tANI_U8 staId,
15454 tCsrBssid bssId,
15455 void *pContext,
15456 void* pVosContext,
15457 tANI_U8 tid)
15458{
15459 eHalStatus status = eHAL_STATUS_SUCCESS;
15460 tAniGetTsmStatsReq *pMsg = NULL;
15461
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015462 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15463 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015464 {
15465 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015466 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015467 }
15468 // need to initiate a stats request to PE
15469 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15470 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15471 pMsg->staId = staId;
15472 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015473 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015474 pMsg->tsmStatsCallback = callback;
15475 pMsg->pDevContext = pContext;
15476 pMsg->pVosContext = pVosContext;
15477 status = palSendMBMessage(pMac->hHdd, pMsg );
15478 if(!HAL_STATUS_SUCCESS(status))
15479 {
15480 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15481 //pMsg is freed by palSendMBMessage
15482 status = eHAL_STATUS_FAILURE;
15483 }
15484 return status;
15485}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015486#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015487
15488
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015489/* ---------------------------------------------------------------------------
15490 \fn csrGetTLSTAState
15491 \helper function to get teh TL STA State whenever the function is called.
15492
15493 \param staId - The staID to be passed to the TL
15494 to get the relevant TL STA State
15495 \return the state as tANI_U16
15496 ---------------------------------------------------------------------------*/
15497tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15498{
15499 WLANTL_STAStateType tlSTAState;
15500 tlSTAState = WLANTL_STA_INIT;
15501
15502 //request TL for STA State
15503 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15504 {
15505 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15506 }
15507
15508 return tlSTAState;
15509}
15510
Jeff Johnson295189b2012-06-20 16:38:30 -070015511eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15512 tANI_U32 statsMask,
15513 tCsrStatsCallback callback,
15514 tANI_U32 periodicity, tANI_BOOLEAN cache,
15515 tANI_U8 staId, void *pContext)
15516{
15517 tCsrStatsClientReqInfo staEntry;
15518 tCsrStatsClientReqInfo *pStaEntry = NULL;
15519 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15520 tListElem *pEntry = NULL;
15521 tANI_BOOLEAN found = FALSE;
15522 eHalStatus status = eHAL_STATUS_SUCCESS;
15523 tANI_BOOLEAN insertInClientList = FALSE;
15524 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015525 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015526
15527 if( csrIsAllSessionDisconnected(pMac) )
15528 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015529 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015530 return eHAL_STATUS_FAILURE;
15531 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015532
15533 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15534 {
15535 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15536 return eHAL_STATUS_FAILURE;
15537 }
15538
Jeff Johnson295189b2012-06-20 16:38:30 -070015539 if((!statsMask) && (!callback))
15540 {
15541 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015542 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015543 return eHAL_STATUS_FAILURE;
15544 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015545 //for the search list method for deregister
15546 staEntry.requesterId = requesterId;
15547 staEntry.statsMask = statsMask;
15548 //requester wants to deregister or just an error
15549 if((statsMask) && (!callback))
15550 {
15551 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15552 if(!pEntry)
15553 {
15554 //msg
15555 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015556 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015557 return eHAL_STATUS_FAILURE;
15558 }
15559 else
15560 {
15561 //clean up & return
15562 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015563 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015564 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015565 pStaEntry->pPeStaEntry->numClient--;
15566 //check if we need to delete the entry from peStatsReqList too
15567 if(!pStaEntry->pPeStaEntry->numClient)
15568 {
15569 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15570 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015571 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015572
Jeff Johnson295189b2012-06-20 16:38:30 -070015573 //check if we need to stop the tl stats timer too
15574 pMac->roam.tlStatsReqInfo.numClient--;
15575 if(!pMac->roam.tlStatsReqInfo.numClient)
15576 {
15577 if(pMac->roam.tlStatsReqInfo.timerRunning)
15578 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015579 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15580 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015581 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015582 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015583 return eHAL_STATUS_FAILURE;
15584 }
15585 }
15586 pMac->roam.tlStatsReqInfo.periodicity = 0;
15587 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15588 }
15589 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015590 // Destroy the vos timer...
15591 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15592 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015594 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015595 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015596 csrRoamRemoveStatListEntry(pMac, pEntry);
15597 pStaEntry = NULL;
15598 return eHAL_STATUS_SUCCESS;
15599 }
15600 }
15601
15602 if(cache && !periodicity)
15603 {
15604 //return the cached stats
15605 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15606 }
15607 else
15608 {
15609 //add the request in the client req list
15610 staEntry.callback = callback;
15611 staEntry.pContext = pContext;
15612 staEntry.periodicity = periodicity;
15613 staEntry.pPeStaEntry = NULL;
15614 staEntry.staId = staId;
15615 staEntry.pMac = pMac;
15616 staEntry.timerExpired = FALSE;
15617
15618
Jeff Johnson295189b2012-06-20 16:38:30 -070015619 //if periodic report requested with non cached result from PE/TL
15620 if(periodicity)
15621 {
15622
15623 //if looking for stats from PE
15624 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15625 {
15626
15627 //check if same request made already & waiting for rsp
15628 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15629 periodicity, &found, staId);
15630 if(!pPeStaEntry)
15631 {
15632 //bail out, maxed out on number of req for PE
15633 return eHAL_STATUS_FAILURE;
15634 }
15635 else
15636 {
15637 staEntry.pPeStaEntry = pPeStaEntry;
15638 }
15639
15640 }
15641 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15642 if(statsMask & (1 << eCsrGlobalClassDStats))
15643 {
15644 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15645 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015646 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015647 }
15648 else
15649 {
15650
15651 //update periodicity
15652 if(pMac->roam.tlStatsReqInfo.periodicity)
15653 {
15654 pMac->roam.tlStatsReqInfo.periodicity =
15655 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15656 }
15657 else
15658 {
15659 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15660 }
15661 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15662 {
15663 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15664 }
15665
15666 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15667 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015668 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015669 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015670 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015671 //req TL for class D stats
15672 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15673 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015674 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015675 }
15676 else
15677 {
15678 //save in SME
15679 csrRoamSaveStatsFromTl(pMac, pTlStats);
15680 }
15681 vos_mem_free(pTlStats);
15682 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015683 }
15684 else
15685 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015686 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015687 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015688
Jeff Johnson295189b2012-06-20 16:38:30 -070015689 if(pMac->roam.tlStatsReqInfo.periodicity)
15690 {
15691 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015692 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15693 pMac->roam.tlStatsReqInfo.periodicity);
15694 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015695 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015696 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015697 return eHAL_STATUS_FAILURE;
15698 }
15699 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15700 }
15701 }
15702 }
15703 pMac->roam.tlStatsReqInfo.numClient++;
15704 }
15705
15706 insertInClientList = TRUE;
15707 }
15708 //if one time report requested with non cached result from PE/TL
15709 else if(!cache && !periodicity)
15710 {
15711 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15712 {
15713 //send down a req
15714 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15715 if(!HAL_STATUS_SUCCESS(status))
15716 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015717 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015718 }
15719 //so that when the stats rsp comes back from PE we respond to upper layer
15720 //right away
15721 staEntry.timerExpired = TRUE;
15722 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015723 }
15724 if(statsMask & (1 << eCsrGlobalClassDStats))
15725 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015726 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015727 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015728 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015729 //req TL for class D stats
15730 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15731 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015732 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015733 }
15734 else
15735 {
15736 //save in SME
15737 csrRoamSaveStatsFromTl(pMac, pTlStats);
15738 }
15739 vos_mem_free(pTlStats);
15740 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015741 }
15742 else
15743 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015744 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015745 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015746
15747 }
15748 //if looking for stats from TL only
15749 if(!insertInClientList)
15750 {
15751 //return the stats
15752 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15753 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015754 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015755 if(insertInClientList)
15756 {
15757 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15758 if(!pStaEntry)
15759 {
15760 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015761 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015762 return eHAL_STATUS_FAILURE;
15763 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015764 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015765 //Init & start timer if needed
15766 if(periodicity)
15767 {
15768 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15769 csrRoamStatsClientTimerHandler, pStaEntry );
15770 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15771 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015772 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015773 return eHAL_STATUS_FAILURE;
15774 }
15775 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15776 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015778 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015779 return eHAL_STATUS_FAILURE;
15780 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015781 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015782 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015783 }
15784 return eHAL_STATUS_SUCCESS;
15785}
15786
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015787#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15788
15789static tSirRetStatus
15790csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15791 tANI_U8* pBD,
15792 tANI_U8 type,
15793 tANI_U8 subType,
15794 tSirMacAddr peerAddr,
15795 tSirMacAddr selfMacAddr)
15796{
15797 tSirRetStatus statusCode = eSIR_SUCCESS;
15798 tpSirMacMgmtHdr pMacHdr;
15799
15800 /* Prepare MAC management header */
15801 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15802
15803 /* Prepare FC */
15804 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15805 pMacHdr->fc.type = type;
15806 pMacHdr->fc.subType = subType;
15807
15808 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015809 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15810 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015811
15812 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15813
15814 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015815 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15816 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015817 return statusCode;
15818} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15819
15820static tSirRetStatus
15821csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15822 tANI_U8 nChannelNum,
15823 tANI_U32 dot11mode,
15824 tSirMacAddr selfMacAddr,
15825 tANI_U8 *pFrame,
15826 tANI_U16 *pusLen)
15827{
15828 tDot11fProbeRequest pr;
15829 tANI_U32 nStatus, nBytes, nPayload;
15830 tSirRetStatus nSirStatus;
15831 /*Bcast tx*/
15832 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15833 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15834
15835
Kiet Lam64c1b492013-07-12 13:56:44 +053015836 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015837
15838 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15839
15840 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15841 {
15842 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15843 }
15844
15845
15846 if (IS_DOT11_MODE_HT(dot11mode))
15847 {
15848 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15849 }
15850
15851
15852 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15853 if ( DOT11F_FAILED( nStatus ) )
15854 {
15855 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15856 "Failed to calculate the packed size f"
15857 "or a Probe Request (0x%08x).\n", nStatus );
15858
15859
15860 nPayload = sizeof( tDot11fProbeRequest );
15861 }
15862 else if ( DOT11F_WARNED( nStatus ) )
15863 {
15864 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15865 "There were warnings while calculating"
15866 "the packed size for a Probe Request ("
15867 "0x%08x).\n", nStatus );
15868 }
15869
15870 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15871
15872 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015873 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015874
15875
15876 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015877 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015878
15879 if ( eSIR_SUCCESS != nSirStatus )
15880 {
15881 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15882 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15883 nSirStatus );
15884 return nSirStatus;
15885 }
15886
15887
15888 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15889 sizeof( tSirMacMgmtHdr ),
15890 nPayload, &nPayload );
15891 if ( DOT11F_FAILED( nStatus ) )
15892 {
15893 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15894 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15895 return eSIR_FAILURE;
15896 }
15897 else if ( DOT11F_WARNED( nStatus ) )
15898 {
15899 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015900 "There were warnings while packing a Probe Request (0x%08x).\n",
15901 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015902 }
15903
15904 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15905 return eSIR_SUCCESS;
15906}
15907
15908eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15909{
15910 vos_msg_t msg;
15911 tSirRoamOffloadScanReq *pRequestBuf;
15912 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15913 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015914 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015915 tANI_U8 *ChannelList = NULL;
15916 tANI_U32 sessionId;
15917 eHalStatus status = eHAL_STATUS_SUCCESS;
15918 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015919 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015920 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015921 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015922 tSirBssDescription *pBssDesc = NULL;
15923 tDot11fBeaconIEs *pIes = NULL;
15924 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080015925 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015926
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015927 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15928
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015929 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015930 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015931 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015932 return eHAL_STATUS_FAILURE;
15933 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015934
15935 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15936 {
15937 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15938 return eHAL_STATUS_FAILURE;
15939 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015940 status = csrRoamGetSessionIdFromBSSID(pMac,
15941 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15942 &sessionId);
15943 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15944 * It is important to ensure that the command is passed down to the FW only
15945 * if the Infra Station is in a connected state.A connected station could also be
15946 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15947 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15948 * irrespective of whichever state we are in.*/
15949 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15950 (command != ROAM_SCAN_OFFLOAD_STOP))
15951 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053015952 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
15953 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
15954 macTraceGetNeighbourRoamState(
15955 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015956 return eHAL_STATUS_FAILURE;
15957 }
15958
15959 if ( !HAL_STATUS_SUCCESS( status ) )
15960 {
15961 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15962 return eHAL_STATUS_FAILURE;
15963 }
15964 pSession = CSR_GET_SESSION( pMac, sessionId );
krunal soni587bf012014-02-04 12:35:11 -080015965 if (NULL == pSession)
15966 {
15967 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15968 "%s:pSession is null", __func__);
15969 return eHAL_STATUS_FAILURE;
15970 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015971 pBssDesc = pSession->pConnectBssDesc;
15972 if (pBssDesc == NULL)
15973 {
15974 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: pBssDesc not found for current session", __func__);
15975 return eHAL_STATUS_FAILURE;
15976 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015977 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15978 if (NULL == pRequestBuf)
15979 {
15980 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15981 return eHAL_STATUS_FAILED_ALLOC;
15982 }
15983
Kiet Lam64c1b492013-07-12 13:56:44 +053015984 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015985 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15986 * host driver reloads, but Riva still up and running*/
Mukul Sharma90506b42014-04-24 13:24:12 +053015987 pRequestBuf->Command = command;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015988 if(command == ROAM_SCAN_OFFLOAD_STOP)
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015989 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015990 pRequestBuf->RoamScanOffloadEnabled = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015991 /*For a STOP Command, there is no need to
15992 * go through filling up all the below parameters
15993 * since they are not required for the STOP command*/
15994 goto send_roam_scan_offload_cmd;
15995 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015996 else
15997 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015998 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15999 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016000 sizeof(tCsrBssid));
16001 pRequestBuf->ConnectedNetwork.ssId.length =
16002 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
16003 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
16004 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
16005 pRequestBuf->ConnectedNetwork.ssId.length);
16006 pRequestBuf->ConnectedNetwork.authentication =
16007 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
16008 pRequestBuf->ConnectedNetwork.encryption =
16009 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
16010 pRequestBuf->ConnectedNetwork.mcencryption =
16011 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016012 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
16013 {
16014 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016015 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016016 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16017 }
16018 else
16019 {
16020 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
16021 operationChannel = pSession->connectedProfile.operationChannel;
16022
16023 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
16024 {
16025 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16026 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
16027 vos_mem_free(pRequestBuf);
16028 return eHAL_STATUS_FAILURE;
16029 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016030 if(NULL == pIes)
16031 {
16032 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16033 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053016034 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016035 return eHAL_STATUS_FAILURE;
16036 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016037 if (pIes->SuppRates.present)
16038 {
16039 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
16040 /*Check for both basic rates and extended rates.*/
16041 for (i = 0; i < pIes->SuppRates.num_rates; i++)
16042 {
16043 /*Check if the Rate is Mandatory or Not*/
16044 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
16045 && (pIes->SuppRates.rates[i] & 0x80))
16046 {
16047 /*Retrieve the actual data rate*/
16048 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
16049 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16050 if (minRate == 0)
16051 minRate = dataRate;
16052 else
16053 minRate = (minRate < dataRate) ? minRate:dataRate;
16054 }
16055 }
16056
16057 if (pIes->ExtSuppRates.present)
16058 {
16059 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
16060 {
16061 /*Check if the Rate is Mandatory or Not*/
16062 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
16063 && (pIes->ExtSuppRates.rates[i] & 0x80))
16064 {
16065 /*Retrieve the actual data rate*/
16066 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
16067 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16068 if (minRate == 0)
16069 minRate = dataRate;
16070 else
16071 minRate = (minRate < dataRate) ? minRate:dataRate;
16072 }
16073 }
16074 }
16075 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
16076 }
16077 else
16078 {
16079 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16080 "%s: Supp Rates not present in pIes", __func__);
16081 vos_mem_free(pRequestBuf);
16082 return eHAL_STATUS_FAILURE;
16083 }
16084 if (NULL != pIes)
16085 {
16086 vos_mem_free(pIes);
16087 pIes = NULL;
16088 }
16089 switch (minRate)
16090 {
16091 case 1:
16092 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
16093 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
16094 break;
16095 case 2:
16096 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
16097 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
16098 break;
16099 case 5:
16100 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
16101 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
16102 break;
16103 case 6:
16104 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16105 {
16106 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
16107 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
16108 }
16109 else
16110 {
16111 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
16112 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
16113 }
16114 break;
16115 case 11:
16116 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
16117 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
16118 break;
16119 case 12:
16120 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16121 {
16122 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
16123 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
16124 }
16125 else
16126 {
16127 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
16128 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
16129 }
16130 break;
16131 case 24:
16132 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16133 {
16134 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
16135 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
16136 }
16137 else
16138 {
16139 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
16140 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
16141 }
16142 break;
16143 default:
16144 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
16145 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16146 break;
16147 }
16148 }
16149 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16150 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
16151 operationChannel, minRate,
16152 pRequestBuf->RxSensitivityThreshold,
16153 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016154 pRequestBuf->RoamRssiDiff =
16155 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016156 pRequestBuf->StartScanReason = reason;
16157 pRequestBuf->NeighborScanTimerPeriod =
16158 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
16159 pRequestBuf->NeighborRoamScanRefreshPeriod =
16160 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
16161 pRequestBuf->NeighborScanChannelMinTime =
16162 pNeighborRoamInfo->cfgParams.minChannelScanTime;
16163 pRequestBuf->NeighborScanChannelMaxTime =
16164 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
16165 pRequestBuf->EmptyRefreshScanPeriod =
16166 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080016167 /* MAWC feature */
16168 pRequestBuf->MAWCEnabled =
16169 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016170#ifdef FEATURE_WLAN_ESE
16171 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016172#endif
16173 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016174#ifdef FEATURE_WLAN_ESE
16175 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016176 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
16177 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016178 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
16179#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016180 currChannelListInfo->numOfChannels == 0)
16181 {
16182
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016183 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
16184 * Give Preference to INI Channels.*/
16185 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
16186 {
16187 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16188 /*The INI channels need to be filtered with respect to the current
16189 * band that is supported.*/
16190 eBand = pMac->roam.configParam.bandCapability;
16191 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016192 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016193 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16194 "Invalid band, No operation carried out (Band %d)", eBand);
16195 vos_mem_free(pRequestBuf);
16196 return eHAL_STATUS_FAILURE;
16197 }
16198 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16199 {
16200 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16201 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16202 (eCSR_BAND_ALL == eBand))
16203 {
16204 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
16205 csrRoamIsChannelValid(pMac, *ChannelList) &&
16206 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16207 {
16208 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16209 }
16210 }
16211 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016212 }
16213 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16214 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016215 }
16216 else
16217 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016218 ChannelList = pMac->scan.occupiedChannels.channelList;
16219 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16220 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016221 /*Allow DFS channels only if the DFS channel roam flag is enabled */
16222 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16223 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016224 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16225 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016226 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016227 }
16228 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016229 }
16230 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16231 /* If the profile changes as to what it was earlier, inform the FW through
16232 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16233 * for the earlier profile and try to learn them afresh.*/
16234 if (reason == REASON_FLUSH_CHANNEL_LIST)
16235 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16236 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016237 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16238 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16239 else
16240 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016241 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016242 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016243 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016244#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016245 else
16246 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016247 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016248 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016249 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016250 if (currChannelListInfo->numOfChannels != 0)
16251 {
16252 ChannelList = currChannelListInfo->ChannelList;
16253 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016254 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016255 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16256 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016257 {
16258 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16259 }
16260 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016261 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016262 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16263 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16264 }
16265 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016266#endif
Kaushik, Sushant5ed8ab62014-03-05 11:21:11 +053016267 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0])) && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016268 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016269 if (j < sizeof(ChannelCacheStr))
16270 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016271 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16272 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016273 }
16274 else
16275 {
16276 break;
16277 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016278 }
16279 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16280 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16281 pRequestBuf->ChannelCacheType,
16282 pRequestBuf->ConnectedNetwork.ChannelCount,
16283 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016284 num_channels = 0;
16285 ChannelList = NULL;
16286
16287 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016288 host_channels = sizeof(pMac->roam.validChannelList);
16289 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016290 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016291 ChannelList = pMac->roam.validChannelList;
16292 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016293 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016294 else
16295 {
16296 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16297 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016298 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016299 return eHAL_STATUS_FAILURE;
16300 }
16301 for(i=0; i<pMac->roam.numValidChannels; i++)
16302 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016303 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16304 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Srinivas Girigowda56076852013-08-20 14:00:50 -070016305 {
16306 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16307 }
16308 ChannelList++;
16309 }
16310 pRequestBuf->ValidChannelCount = num_channels;
16311
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016312 pRequestBuf->MDID.mdiePresent =
16313 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16314 pRequestBuf->MDID.mobilityDomain =
16315 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016316 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16317
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016318 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016319 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16320 * where RFS is the RF Switching time. It is twice RFS to consider the
16321 * time to go off channel and return to the home channel. */
16322 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16323 {
16324 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16325 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16326 " Hence enforcing home away time to disable (0)",
16327 __func__, pRequestBuf->HomeAwayTime,
16328 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16329 pRequestBuf->HomeAwayTime = 0;
16330 }
16331 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016332
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016333 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16334 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16335 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16336 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16337 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16338
16339 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16340 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016341send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016342 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016343 msg.reserved = 0;
16344 msg.bodyptr = pRequestBuf;
16345 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16346 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016347 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16348 vos_mem_free(pRequestBuf);
16349 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016350 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016351 else
16352 {
16353 if (ROAM_SCAN_OFFLOAD_START == command)
16354 bRoamScanOffloadStarted = VOS_TRUE;
16355 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16356 bRoamScanOffloadStarted = VOS_FALSE;
16357 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016358
16359 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16360 return status;
16361}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016362
16363eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16364{
16365 switch(reason)
16366 {
16367 case 0:
16368 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16369 break;
16370 case REASON_OS_REQUESTED_ROAMING_NOW:
16371 csrNeighborRoamProceedWithHandoffReq(pMac);
16372 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016373 case REASON_INITIAL_FORCED_ROAM_TO_5G:
16374 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
16375 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016376 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016377 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Rsp for Roam Scan Offload with reason %d", reason);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016378 }
16379 return eHAL_STATUS_SUCCESS;
16380}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016381#endif
16382
Jeff Johnson295189b2012-06-20 16:38:30 -070016383tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16384 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16385{
16386 tANI_BOOLEAN found = FALSE;
16387 eHalStatus status = eHAL_STATUS_SUCCESS;
16388 tCsrPeStatsReqInfo staEntry;
16389 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16390 tListElem *pStaEntry = NULL;
16391 VOS_STATUS vosStatus;
16392 tPmcPowerState powerState;
16393 *pFound = FALSE;
16394
16395 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16396 if(pStaEntry)
16397 {
16398 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16399 if(pTempStaEntry->periodicity)
16400 {
16401 pTempStaEntry->periodicity =
16402 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16403 }
16404 else
16405 {
16406 pTempStaEntry->periodicity = periodicity;
16407 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016408 pTempStaEntry->numClient++;
16409 found = TRUE;
16410 }
16411 else
16412 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016413 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016414 staEntry.numClient = 1;
16415 staEntry.periodicity = periodicity;
16416 staEntry.pMac = pMac;
16417 staEntry.rspPending = FALSE;
16418 staEntry.staId = staId;
16419 staEntry.statsMask = statsMask;
16420 staEntry.timerRunning = FALSE;
16421 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16422 if(!pTempStaEntry)
16423 {
16424 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016425 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016426 return NULL;
16427 }
16428 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016429 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16430 if(ePMC_FULL_POWER == powerState)
16431 {
16432 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16433 {
16434 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16435 }
16436 }
16437 else
16438 {
16439 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16440 {
16441 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16442 }
16443 }
16444 if(!pTempStaEntry->timerRunning)
16445 {
16446 //send down a req in case of one time req, for periodic ones wait for timer to expire
16447 if(!pTempStaEntry->rspPending &&
16448 !pTempStaEntry->periodicity)
16449 {
16450 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16451 if(!HAL_STATUS_SUCCESS(status))
16452 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016453 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016454 }
16455 else
16456 {
16457 pTempStaEntry->rspPending = TRUE;
16458 }
16459 }
16460 if(pTempStaEntry->periodicity)
16461 {
16462 if(!found)
16463 {
16464
16465 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16466 csrRoamPeStatsTimerHandler, pTempStaEntry );
16467 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16468 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016469 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016470 return NULL;
16471 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016472 }
16473 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016474 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016475 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16476 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16477 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016478 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016479 return NULL;
16480 }
16481 pTempStaEntry->timerRunning = TRUE;
16482 }
16483 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016484 *pFound = found;
16485 return pTempStaEntry;
16486}
16487
Jeff Johnson295189b2012-06-20 16:38:30 -070016488/*
16489 pStaEntry is no longer invalid upon the return of this function.
16490*/
16491static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16492{
16493 if(pEntry)
16494 {
16495 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16496 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016497 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016498 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016499 }
16500 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016501
16502void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16503{
16504 tListElem *pEntry;
16505 tCsrPeStatsReqInfo *pTempStaEntry;
16506 VOS_STATUS vosStatus;
16507 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016508 if(!pEntry)
16509 {
16510 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016511 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016512 return;
16513 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016514 while( pEntry )
16515 {
16516 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016517 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16518 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016519 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016520 if(pTempStaEntry->timerRunning)
16521 {
16522 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16523 /* If we are not able to stop the timer here, just remove
16524 * the entry from the linked list. Destroy the timer object
16525 * and free the memory in the timer CB
16526 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016527 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016528 {
16529 /* the timer is successfully stopped */
16530 pTempStaEntry->timerRunning = FALSE;
16531
16532 /* Destroy the timer */
16533 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16534 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016536 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016537 }
16538 }
16539 else
16540 {
16541 // the timer could not be stopped. Hence destroy and free the
16542 // memory for the PE stat entry in the timer CB.
16543 pTempStaEntry->timerStopFailed = TRUE;
16544 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016545 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016546
16547 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16548 {
16549 // Only free the memory if we could stop the timer successfully
16550 if(!pTempStaEntry->timerStopFailed)
16551 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016552 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016553 pTempStaEntry = NULL;
16554 }
16555 break;
16556 }
16557
16558 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16559 }
16560 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016561 return;
16562}
16563
16564
Jeff Johnsone7245742012-09-05 17:12:55 -070016565void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016566{
16567
Jeff Johnsone7245742012-09-05 17:12:55 -070016568 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16569 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16570 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16571 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16572 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16573 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16574 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016575 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016576 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16577 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16578 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16579 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16580 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16581 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016582 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016583 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16584 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016585
16586}
16587
Jeff Johnson295189b2012-06-20 16:38:30 -070016588void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16589 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16590{
16591 tANI_U8 stats[500];
16592 tANI_U8 *pStats = NULL;
16593 tANI_U32 tempMask = 0;
16594 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016595 if(!callback)
16596 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016597 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016598 return;
16599 }
16600 if(!statsMask)
16601 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016602 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016603 return;
16604 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016605 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016606 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016607 while(tempMask)
16608 {
16609 if(tempMask & 1)
16610 {
16611 //new stats info from PE, fill up the stats strucutres in PMAC
16612 switch(counter)
16613 {
16614 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016615 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016616 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16617 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016618 pStats += sizeof(tCsrSummaryStatsInfo);
16619 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016620 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016621 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016622 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16623 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016624 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016625 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016626 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016627 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016628 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16629 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016630 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016631 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016632 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016633 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016634 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16635 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016636 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016637 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016638 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016639 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016640 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16641 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016642 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016643 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016644 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016645 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016646 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16647 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016648 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016649 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016650 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016651 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016652 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016653 }
16654 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016655 tempMask >>=1;
16656 counter++;
16657 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016658 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016659}
16660
Jeff Johnson295189b2012-06-20 16:38:30 -070016661eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16662{
16663 tListElem *pEntry = NULL;
16664 tListElem *pPrevEntry = NULL;
16665 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16666 eHalStatus status = eHAL_STATUS_SUCCESS;
16667 VOS_STATUS vosStatus;
16668 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016669 if(!pEntry)
16670 {
16671 //list empty
16672 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016673 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016674 return status;
16675 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016676 while( pEntry )
16677 {
16678 if(pPrevEntry)
16679 {
16680 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16681 //send up the stats report
16682 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16683 pTempStaEntry->staId, pTempStaEntry->pContext);
16684 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16685 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016686 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016687 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16688 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016689 pTempStaEntry->pPeStaEntry->numClient--;
16690 //check if we need to delete the entry from peStatsReqList too
16691 if(!pTempStaEntry->pPeStaEntry->numClient)
16692 {
16693 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16694 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016695 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016696 //check if we need to stop the tl stats timer too
16697 pMac->roam.tlStatsReqInfo.numClient--;
16698 if(!pMac->roam.tlStatsReqInfo.numClient)
16699 {
16700 if(pMac->roam.tlStatsReqInfo.timerRunning)
16701 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016702 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16703 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016705 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016706 //we will continue
16707 }
16708 }
16709 pMac->roam.tlStatsReqInfo.periodicity = 0;
16710 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16711 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016712 if (pTempStaEntry->periodicity)
16713 {
16714 //While creating StaEntry in csrGetStatistics,
16715 //Initializing and starting timer only when periodicity is set.
16716 //So Stop and Destroy timer only when periodicity is set.
16717
Jeff Johnsone7245742012-09-05 17:12:55 -070016718 vos_timer_stop( &pTempStaEntry->timer );
16719 // Destroy the vos timer...
16720 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16721 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16722 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016723 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016724 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016725 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016726
Jeff Johnson295189b2012-06-20 16:38:30 -070016727
16728 pPrevEntry = pEntry;
16729 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16730 }
16731 //the last one
16732 if(pPrevEntry)
16733 {
16734 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16735 //send up the stats report
16736 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16737 pTempStaEntry->staId, pTempStaEntry->pContext);
16738 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16739 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016740 return status;
16741
16742}
16743
Jeff Johnson295189b2012-06-20 16:38:30 -070016744eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16745 tRequestFullPowerReason *pReason,
16746 tANI_BOOLEAN *pfNeedPower )
16747{
16748 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16749 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16750 tPmcState pmcState;
16751 eHalStatus status = eHAL_STATUS_SUCCESS;
16752 // TODO : Session info unavailable
16753 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016754 if( pfNeedPower )
16755 {
16756 *pfNeedPower = eANI_BOOLEAN_FALSE;
16757 }
16758 //We only handle CSR commands
16759 if( !(eSmeCsrCommandMask & pCommand->command) )
16760 {
16761 return eHAL_STATUS_SUCCESS;
16762 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016763 //Check PMC state first
16764 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016765 switch( pmcState )
16766 {
16767 case REQUEST_IMPS:
16768 case IMPS:
16769 if( eSmeCommandScan == pCommand->command )
16770 {
16771 switch( pCommand->u.scanCmd.reason )
16772 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016773#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16774 case eCsrScanGetLfrResult:
16775#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016776 case eCsrScanGetResult:
16777 case eCsrScanBGScanAbort:
16778 case eCsrScanBGScanEnable:
16779 case eCsrScanGetScanChnInfo:
16780 //Internal process, no need for full power
16781 fNeedFullPower = eANI_BOOLEAN_FALSE;
16782 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016783 default:
16784 //Other scans are real scan, ask for power
16785 fNeedFullPower = eANI_BOOLEAN_TRUE;
16786 break;
16787 } //switch
16788 }
16789 else
16790 {
16791 //ask for power for roam and status change
16792 fNeedFullPower = eANI_BOOLEAN_TRUE;
16793 }
16794 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016795 case REQUEST_BMPS:
16796 case BMPS:
16797 case REQUEST_START_UAPSD:
16798 case UAPSD:
16799 //We treat WOWL same as BMPS
16800 case REQUEST_ENTER_WOWL:
16801 case WOWL:
16802 if( eSmeCommandRoam == pCommand->command )
16803 {
16804 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16805 tCsrScanResult *pScanResult;
16806 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016807 switch ( pCommand->u.roamCmd.roamReason )
16808 {
16809 case eCsrForcedDisassoc:
16810 case eCsrForcedDisassocMICFailure:
16811 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16812 fNeedFullPower = eANI_BOOLEAN_TRUE;
16813 break;
16814 case eCsrSmeIssuedDisassocForHandoff:
16815 case eCsrForcedDeauth:
16816 case eCsrHddIssuedReassocToSameAP:
16817 case eCsrSmeIssuedReassocToSameAP:
16818 fNeedFullPower = eANI_BOOLEAN_TRUE;
16819 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016820 case eCsrCapsChange:
16821 fNeedFullPower = eANI_BOOLEAN_TRUE;
16822 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016823 default:
16824 //Check whether the profile is already connected. If so, no need for full power
16825 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16826 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16827 {
16828 //Only need to check the first one
16829 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16830 if( pEntry )
16831 {
16832 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16833#if 0
16834 // TODO : Session Specific info pConnectBssDesc
16835 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16836 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16837 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16838 {
16839 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16840 // with Authenticating first. To force this, stop the current association (Disassociate) and
16841 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16842 // a new Association.
16843 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16844 {
16845 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16846 {
16847 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16848 //No need for full power
16849 //Set the flag so the code later can avoid to do the above
16850 //check again.
16851 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16852 break;
16853 }
16854 }
16855 }
16856#endif
16857 }
16858 }
16859 //If we are here, full power is needed
16860 fNeedFullPower = eANI_BOOLEAN_TRUE;
16861 break;
16862 }
16863 }
16864 else if( eSmeCommandWmStatusChange == pCommand->command )
16865 {
16866 //need full power for all
16867 fNeedFullPower = eANI_BOOLEAN_TRUE;
16868 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16869 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016870#ifdef FEATURE_WLAN_TDLS
16871 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16872 {
16873 //TDLS link is getting established. need full power
16874 fNeedFullPower = eANI_BOOLEAN_TRUE;
16875 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16876 }
16877#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016878 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016879 case REQUEST_STOP_UAPSD:
16880 case REQUEST_EXIT_WOWL:
16881 if( eSmeCommandRoam == pCommand->command )
16882 {
16883 fNeedFullPower = eANI_BOOLEAN_TRUE;
16884 switch ( pCommand->u.roamCmd.roamReason )
16885 {
16886 case eCsrForcedDisassoc:
16887 case eCsrForcedDisassocMICFailure:
16888 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16889 break;
16890 default:
16891 break;
16892 }
16893 }
16894 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016895 case STOPPED:
16896 case REQUEST_STANDBY:
16897 case STANDBY:
16898 case LOW_POWER:
16899 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053016900 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
16901 " stopped/standby state %s (%d)" ),
16902 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016903 status = eHAL_STATUS_FAILURE;
16904 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016905 case FULL_POWER:
16906 case REQUEST_FULL_POWER:
16907 default:
16908 //No need to ask for full power. This has to be FULL_POWER state
16909 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016910 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016911 if( pReason )
16912 {
16913 *pReason = reason;
16914 }
16915 if( pfNeedPower )
16916 {
16917 *pfNeedPower = fNeedFullPower;
16918 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016919 return ( status );
16920}
16921
Jeff Johnson295189b2012-06-20 16:38:30 -070016922static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16923{
16924 eHalStatus status = eHAL_STATUS_SUCCESS;
16925 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16926 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016927 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016928 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16929 {
16930 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16931 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016932 return ( status );
16933}
16934
Jeff Johnson295189b2012-06-20 16:38:30 -070016935tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16936{
16937 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016938 if( pCmd )
16939 {
16940 pMac->roam.sPendingCommands++;
16941 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016942 return ( pCmd );
16943}
16944
Jeff Johnson295189b2012-06-20 16:38:30 -070016945void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16946{
16947 if (pMac->roam.sPendingCommands > 0)
16948 {
16949 //All command allocated through csrGetCommandBuffer need to
16950 //decrement the pending count when releasing.
16951 pMac->roam.sPendingCommands--;
16952 smeReleaseCommand( pMac, pCommand );
16953 }
16954 else
16955 {
16956 smsLog(pMac, LOGE, FL( "no pending commands"));
16957 VOS_ASSERT(0);
16958 }
16959}
16960
Jeff Johnson295189b2012-06-20 16:38:30 -070016961//Return SUCCESS is the command is queued, failed
16962eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16963{
16964 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016965 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16966 {
16967 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16968 pCommand->u.scanCmd.reason);
16969 return eHAL_STATUS_CSR_WRONG_STATE;
16970 }
16971
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016972 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16973 {
16974 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16975 &pCommand->Link, LL_ACCESS_LOCK);
16976 // process the command queue...
16977 smeProcessPendingQueue(pMac);
16978 status = eHAL_STATUS_SUCCESS;
16979 goto end;
16980 }
16981
Jeff Johnson295189b2012-06-20 16:38:30 -070016982 //We can call request full power first before putting the command into pending Q
16983 //because we are holding SME lock at this point.
16984 status = csrRequestFullPower( pMac, pCommand );
16985 if( HAL_STATUS_SUCCESS( status ) )
16986 {
16987 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016988 //make sure roamCmdPendingList is not empty first
16989 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16990 if( fNoCmdPending )
16991 {
16992 smePushCommand( pMac, pCommand, fHighPriority );
16993 }
16994 else
16995 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016996 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016997 //no list lock is needed since SME lock is held
16998 if( !fHighPriority )
16999 {
17000 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17001 }
17002 else {
17003 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17004 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017005 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017006 }
17007 else if( eHAL_STATUS_PMC_PENDING == status )
17008 {
17009 //no list lock is needed since SME lock is held
17010 if( !fHighPriority )
17011 {
17012 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17013 }
17014 else {
17015 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17016 }
17017 //Let caller know the command is queue
17018 status = eHAL_STATUS_SUCCESS;
17019 }
17020 else
17021 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017022 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070017023 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017024 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070017025 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017026end:
Jeff Johnson295189b2012-06-20 16:38:30 -070017027 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070017028}
Jeff Johnson295189b2012-06-20 16:38:30 -070017029eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
17030{
17031 eHalStatus status = eHAL_STATUS_SUCCESS;
17032 tSirUpdateAPWPSIEsReq *pMsg;
17033 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
17034
17035 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17036 if (NULL == pSession)
17037 {
17038 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17039 return eHAL_STATUS_FAILURE;
17040 }
17041
Jeff Johnson295189b2012-06-20 16:38:30 -070017042 do
17043 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017044 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
17045 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17046 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017047 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
17048
17049 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070017050 VOS_ASSERT(pBuf);
17051
Jeff Johnson295189b2012-06-20 16:38:30 -070017052 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017053 // transactionId
17054 *pBuf = 0;
17055 *( pBuf + 1 ) = 0;
17056 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070017057 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017058 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17059 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017060 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017061 //sessionId
17062 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017063 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017064 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070017065 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070017066 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017067 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017068 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017069 return ( status );
17070}
Jeff Johnson295189b2012-06-20 16:38:30 -070017071eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
17072{
17073 eHalStatus status = eHAL_STATUS_SUCCESS;
17074 tSirUpdateAPWPARSNIEsReq *pMsg;
17075 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017076 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17077 if (NULL == pSession)
17078 {
17079 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17080 return eHAL_STATUS_FAILURE;
17081 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017082 do
17083 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017084 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
17085 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17086 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017087 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070017088 pBuf = (tANI_U8 *)&pMsg->transactionId;
17089 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017090 // transactionId
17091 *pBuf = 0;
17092 *( pBuf + 1 ) = 0;
17093 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070017094 VOS_ASSERT(pBuf);
17095
Jeff Johnson295189b2012-06-20 16:38:30 -070017096 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017097 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17098 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017099 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017100 // sessionId
17101 *pBuf++ = (tANI_U8)sessionId;
17102
17103 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017104 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070017105 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070017106 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017107 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017108 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017109 return ( status );
17110}
Jeff Johnson295189b2012-06-20 16:38:30 -070017111
17112#ifdef WLAN_FEATURE_VOWIFI_11R
17113//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
17114eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
17115{
17116 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17117 tpSirFTPreAuthReq pftPreAuthReq;
17118 tANI_U16 auth_req_len = 0;
17119 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017120 auth_req_len = sizeof(tSirFTPreAuthReq);
17121 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053017122 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070017123 {
17124 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
17125 return eHAL_STATUS_RESOURCES;
17126 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017127 // Save the SME Session ID here. We need it while processing the preauth response
17128 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017129 vos_mem_zero(pftPreAuthReq, auth_req_len);
17130
17131 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
17132 sizeof(pBssDescription->length) + pBssDescription->length);
17133
17134 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
17135
17136 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
17137
Kiet Lam64c1b492013-07-12 13:56:44 +053017138 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
17139 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
17140 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
17141 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017142
Jeff Johnson295189b2012-06-20 16:38:30 -070017143#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080017144 if (csrRoamIs11rAssoc(pMac) &&
17145 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070017146 {
17147 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053017148 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
17149 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070017150 }
17151 else
17152#endif
17153 {
17154 pftPreAuthReq->ft_ies_length = 0;
17155 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070017156 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
17157 sizeof(pBssDescription->length) + pBssDescription->length);
17158 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070017159 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
17160}
Jeff Johnson295189b2012-06-20 16:38:30 -070017161/*--------------------------------------------------------------------------
17162 * This will receive and process the FT Pre Auth Rsp from the current
17163 * associated ap.
17164 *
17165 * This will invoke the hdd call back. This is so that hdd can now
17166 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
17167 ------------------------------------------------------------------------*/
17168void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
17169{
17170 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17171 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017172#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017173 tCsrRoamInfo roamInfo;
17174#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017175 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070017176
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017177#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080017178 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017179 if (status != eHAL_STATUS_SUCCESS) {
17180 /*
17181 * Bail out if pre-auth was not even processed.
17182 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017183 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
17184 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017185 return;
17186 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017187#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017188 /* The below function calls/timers should be invoked only if the pre-auth is successful */
17189 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
17190 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070017191 // Implies a success
17192 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017193 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
17194 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053017195 /* No need to notify qos module if this is a non 11r & ESE roam*/
17196 if (csrRoamIs11rAssoc(pMac)
17197#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
17198 || csrRoamIsESEAssoc(pMac)
17199#endif
17200 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070017201 {
17202 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17203 }
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017204#ifdef DEBUG_ROAM_DELAY
17205 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
17206#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017207 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17208 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017209 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
17210 60);
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017211#ifdef DEBUG_ROAM_DELAY
17212 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
17213#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017214 if (eHAL_STATUS_SUCCESS != status)
17215 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017216 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017217 return;
17218 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017219 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017220 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
17221 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070017222 if (csrRoamIs11rAssoc(pMac))
17223 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17224 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
17225
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017226#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17227 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017228 {
17229 /* read TSF */
17230 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
17231
17232 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017233 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017234 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
17235 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017236#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017237#ifdef FEATURE_WLAN_LFR
17238 // If Legacy Fast Roaming is enabled, signal the supplicant
17239 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053017240 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017241 {
17242 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017243 vos_mem_copy((void *)&roamInfo.bssid,
17244 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017245 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17246 }
17247
17248#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017249
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017250 // If its an Open Auth, FT IEs are not provided by supplicant
17251 // Hence populate them here
17252 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
17253 pMac->ft.ftSmeContext.addMDIE = FALSE;
17254 if( csrRoamIs11rAssoc(pMac) &&
17255 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
17256 {
17257 tANI_U16 ft_ies_length;
17258 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
17259
17260 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
17261 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
17262 {
17263 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
17264 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
17265 }
17266
17267 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
17268 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
17269 {
17270 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
17271 }
17272 else
17273 {
17274 // Copy the RIC IEs to reassoc IEs
17275 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
17276 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
17277 pFTPreAuthRsp->ric_ies_length);
17278 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
17279 pMac->ft.ftSmeContext.addMDIE = TRUE;
17280 }
17281 }
17282
Jeff Johnson295189b2012-06-20 16:38:30 -070017283 // Done with it, init it.
17284 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
17285}
17286#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017287
Jeff Johnson295189b2012-06-20 16:38:30 -070017288#ifdef FEATURE_WLAN_BTAMP_UT_RF
17289void csrRoamJoinRetryTimerHandler(void *pv)
17290{
17291 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
17292 tpAniSirGlobal pMac = pInfo->pMac;
17293 tANI_U32 sessionId = pInfo->sessionId;
17294 tCsrRoamSession *pSession;
17295
17296 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17297 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017298 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017299 pSession = CSR_GET_SESSION( pMac, sessionId );
17300 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17301 {
17302 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017304 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017305 }
17306 }
17307 }
17308}
Jeff Johnson295189b2012-06-20 16:38:30 -070017309eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17310{
17311 eHalStatus status = eHAL_STATUS_FAILURE;
17312 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17313
17314 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17315 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017316 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017317 pSession->maxRetryCount--;
17318 pSession->joinRetryTimerInfo.pMac = pMac;
17319 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017320 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17321 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017322 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017323 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017324 }
17325 }
17326 else
17327 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017328 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017329 pSession->maxRetryCount);
17330 }
17331
17332 return (status);
17333}
Jeff Johnson295189b2012-06-20 16:38:30 -070017334eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17335{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017336 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017337 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17338 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017339 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017340 }
17341
17342 return eHAL_STATUS_SUCCESS;
17343}
17344#endif
17345
17346
17347/*
17348 pBuf points to the beginning of the message
17349 LIM packs disassoc rsp as below,
17350 messageType - 2 bytes
17351 messageLength - 2 bytes
17352 sessionId - 1 byte
17353 transactionId - 2 bytes (tANI_U16)
17354 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17355 peerMacAddr - 6 bytes
17356 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17357*/
17358static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17359{
17360 if(pBuf && pRsp)
17361 {
17362 pBuf += 4; //skip type and length
17363 pRsp->sessionId = *pBuf++;
17364 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17365 pBuf += 2;
17366 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17367 pBuf += 4;
17368 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17369 }
17370}
17371
Jeff Johnsond13512a2012-07-17 11:42:19 -070017372eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17373{
17374 static uNvTables nvTables;
17375 eHalStatus status = eHAL_STATUS_SUCCESS;
17376 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17377
17378 /* read the country code from NV and use it */
17379 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17380 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017381 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17382 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017383 return status;
17384 }
17385 else
17386 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017387 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017388 status = eHAL_STATUS_FAILURE;
17389 return status;
17390 }
17391}
17392
17393eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17394{
Kiet Lam64c1b492013-07-12 13:56:44 +053017395 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017396 return eHAL_STATUS_SUCCESS;
17397}
schang86c22c42013-03-13 18:41:24 -070017398
17399eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17400{
17401 tSirSetTxPowerReq *pMsg = NULL;
17402 eHalStatus status = eHAL_STATUS_SUCCESS;
17403 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17404
17405 if (!pSession)
17406 {
17407 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17408 return eHAL_STATUS_FAILURE;
17409 }
17410
Kiet Lam64c1b492013-07-12 13:56:44 +053017411 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17412 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17413 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17414 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17415 pMsg->length = sizeof(tSirSetTxPowerReq);
17416 pMsg->mwPower = mW;
17417 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17418 sizeof(tSirMacAddr));
17419 status = palSendMBMessage(pMac->hHdd, pMsg);
17420 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017421 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017422 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17423 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017424 }
17425 return status;
17426}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017427
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017428eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17429{
17430 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17431 eHalStatus status = eHAL_STATUS_SUCCESS;
17432 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17433
17434 if (!pSession)
17435 {
17436 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17437 return eHAL_STATUS_FAILURE;
17438 }
17439 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17440 {
17441 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053017442
17443 if( NULL == pMsg )
17444 {
17445 smsLog(pMac, LOGE, FL("PMsg is NULL "));
17446 return eHAL_STATUS_FAILURE;
17447 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017448 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17449 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17450 pMsg->length = sizeof(tANI_U8);
17451 pMsg->seesionId = sessionId;
17452 status = palSendMBMessage(pMac->hHdd, pMsg);
17453 if (!HAL_STATUS_SUCCESS(status))
17454 {
17455 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17456 //pMsg is freed by palSendMBMessage
17457 }
17458 }
17459 else
17460 {
17461 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17462 status = eHAL_STATUS_FAILURE;
17463 }
17464 return status;
17465}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017466/* Returns whether a session is in VOS_STA_MODE...or not */
17467tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17468{
17469 tCsrRoamSession *pSession = NULL;
17470 pSession = CSR_GET_SESSION ( pMac, sessionId );
17471 if(!pSession)
17472 {
17473 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17474 return eANI_BOOLEAN_FALSE;
17475 }
17476 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17477 {
17478 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17479 return eANI_BOOLEAN_FALSE;
17480 }
17481 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17482 {
17483 return eANI_BOOLEAN_FALSE;
17484 }
17485 /* There is a possibility that the above check may fail,because
17486 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17487 * when it is connected.So,we may sneak through the above check even
17488 * if we are not a STA mode INFRA station. So, if we sneak through
17489 * the above condition, we can use the following check if we are
17490 * really in STA Mode.*/
17491
17492 if ( NULL != pSession->pCurRoamProfile )
17493 {
17494 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17495 {
17496 return eANI_BOOLEAN_TRUE;
17497 } else {
17498 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17499 return eANI_BOOLEAN_FALSE;
17500 }
17501 }
17502
17503 return eANI_BOOLEAN_FALSE;
17504}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017505
17506#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17507eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17508 tCsrHandoffRequest *pHandoffInfo)
17509{
17510 eHalStatus status = eHAL_STATUS_SUCCESS;
17511 vos_msg_t msg;
17512
17513 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017514 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17515 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017516 {
17517 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017518 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017519 }
17520 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17521 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17522 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17523 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017524 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017525 pHandoffInfo->bssid,
17526 6);
17527 msg.type = eWNI_SME_HANDOFF_REQ;
17528 msg.bodyptr = pMsg;
17529 msg.reserved = 0;
17530 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17531 {
17532 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017533 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017534 status = eHAL_STATUS_FAILURE;
17535 }
17536 return status;
17537}
17538#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017539
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017540
17541#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017542/* ---------------------------------------------------------------------------
17543 \fn csrSetCCKMIe
17544 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17545 data structure and this IE will be packed inside reassociation request
17546 \param pMac - pMac global structure
17547 \param sessionId - Current session id
17548 \param pCckmIe - pointer to CCKM IE data
17549 \param ccKmIeLen - length of the CCKM IE
17550 \- return Success or failure
17551 -------------------------------------------------------------------------*/
17552VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17553 const tANI_U8 *pCckmIe,
17554 const tANI_U8 ccKmIeLen)
17555{
17556 eHalStatus status = eHAL_STATUS_SUCCESS;
17557 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17558
17559 if (!pSession)
17560 {
17561 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17562 return eHAL_STATUS_FAILURE;
17563 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017564 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017565 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17566 return status;
17567}
17568
17569/* ---------------------------------------------------------------------------
17570 \fn csrRoamReadTSF
17571 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17572 probe response reception from the hand off AP to arrive at the latest TSF value.
17573 \param pMac - pMac global structure
17574 \param pTimestamp - output TSF timestamp
17575 \- return Success or failure
17576 -------------------------------------------------------------------------*/
17577VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17578{
17579 eHalStatus status = eHAL_STATUS_SUCCESS;
17580 tCsrNeighborRoamBSSInfo handoffNode;
17581 tANI_U32 timer_diff = 0;
17582 tANI_U32 timeStamp[2];
17583 tpSirBssDescription pBssDescription = NULL;
17584
17585 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17586 pBssDescription = handoffNode.pBssDescription;
17587
17588 // Get the time diff in milli seconds
17589 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17590 // Convert msec to micro sec timer
17591 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17592
17593 timeStamp[0] = pBssDescription->timeStamp[0];
17594 timeStamp[1] = pBssDescription->timeStamp[1];
17595
17596 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17597
Kiet Lamf2f201e2013-11-16 21:24:16 +053017598 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017599 sizeof (tANI_U32) * 2);
17600 return status;
17601}
17602
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017603#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017604