blob: 2817bbb7cb0a57b454971c7fcc64e7a33d0ced9b [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:
Abhishek Singhae408032014-09-25 17:22:04 +0530136#ifdef WLAN_FEATURE_11W
137 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
138#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700139 n = AUTH_WPA2_EAP;
140 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700141 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700142#ifdef WLAN_FEATURE_11W
143 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
144#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700145 n = AUTH_WPA2_PSK;
146 break;
147#ifdef FEATURE_WLAN_WAPI
148 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
149 n = AUTH_WAPI_CERT;
150 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
152 n = AUTH_WAPI_PSK;
153 break;
154#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 default:
156 break;
157 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700158 return (n);
159}
Jeff Johnson295189b2012-06-20 16:38:30 -0700160int diagEncTypeFromCSRType(eCsrEncryptionType encType)
161{
162 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 switch(encType)
164 {
165 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
166 case eCSR_ENCRYPT_TYPE_WEP40:
167 n = ENC_MODE_WEP40;
168 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
170 case eCSR_ENCRYPT_TYPE_WEP104:
171 n = ENC_MODE_WEP104;
172 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700173 case eCSR_ENCRYPT_TYPE_TKIP:
174 n = ENC_MODE_TKIP;
175 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700176 case eCSR_ENCRYPT_TYPE_AES:
177 n = ENC_MODE_AES;
178 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700179#ifdef FEATURE_WLAN_WAPI
180 case eCSR_ENCRYPT_TYPE_WPI:
181 n = ENC_MODE_SMS4;
182 break;
183#endif /* FEATURE_WLAN_WAPI */
184 default:
185 break;
186 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700187 return (n);
188}
Jeff Johnson295189b2012-06-20 16:38:30 -0700189#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700190static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
191static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700192static void initConfigParam(tpAniSirGlobal pMac);
193static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
194 eCsrRoamCompleteResult Result, void *Context );
195static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
196 tCsrRoamProfile *pProfile,
197 tANI_BOOLEAN *pfSameIbss );
198static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
199static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700200 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
201static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700202eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
203static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
204eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
205eHalStatus csrRoamClose(tpAniSirGlobal pMac);
206void csrRoamMICErrorTimerHandler(void *pv);
207void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
208tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
209
210static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
211static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
212static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700213eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
214eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
215static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700216static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700217static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700218static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
219eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
220 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
221 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
222 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
223 tANI_U8 *pKeyRsc );
224static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
225 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
226 tCsrRoamProfile *pProfile );
227void csrRoamStatisticsTimerHandler(void *pv);
228void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700229static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
230VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
231 v_U8_t rssiNotification,
232 void * context);
233static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
234void csrRoamVccTrigger(tpAniSirGlobal pMac);
235eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
236/*
237 pStaEntry is no longer invalid upon the return of this function.
238*/
239static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700240static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700241static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700242tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
243 tDblLinkList *pStaList,
244 tCsrStatsClientReqInfo *pStaEntry);
245void csrRoamStatsClientTimerHandler(void *pv);
246tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
247 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
248void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
249 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700250void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700251void csrRoamTlStatsTimerHandler(void *pv);
252void csrRoamPeStatsTimerHandler(void *pv);
253tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
254void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
255tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
256eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
257static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
258static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
259static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
260static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
261 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
262//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
263static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
264void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
265#ifdef FEATURE_WLAN_BTAMP_UT_RF
266void csrRoamJoinRetryTimerHandler(void *pv);
267#endif
Atul Mittalb849d5a2014-07-29 12:08:39 +0530268void limInitOperatingClasses( tHalHandle hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -0700269extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700270extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700271static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700272void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700273
274//Initialize global variables
275static void csrRoamInitGlobals(tpAniSirGlobal pMac)
276{
277 if(pMac)
278 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800279 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
280 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 }
282 return;
283}
284
Jeff Johnson295189b2012-06-20 16:38:30 -0700285static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
286{
287 if(pMac)
288 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800289 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 }
291 return;
292}
Jeff Johnson295189b2012-06-20 16:38:30 -0700293eHalStatus csrOpen(tpAniSirGlobal pMac)
294{
295 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530296#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 static uNvTables nvTables;
298 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530300#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700301 tANI_U32 i;
302
303 do
304 {
305 /* Initialize CSR Roam Globals */
306 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700307 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
308 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
309
310 initConfigParam(pMac);
311 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
312 break;
313 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
314 break;
315 pMac->roam.nextRoamId = 1; //Must not be 0
316 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
317 break;
318 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
319 break;
320 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
321 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530322
323#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
325 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
326 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530327 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
328 WNI_CFG_COUNTRY_CODE_LEN);
329 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700330 }
331 else
332 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800333 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 //hardcoded for now
335 pMac->scan.countryCodeDefault[0] = 'U';
336 pMac->scan.countryCodeDefault[1] = 'S';
337 pMac->scan.countryCodeDefault[2] = 'I';
338 //status = eHAL_STATUS_SUCCESS;
339 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700340 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530341
342 if (!('0' == pMac->scan.countryCodeDefault[0] &&
343 '0' == pMac->scan.countryCodeDefault[1]))
344 {
345 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
346 &regId, COUNTRY_NV);
347 }
348 else
349 {
350 regId = REGDOMAIN_WORLD;
351 }
Abhishek Singha306a442013-11-07 18:39:01 +0530352 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700353 pMac->scan.domainIdDefault = regId;
354 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530355 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
356 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530358#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 }while(0);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530360
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 return (status);
362}
363
Mihir Shetee1093ba2014-01-21 20:13:32 +0530364/* --------------------------------------------------------------------------
365 \fn csrInitChannels
366 \brief This function must be called to initialize CSR channel lists
367 \return eHalStatus
368 ----------------------------------------------------------------------------*/
369eHalStatus csrInitChannels(tpAniSirGlobal pMac)
370{
371 eHalStatus status = eHAL_STATUS_SUCCESS;
372 static uNvTables nvTables;
373 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530374 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530375
376 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
377 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
378 {
379 vos_mem_copy(pMac->scan.countryCodeDefault,
380 nvTables.defaultCountryTable.countryCode,
381 WNI_CFG_COUNTRY_CODE_LEN);
382 }
383 else
384 {
385 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
386 //hardcoded for now
387 pMac->scan.countryCodeDefault[0] = 'U';
388 pMac->scan.countryCodeDefault[1] = 'S';
389 pMac->scan.countryCodeDefault[2] = 'I';
390 }
391 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
392
Mihir Shetee1093ba2014-01-21 20:13:32 +0530393 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
394 pMac->scan.domainIdDefault = regId;
395 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
396 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
397 WNI_CFG_COUNTRY_CODE_LEN);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530398 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
399 WNI_CFG_COUNTRY_CODE_LEN);
Agarwal Ashishcd9b8e62014-07-21 19:48:24 +0530400 vos_mem_copy(pMac->scan.countryCode11d, pMac->scan.countryCodeDefault,
401 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530402 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530403 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530404
405 return status;
406}
407
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530408eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac, driver_load_type init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530409{
410 eHalStatus status = eHAL_STATUS_SUCCESS;
411 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530412 tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN];
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530413
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530414 /* In case of driver load ; driver need to get channel
415 * list with default Countrycode.
416 * In case of SSR; driver need to get channel list
417 * with old country code. 0 is for init and
418 * 1 is for reinit
419 */
420 switch (init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530421 {
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530422 case INIT:
423 vos_mem_copy(cc, pMac->scan.countryCodeDefault,
424 WNI_CFG_COUNTRY_CODE_LEN);
425 if (!('0' == cc[0] &&
426 '0' == cc[1]))
427 {
428 csrGetRegulatoryDomainForCountry(pMac, cc,
429 &regId, COUNTRY_NV);
430 }
431 else
432 {
433 return status;
434 }
435 pMac->scan.domainIdDefault = regId;
436 break;
437 case REINIT:
438 vos_getCurrentCountryCode(&cc[0]);
439 status = csrGetRegulatoryDomainForCountry(pMac,
440 cc, &regId, COUNTRY_QUERY);
441 break;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530442 }
443 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530444 pMac->scan.domainIdCurrent = regId;
445 vos_mem_copy(pMac->scan.countryCodeCurrent, cc,
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530446 WNI_CFG_COUNTRY_CODE_LEN);
447 status = csrInitGetChannels( pMac );
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530448
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530449 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
450 FL("Current Country is %c%c "), pMac->scan.countryCodeCurrent[0],
451 pMac->scan.countryCodeCurrent[1]);
452
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530453 /* reset info based on new cc, and we are done */
454 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
455 csrScanFilterResults(pMac);
456
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530457 return status;
458}
459
Jeff Johnson295189b2012-06-20 16:38:30 -0700460eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
461{
462 eHalStatus status = eHAL_STATUS_SUCCESS;
463 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
464 v_REGDOMAIN_t regId;
465 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 if(NULL == apCntryCode)
467 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530468 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 return eHAL_STATUS_FAILURE;
470 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530471 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700472 /* To get correct Regulatory domain from NV table
473 * 2 character Country code should be used
474 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700475 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
476/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700478
479 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
480 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800481 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700482 return eHAL_STATUS_FAILURE;
483 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700484*/
Kiet Lam6c583332013-10-14 05:37:09 +0530485 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
486 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 if (status != eHAL_STATUS_SUCCESS)
488 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700489 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 return status;
491 }
Abhishek Singha306a442013-11-07 18:39:01 +0530492 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 if (status != eHAL_STATUS_SUCCESS)
494 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700495 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700496 return status;
497 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 pMac->scan.domainIdDefault = regId;
499 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700500 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530501 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
502
Jeff Johnson295189b2012-06-20 16:38:30 -0700503 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530504 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
505
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 /* If 2 bytes country code, 3rd byte must be filled with space */
507 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
508 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530509 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530511 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
512 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700514 return status;
515}
Jeff Johnson295189b2012-06-20 16:38:30 -0700516eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
517{
518 eHalStatus status = eHAL_STATUS_SUCCESS;
519 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
520 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530521 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
522 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
524 {
525 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
526 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
527 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
528 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
529 }
530 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
531
532 return status;
533}
Jeff Johnson295189b2012-06-20 16:38:30 -0700534eHalStatus csrClose(tpAniSirGlobal pMac)
535{
536 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800537
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 csrRoamClose(pMac);
539 csrScanClose(pMac);
540 csrLLClose(&pMac->roam.statsClientReqList);
541 csrLLClose(&pMac->roam.peStatsReqList);
542 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 /* DeInit Globals */
544 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 return (status);
546}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530547
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800548eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530549{
550 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800551 tCsrScanStruct *pScan = &pMac->scan;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530552 tANI_U32 numChan = 0;
553 tANI_U32 bufLen ;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530554 vos_msg_t msg;
555 tANI_U8 i;
556
Atul Mittalb849d5a2014-07-29 12:08:39 +0530557 limInitOperatingClasses((tHalHandle)pMac);
Agarwal Ashish738843c2014-09-25 12:27:56 +0530558 numChan = sizeof(pMac->roam.validChannelList);
559
560 if ( !HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
561 (tANI_U8 *)pMac->roam.validChannelList, &numChan)))
562 {
563 smsLog( pMac, LOGE, "Failed to get Channel list from CFG");
564 return eHAL_STATUS_FAILED_ALLOC;
565 }
566
567 bufLen = sizeof(tSirUpdateChanList) +
568 (sizeof(tSirUpdateChanParam) * (numChan - 1));
569
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530570 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
571 if (!pChanList)
572 {
573 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
574 "Failed to allocate memory for tSirUpdateChanList");
575 return eHAL_STATUS_FAILED_ALLOC;
576 }
577
578 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
579 msg.reserved = 0;
580 msg.bodyptr = pChanList;
581 pChanList->numChan = numChan;
582 for (i = 0; i < pChanList->numChan; i++)
583 {
Agarwal Ashish738843c2014-09-25 12:27:56 +0530584 pChanList->chanParam[i].chanId = pMac->roam.validChannelList[i];
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800585 pChanList->chanParam[i].pwr = cfgGetRegulatoryMaxTransmitPower(pMac,
586 pScan->defaultPowerTable[i].chanId);
587 if (vos_nv_getChannelEnabledState(pChanList->chanParam[i].chanId) ==
588 NV_CHANNEL_DFS)
589 pChanList->chanParam[i].dfsSet = VOS_TRUE;
590 else
591 pChanList->chanParam[i].dfsSet = VOS_FALSE;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530592 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
593 "%s Supported Channel: %d\n", __func__, pChanList->chanParam[i].chanId);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530594 }
595
596 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
597 {
598 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
599 "%s: Failed to post msg to WDA", __func__);
600 vos_mem_free(pChanList);
601 return eHAL_STATUS_FAILURE;
602 }
603
604 return eHAL_STATUS_SUCCESS;
605}
606
Jeff Johnson295189b2012-06-20 16:38:30 -0700607eHalStatus csrStart(tpAniSirGlobal pMac)
608{
609 eHalStatus status = eHAL_STATUS_SUCCESS;
610 tANI_U32 i;
611
612 do
613 {
614 //save the global vos context
615 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
616 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
617 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
618
619 status = csrRoamStart(pMac);
620 if(!HAL_STATUS_SUCCESS(status)) break;
621 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
622 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
623 if(!HAL_STATUS_SUCCESS(status)) break;
624 pMac->roam.sPendingCommands = 0;
625 csrScanEnable(pMac);
626#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
627 status = csrNeighborRoamInit(pMac);
628#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
629 pMac->roam.tlStatsReqInfo.numClient = 0;
630 pMac->roam.tlStatsReqInfo.periodicity = 0;
631 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
632 //init the link quality indication also
633 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
634 if(!HAL_STATUS_SUCCESS(status))
635 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800636 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 break;
638 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530639
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700641#if defined(ANI_LOGDUMP)
642 csrDumpInit(pMac);
643#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 return (status);
645}
646
Kiet Lama72a2322013-11-15 11:18:11 +0530647eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700648{
649 tANI_U32 sessionId;
650 tANI_U32 i;
651
652 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
653 {
654 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
655 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700656 csrScanDisable(pMac);
657 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
658 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
660
661#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
662 csrNeighborRoamClose(pMac);
663#endif
664 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 // deregister from PMC since we register during csrStart()
666 // (ignore status since there is nothing we can do if it fails)
667 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 //Reset the domain back to the deault
669 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800670 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700671
672 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
673 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530674 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
676 }
677
Kiet Lama72a2322013-11-15 11:18:11 +0530678#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
679 /* When HAL resets all the context information
680 * in HAL is lost, so we might need to send the
681 * scan offload request again when it comes
682 * out of reset for scan offload to be functional
683 */
684 if (HAL_STOP_TYPE_SYS_RESET == stopType)
685 {
686 bRoamScanOffloadStarted = VOS_FALSE;
687 }
688#endif
689
Jeff Johnson295189b2012-06-20 16:38:30 -0700690 return (eHAL_STATUS_SUCCESS);
691}
692
Jeff Johnson295189b2012-06-20 16:38:30 -0700693eHalStatus csrReady(tpAniSirGlobal pMac)
694{
695 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 csrScanGetSupportedChannels( pMac );
697 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
698 //use it to init the background scan list
699 csrInitBGScanChannelList(pMac);
700 /* HDD issues the init scan */
701 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800702 /* If the gScanAgingTime is set to '0' then scan results aging timeout
703 based on timer feature is not enabled*/
704 if(0 != pMac->scan.scanResultCfgAgingTime )
705 {
706 csrScanStartResultCfgAgingTimer(pMac);
707 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 //Store the AC weights in TL for later use
709 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 status = csrInitChannelList( pMac );
711 if ( ! HAL_STATUS_SUCCESS( status ) )
712 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800713 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 status );
715 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 return (status);
717}
Jeff Johnson295189b2012-06-20 16:38:30 -0700718void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
719{
720 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
722 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
723}
Jeff Johnson295189b2012-06-20 16:38:30 -0700724void csrSetGlobalCfgs( tpAniSirGlobal pMac )
725{
Jeff Johnsone7245742012-09-05 17:12:55 -0700726
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
728 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
729 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
730 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
731 NULL, eANI_BOOLEAN_FALSE);
732 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700733 /* 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
734 * Once session is established we will use the session related params stored in PE session for CB mode
735 */
736 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
738
739 //Update the operating mode to configured value during initialization,
740 //So that client can advertise full capabilities in Probe request frame.
741 csrSetDefaultDot11Mode( pMac );
742}
743
Jeff Johnson295189b2012-06-20 16:38:30 -0700744eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
745{
746 eHalStatus status = eHAL_STATUS_SUCCESS;
747 tANI_U32 i;
748 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 do
750 {
751 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
752 {
753 pSession = CSR_GET_SESSION( pMac, i );
754 pSession->roamingTimerInfo.pMac = pMac;
755 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
756 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
758 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530759 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
760 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530762 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800764 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 break;
766 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530767 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
768 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
769 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800771 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 return eHAL_STATUS_FAILURE;
773 }
774 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 return (status);
776}
777
Jeff Johnson295189b2012-06-20 16:38:30 -0700778eHalStatus csrRoamClose(tpAniSirGlobal pMac)
779{
780 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700781 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
782 {
783 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
784 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530785 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
786 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
787 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
788 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 return (eHAL_STATUS_SUCCESS);
790}
791
Jeff Johnson295189b2012-06-20 16:38:30 -0700792eHalStatus csrRoamStart(tpAniSirGlobal pMac)
793{
794 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700795 return (eHAL_STATUS_SUCCESS);
796}
797
Jeff Johnson295189b2012-06-20 16:38:30 -0700798void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
799{
800 csrRoamStopRoamingTimer(pMac, sessionId);
801 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
802 csrRoamDeregStatisticsReq(pMac);
803}
Jeff Johnson295189b2012-06-20 16:38:30 -0700804eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
805{
806 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800807 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 {
809 status = eHAL_STATUS_SUCCESS;
810 *pState = pMac->roam.roamSession[sessionId].connectState;
811 }
812 return (status);
813}
814
Jeff Johnson295189b2012-06-20 16:38:30 -0700815eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
816{
817 eHalStatus status = eHAL_STATUS_FAILURE;
818 tANI_U32 size = 0;
819 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700820
821 if(!pSession)
822 {
823 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
824 return eHAL_STATUS_FAILURE;
825 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700826
827 if(pProfile)
828 {
829 if(pSession->pConnectBssDesc)
830 {
831 do
832 {
833 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
834 if(size)
835 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530836 pProfile->pBssDesc = vos_mem_malloc(size);
837 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530839 vos_mem_copy(pProfile->pBssDesc,
840 pSession->pConnectBssDesc, size);
841 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 }
843 else
844 break;
845 }
846 else
847 {
848 pProfile->pBssDesc = NULL;
849 }
850 pProfile->AuthType = pSession->connectedProfile.AuthType;
851 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
852 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
853 pProfile->BSSType = pSession->connectedProfile.BSSType;
854 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
855 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530856 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
857 sizeof(tCsrBssid));
858 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
859 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700860#ifdef WLAN_FEATURE_VOWIFI_11R
861 if (pSession->connectedProfile.MDID.mdiePresent)
862 {
863 pProfile->MDID.mdiePresent = 1;
864 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
865 }
866 else
867 {
868 pProfile->MDID.mdiePresent = 0;
869 pProfile->MDID.mobilityDomain = 0;
870 }
871#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800872#ifdef FEATURE_WLAN_ESE
873 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
874 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800876 vos_mem_copy (pProfile->eseCckmInfo.krk,
877 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530878 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800879 pProfile->eseCckmInfo.reassoc_req_num=
880 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
881 pProfile->eseCckmInfo.krk_plumbed =
882 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 }
884#endif
885 }while(0);
886 }
887 }
888
889 return (status);
890}
891
Jeff Johnson295189b2012-06-20 16:38:30 -0700892eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
893{
894 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700895
896 if((csrIsConnStateConnected(pMac, sessionId)) ||
897 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 {
899 if(pProfile)
900 {
901 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
902 }
903 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 return (status);
905}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700906
Jeff Johnson295189b2012-06-20 16:38:30 -0700907eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
908{
909 eHalStatus status = eHAL_STATUS_SUCCESS;
910
Kiet Lam64c1b492013-07-12 13:56:44 +0530911 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530913 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530915 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700916 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530917 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700918 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530919 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
920
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
922 return (status);
923}
924
Jeff Johnson295189b2012-06-20 16:38:30 -0700925static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
926{
927 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700928 if( pConnectedInfo->pbFrames )
929 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530930 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700931 pConnectedInfo->pbFrames = NULL;
932 }
933 pConnectedInfo->nBeaconLength = 0;
934 pConnectedInfo->nAssocReqLength = 0;
935 pConnectedInfo->nAssocRspLength = 0;
936 pConnectedInfo->staId = 0;
937#ifdef WLAN_FEATURE_VOWIFI_11R
938 pConnectedInfo->nRICRspLength = 0;
939#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800940#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700941 pConnectedInfo->nTspecIeLength = 0;
942#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 return ( status );
944}
945
Jeff Johnson295189b2012-06-20 16:38:30 -0700946
947
Jeff Johnsone7245742012-09-05 17:12:55 -0700948
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700949void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
950{
951 csrReinitPreauthCmd(pMac, pCommand);
952 csrReleaseCommand( pMac, pCommand );
953}
954
Jeff Johnson295189b2012-06-20 16:38:30 -0700955void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
956{
957 csrReinitRoamCmd(pMac, pCommand);
958 csrReleaseCommand( pMac, pCommand );
959}
960
Jeff Johnson295189b2012-06-20 16:38:30 -0700961void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
962{
963 csrReinitScanCmd(pMac, pCommand);
964 csrReleaseCommand( pMac, pCommand );
965}
966
Jeff Johnson295189b2012-06-20 16:38:30 -0700967void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
968{
969 csrReinitWmStatusChangeCmd(pMac, pCommand);
970 csrReleaseCommand( pMac, pCommand );
971}
972
Jeff Johnson295189b2012-06-20 16:38:30 -0700973void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
974{
Kiet Lam64c1b492013-07-12 13:56:44 +0530975 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700976}
977
Jeff Johnson295189b2012-06-20 16:38:30 -0700978void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
979{
Kiet Lam64c1b492013-07-12 13:56:44 +0530980 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700981}
982
Jeff Johnson295189b2012-06-20 16:38:30 -0700983void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
984{
985 csrReinitSetKeyCmd(pMac, pCommand);
986 csrReleaseCommand( pMac, pCommand );
987}
Jeff Johnson295189b2012-06-20 16:38:30 -0700988void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
989{
990 csrReinitRemoveKeyCmd(pMac, pCommand);
991 csrReleaseCommand( pMac, pCommand );
992}
Jeff Johnson295189b2012-06-20 16:38:30 -0700993void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
994{
995
996 if( eSmeCsrCommandMask & pCommand->command )
997 {
998 switch (pCommand->command)
999 {
1000 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -08001001 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -08001002 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
1003 __func__, pCommand->u.scanCmd.reason,
1004 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001005 if (NULL != pCommand->u.scanCmd.callback)
1006 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001007 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
1009 }
1010 csrReleaseCommandScan( pMac, pCommand );
1011 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 case eSmeCommandRoam:
1013 csrReleaseCommandRoam( pMac, pCommand );
1014 break;
1015
1016 case eSmeCommandWmStatusChange:
1017 csrReleaseCommandWmStatusChange( pMac, pCommand );
1018 break;
1019
1020 case eSmeCommandSetKey:
1021 csrReleaseCommandSetKey( pMac, pCommand );
1022 break;
1023
1024 case eSmeCommandRemoveKey:
1025 csrReleaseCommandRemoveKey( pMac, pCommand );
1026 break;
1027
1028 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001029 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 csrReleaseCommand( pMac, pCommand );
1031 break;
1032 }
1033 }
1034}
1035
Jeff Johnson295189b2012-06-20 16:38:30 -07001036void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
1037{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301038 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1039 macTraceGetcsrRoamSubState(NewSubstate),
1040 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001041
Jeff Johnson295189b2012-06-20 16:38:30 -07001042 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1043 {
1044 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001046 pMac->roam.curSubState[sessionId] = NewSubstate;
1047}
1048
Jeff Johnson295189b2012-06-20 16:38:30 -07001049eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1050{
1051 eCsrRoamState PreviousState;
1052
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301053 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1054 macTraceGetcsrRoamState(NewRoamState),
1055 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001056
1057 PreviousState = pMac->roam.curState[sessionId];
1058
1059 if ( NewRoamState != pMac->roam.curState[sessionId] )
1060 {
1061 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1062 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1063 {
1064 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1065 }
1066
1067 pMac->roam.curState[sessionId] = NewRoamState;
1068 }
1069 return( PreviousState );
1070}
1071
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001072void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001073{
1074 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 if(catOffset)
1076 {
1077 pMac->roam.configParam.bCatRssiOffset = catOffset;
1078 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1079 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001080 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 -07001081 }
1082 }
1083}
1084
Jeff Johnson295189b2012-06-20 16:38:30 -07001085static void initConfigParam(tpAniSirGlobal pMac)
1086{
1087 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301089 pMac->roam.configParam.channelBondingMode24GHz =
1090 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1091 pMac->roam.configParam.channelBondingMode5GHz =
1092 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1094 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1095 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1096 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1097 pMac->roam.configParam.HeartbeatThresh24 = 40;
1098 pMac->roam.configParam.HeartbeatThresh50 = 40;
1099 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1100 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1101 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001102 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 pMac->roam.configParam.RTSThreshold = 2346;
1104 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1105 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1106 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1107 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1108 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1109 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1110 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1111 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1112 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1113 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1114 {
1115 pMac->roam.configParam.BssPreferValue[i] = i;
1116 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001117 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1119 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1120 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1122 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05301123 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1125 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1126 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1127 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001128 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1129 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001130 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001131#ifdef WLAN_AP_STA_CONCURRENCY
1132 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1133 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1134 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1135 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1136 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001137 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1138 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001139#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1141 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1142 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1143 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001144#ifdef WLAN_FEATURE_VOWIFI_11R
1145 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1146#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001147#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1148 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1149 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1150 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1151 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1152 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1153 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1154 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1155 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1156 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1157 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1158 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001159 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05301160 pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001161#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001162#ifdef WLAN_FEATURE_11AC
1163 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1164#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001165
1166 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1167 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001168
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001169 //Remove this code once SLM_Sessionization is supported
1170 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001171 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001172
Jeff Johnsone7245742012-09-05 17:12:55 -07001173}
Jeff Johnson295189b2012-06-20 16:38:30 -07001174eCsrBand csrGetCurrentBand(tHalHandle hHal)
1175{
1176 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1177 return pMac->roam.configParam.bandCapability;
1178}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001179
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001180
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001181#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001182/*
1183 This function flushes the roam scan cache
1184*/
1185eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1186{
1187 eHalStatus status = eHAL_STATUS_SUCCESS;
1188 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1189
1190 /* Free up the memory first (if required) */
1191 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1192 {
1193 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1194 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1195 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1196 }
1197 return status;
1198}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001199#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001200
1201
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001202#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001203/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001204 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001205*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001206eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001207{
1208 eHalStatus status = eHAL_STATUS_SUCCESS;
1209 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1210
1211 /* Free up the memory first (if required) */
1212 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1213 {
1214 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1215 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001216 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001217 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001218 return status;
1219}
1220
1221
1222
1223/*
1224 This function flushes the roam scan cache and creates fresh cache
1225 based on the input channel list
1226*/
1227eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1228 const tANI_U8 *pChannelList,
1229 const tANI_U8 numChannels)
1230{
1231 eHalStatus status = eHAL_STATUS_SUCCESS;
1232 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1233
Srinivas Girigowdade697412013-02-14 16:31:48 -08001234 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1235
1236 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1237 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1238
1239 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1240 {
1241 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1242 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1243 return eHAL_STATUS_RESOURCES;
1244 }
1245
1246 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301247 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1248 pChannelList,
1249 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001250 return status;
1251}
1252
1253/* This function modifies the bgscan channel list set via config ini or
1254 runtime, whenever the band changes.
1255 if the band is auto, then no operation is performed on the channel list
1256 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1257 if the band is 5G, then make sure channel list contains only 5G valid channels
1258*/
1259eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1260 eCsrBand eBand)
1261{
1262 eHalStatus status = eHAL_STATUS_SUCCESS;
1263 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1264 tANI_U8 outNumChannels = 0;
1265 tANI_U8 inNumChannels = 0;
1266 tANI_U8 *inPtr = NULL;
1267 tANI_U8 i = 0;
1268 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1269
1270 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1271
1272 {
1273 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1274 "No update required for channel list "
1275 "either cfg.ini channel list is not set up or "
1276 "auto band (Band %d)", eBand);
1277 return status;
1278 }
1279
1280 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1281 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1282 if (eCSR_BAND_24 == eBand)
1283 {
1284 for (i = 0; i < inNumChannels; i++)
1285 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001286 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001287 {
1288 ChannelList[outNumChannels++] = inPtr[i];
1289 }
1290 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001291 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001292 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001293 }
1294 else if (eCSR_BAND_5G == eBand)
1295 {
1296 for (i = 0; i < inNumChannels; i++)
1297 {
1298 /* Add 5G Non-DFS channel */
1299 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001300 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001301 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1302 {
1303 ChannelList[outNumChannels++] = inPtr[i];
1304 }
1305 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001306 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001307 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001308 }
1309 else if (eCSR_BAND_ALL == eBand)
1310 {
1311 for (i = 0; i < inNumChannels; i++)
1312 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001313 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001314 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1315 {
1316 ChannelList[outNumChannels++] = inPtr[i];
1317 }
1318 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001319 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001320 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001321 }
1322 else
1323 {
1324 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1325 "Invalid band, No operation carried out (Band %d)", eBand);
1326 status = eHAL_STATUS_INVALID_PARAMETER;
1327 }
1328
1329 return status;
1330}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001331#endif
1332
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001333#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001334/* This function modifies the roam scan channel list as per AP neighbor
1335 report; AP neighbor report may be empty or may include only other AP
1336 channels; in any case, we merge the channel list with the learned occupied
1337 channels list.
1338 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1339 if the band is 5G, then make sure channel list contains only 5G valid channels
1340*/
1341eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1342 tANI_U8 *pChannelList,
1343 tANI_U8 numChannels,
1344 const eCsrBand eBand)
1345{
1346 eHalStatus status = eHAL_STATUS_SUCCESS;
1347 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1348 tANI_U8 outNumChannels = 0;
1349 tANI_U8 inNumChannels = numChannels;
1350 tANI_U8 *inPtr = pChannelList;
1351 tANI_U8 i = 0;
1352 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1353 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1354 tANI_U8 mergedOutputNumOfChannels = 0;
1355 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1356
1357 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1358 * report Channels. This increases the chances of the DUT to get a candidate AP while
1359 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1360 if (pMac->scan.occupiedChannels.numChannels)
1361 {
1362 csrNeighborRoamMergeChannelLists(pMac,
1363 &pMac->scan.occupiedChannels.channelList[0],
1364 pMac->scan.occupiedChannels.numChannels,
1365 inPtr,
1366 inNumChannels,
1367 &mergedOutputNumOfChannels);
1368 inNumChannels = mergedOutputNumOfChannels;
1369 }
1370
1371 if (eCSR_BAND_24 == eBand)
1372 {
1373 for (i = 0; i < inNumChannels; i++)
1374 {
1375 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1376 {
1377 ChannelList[outNumChannels++] = inPtr[i];
1378 }
1379 }
1380 }
1381 else if (eCSR_BAND_5G == eBand)
1382 {
1383 for (i = 0; i < inNumChannels; i++)
1384 {
1385 /* Add 5G Non-DFS channel */
1386 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1387 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1388 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1389 {
1390 ChannelList[outNumChannels++] = inPtr[i];
1391 }
1392 }
1393 }
1394 else if (eCSR_BAND_ALL == eBand)
1395 {
1396 for (i = 0; i < inNumChannels; i++)
1397 {
1398 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1399 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1400 {
1401 ChannelList[outNumChannels++] = inPtr[i];
1402 }
1403 }
1404 }
1405 else
1406 {
1407 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1408 "Invalid band, No operation carried out (Band %d)", eBand);
1409 return eHAL_STATUS_INVALID_PARAMETER;
1410 }
1411
1412 /* if roaming within band is enabled, then select only the
1413 in band channels .
1414 This is required only if the band capability is set to ALL,
1415 E.g., if band capability is only 2.4G then all the channels in the
1416 list are already filtered for 2.4G channels, hence ignore this check*/
1417
1418 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1419 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301420 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001421 pMac,
1422 ChannelList,
1423 outNumChannels,
1424 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301425 &outNumChannels,
1426 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301427 vos_mem_copy(ChannelList,
1428 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001429 }
1430
1431 /* Prepare final roam scan channel list */
1432 if(outNumChannels)
1433 {
1434 /* Clear the channel list first */
1435 if (NULL != currChannelListInfo->ChannelList)
1436 {
1437 vos_mem_free(currChannelListInfo->ChannelList);
1438 currChannelListInfo->ChannelList = NULL;
1439 currChannelListInfo->numOfChannels = 0;
1440 }
1441
1442 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1443 if (NULL == currChannelListInfo->ChannelList)
1444 {
1445 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1446 "Failed to allocate memory for roam scan channel list");
1447 currChannelListInfo->numOfChannels = 0;
1448 return VOS_STATUS_E_RESOURCES;
1449 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301450 vos_mem_copy(currChannelListInfo->ChannelList,
1451 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001452 }
1453 return status;
1454}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001455#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001456
Jeff Johnson295189b2012-06-20 16:38:30 -07001457eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1458{
1459 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1460 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1462 (eBand == eCSR_BAND_24))
1463 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001464 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001465 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001466 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001467 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 pMac->roam.configParam.uCfgDot11Mode, eBand);
1469 return eHAL_STATUS_INVALID_PARAMETER;
1470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1472 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1473 (eBand == eCSR_BAND_5G))
1474 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001475 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001477 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001478 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001479 pMac->roam.configParam.uCfgDot11Mode, eBand);
1480 return eHAL_STATUS_INVALID_PARAMETER;
1481 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001482 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001483 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001484 pMac->roam.configParam.eBand = eBand;
1485 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001487#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001488 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1489 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001490#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 status = csrInitGetChannels( pMac );
1492 if (eHAL_STATUS_SUCCESS == status)
1493 csrInitChannelList( hHal );
1494 return status;
1495}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001496
1497
Jeff Johnsone7245742012-09-05 17:12:55 -07001498/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1499 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1500 * Ideally we should have kept the ini value and enum value same and representing the same
1501 * cb values as in 11n standard i.e.
1502 * Set to 1 (SCA) if the secondary channel is above the primary channel
1503 * Set to 3 (SCB) if the secondary channel is below the primary channel
1504 * Set to 0 (SCN) if no secondary channel is present
1505 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1506 * 0 - secondary none
1507 * 1 - secondary LOW
1508 * 2 - secondary HIGH
1509 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1510 * The enum values are as follows:
1511 * PHY_SINGLE_CHANNEL_CENTERED = 0
1512 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1513 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1514 */
1515ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1516{
1517
1518 ePhyChanBondState phyCbState;
1519 switch (cbIniValue) {
1520 // secondary none
1521 case 0:
1522 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1523 break;
1524 // secondary LOW
1525 case 1:
1526 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1527 break;
1528 // secondary HIGH
1529 case 2:
1530 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1531 break;
1532#ifdef WLAN_FEATURE_11AC
1533 case 3:
1534 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1535 break;
1536 case 4:
1537 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1538 break;
1539 case 5:
1540 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1541 break;
1542 case 6:
1543 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1544 break;
1545 case 7:
1546 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1547 break;
1548 case 8:
1549 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1550 break;
1551 case 9:
1552 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1553 break;
1554#endif
1555 default:
1556 // If an invalid value is passed, disable CHANNEL BONDING
1557 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1558 break;
1559 }
1560 return phyCbState;
1561}
1562
1563v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1564{
1565
1566 v_U32_t cbIniValue;
1567 switch (phyCbState) {
1568 // secondary none
1569 case PHY_SINGLE_CHANNEL_CENTERED:
1570 cbIniValue = 0;
1571 break;
1572 // secondary LOW
1573 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1574 cbIniValue = 1;
1575 break;
1576 // secondary HIGH
1577 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1578 cbIniValue = 2;
1579 break;
1580#ifdef WLAN_FEATURE_11AC
1581 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1582 cbIniValue = 3;
1583 break;
1584 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1585 cbIniValue = 4;
1586 break;
1587 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1588 cbIniValue = 5;
1589 break;
1590 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1591 cbIniValue = 6;
1592 break;
1593 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1594 cbIniValue = 7;
1595 break;
1596 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1597 cbIniValue = 8;
1598 break;
1599 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1600 cbIniValue = 9;
1601 break;
1602#endif
1603 default:
1604 // return some invalid value
1605 cbIniValue = 10;
1606 break;
1607 }
1608 return cbIniValue;
1609}
Jeff Johnson295189b2012-06-20 16:38:30 -07001610
1611eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1612{
1613 eHalStatus status = eHAL_STATUS_SUCCESS;
1614
1615 if(pParam)
1616 {
1617 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1618 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1619 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1620 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1621 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1622 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1623
1624 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001625 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1626
Jeff Johnsone7245742012-09-05 17:12:55 -07001627 /* channelBondingMode5GHz plays a dual role right now
1628 * 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
1629 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1630 */
1631 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1632 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001633 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001634 }
1635 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1636 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001638 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001639 }
1640 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001641 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1642 pMac->roam.configParam.phyMode = pParam->phyMode;
1643 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1644 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1645 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1646 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1647 pMac->roam.configParam.TxRate = pParam->TxRate;
1648 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1649 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1650 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1651 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1652 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001653 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001654 //if HDD passed down non zero values then only update,
1655 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301656 if (pParam->nInitialDwellTime)
1657 {
1658 pMac->roam.configParam.nInitialDwellTime =
1659 pParam->nInitialDwellTime;
1660 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001661 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 {
1663 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301664 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1665 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001667 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 {
1669 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301670 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1671 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001673 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 {
1675 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301676 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1677 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001679 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 {
1681 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301682 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1683 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001685 if (pParam->nActiveMaxChnTimeBtc)
1686 {
1687 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1688 }
1689 if (pParam->nActiveMinChnTimeBtc)
1690 {
1691 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1692 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001693#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001694 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001695 {
1696 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1697 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001698 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001699 {
1700 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1701 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001702 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001703 {
1704 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1705 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001706 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001707 {
1708 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1709 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001710 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001711 {
1712 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1713 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001714 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001715 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001716 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1717 }
1718 if (pParam->nNumP2PChanCombinedConc)
1719 {
1720 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001721 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001722#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001724 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001725 {
1726 //Change the unit from second to microsecond
1727 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1729 {
1730 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1731 }
1732 else
1733 {
1734 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1735 }
1736 }
1737 else
1738 {
1739 pMac->roam.configParam.impsSleepTime = 0;
1740 }
1741 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1743 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001744 //if HDD passed down non zero values for age params, then only update,
1745 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001746 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 {
1748 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 if(pParam->scanAgeTimeNCNPS)
1751 {
1752 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 if(pParam->scanAgeTimeNCPS)
1755 {
1756 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 if(pParam->scanAgeTimeCNPS)
1759 {
1760 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1761 }
1762 if(pParam->scanAgeTimeCPS)
1763 {
1764 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1765 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301766 if (pParam->initialScanSkipDFSCh)
1767 {
1768 pMac->roam.configParam.initialScanSkipDFSCh =
1769 pParam->initialScanSkipDFSCh;
1770 }
1771
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001772 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1774 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1775 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1776 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1777 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1779 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001780 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1781 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1782 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1783 //Assign this before calling CsrInit11dInfo
1784 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001785 if( csrIs11dSupported( pMac ) )
1786 {
1787 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1788 }
1789 else
1790 {
1791 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1792 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001793
1794 /* Initialize the power + channel information if 11h is enabled.
1795 If 11d is enabled this information has already been initialized */
1796 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1797 {
1798 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1799 }
1800
1801
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301802#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301803 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1804 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001805 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001806#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001807#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001808 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001809 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001810 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001811 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001812 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001813 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001814 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001815 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001816 pMac->roam.configParam.nProbes = pParam->nProbes;
1817 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001818#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001819#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1820 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001821 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001822#endif
1823#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001824 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001825 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001826#endif
1827
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001828#ifdef FEATURE_WLAN_ESE
1829 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001830#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001831#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301832 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1833 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001834 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1835 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1836 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1837 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1838 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1839 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1840 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1841 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05301842 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001843 {
1844 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001845 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 -07001846 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1847 {
1848 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 }
1851#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1853 pMac->scan.fValidateList = pParam->fValidateList;
1854 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1855 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001856 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001858 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
Peng Xu2446a892014-09-05 17:21:18 +05301859 pMac->scan.scanBandPreference = pParam->scanBandPreference;
Jeff Johnsone7245742012-09-05 17:12:55 -07001860 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1861 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1862 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1863 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1864 * single session
1865 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001866 //Remove this code once SLM_Sessionization is supported
1867 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001868 pMac->roam.configParam.doBMPSWorkaround = 0;
1869
Jeff Johnsone7245742012-09-05 17:12:55 -07001870#ifdef WLAN_FEATURE_11AC
1871 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001872 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001873 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001874 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301875 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1876 if ( pParam->enableTxBF )
1877 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
1878 else
1879 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001880#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001881 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001882
1883 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001884 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001885 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1886 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301887 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05301888 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 }
1890
1891 return status;
1892}
1893
Jeff Johnson295189b2012-06-20 16:38:30 -07001894eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1895{
1896 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001897 if(pParam)
1898 {
1899 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1900 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1901 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1902 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1903 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1904 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001905 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1906 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1908 pParam->phyMode = pMac->roam.configParam.phyMode;
1909 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1910 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1911 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1912 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1913 pParam->TxRate = pMac->roam.configParam.TxRate;
1914 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1915 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1916 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1917 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1918 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1920 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1921 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1922 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001923 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1924 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1925 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001926#ifdef WLAN_AP_STA_CONCURRENCY
1927 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1928 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1929 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1930 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1931 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001932 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1933 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001934#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001935 //Change the unit from microsecond to second
1936 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1937 pParam->eBand = pMac->roam.configParam.eBand;
1938 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1939 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1940 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1941 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1942 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1943 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1944 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1945 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1946 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1947 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1948 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1949 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1950 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1952 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1953 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1954 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001955 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1956 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1957 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1958 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1959 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001960 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001961 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001962 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001963 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Peng Xu2446a892014-09-05 17:21:18 +05301964 pParam->scanBandPreference = pMac->scan.scanBandPreference;
Jeff Johnson295189b2012-06-20 16:38:30 -07001965#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301966 vos_mem_copy(&pParam->neighborRoamConfig,
1967 &pMac->roam.configParam.neighborRoamConfig,
1968 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001969#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001970#ifdef WLAN_FEATURE_11AC
1971 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001972 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001973 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001974 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301975 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1976 if ( pParam->enableTxBF )
1977 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
1978 else
1979 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001980#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001981#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301982 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1983 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001984#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001985#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001986 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1987 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1988 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1989 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1990 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001991 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001992 pParam->nProbes = pMac->roam.configParam.nProbes;
1993 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001994#endif
1995#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1996 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1997 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1998#endif
1999#ifdef FEATURE_WLAN_LFR
2000 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
2001#endif
2002
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002003#ifdef FEATURE_WLAN_ESE
2004 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002005#endif
2006#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302007 vos_mem_copy(&pParam->neighborRoamConfig,
2008 &pMac->roam.configParam.neighborRoamConfig,
2009 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002010 {
2011 int i;
2012 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
2013 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2014 {
2015 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2016 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002017 }
2018#endif
2019
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07002020 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07002021
krunal soni5afa96c2013-09-06 22:19:02 -07002022 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002023 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07002024
krunal sonie9002db2013-11-25 14:24:17 -08002025 pParam->isCoalesingInIBSSAllowed =
2026 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302027 pParam->allowDFSChannelRoam =
2028 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302029 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 csrSetChannels(pMac, pParam);
2031
2032 status = eHAL_STATUS_SUCCESS;
2033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 return (status);
2035}
2036
Jeff Johnson295189b2012-06-20 16:38:30 -07002037eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
2038{
2039 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2040 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2041 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2042 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 do
2044 {
2045 if(eCSR_BAND_24 == eBand)
2046 {
2047 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2048 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2049 }
2050 if(eCSR_BAND_5G == eBand)
2051 {
2052 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2053 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2054 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2055 )
2056 {
2057 break;
2058 }
2059 }
2060 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2061 {
2062 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2063 }
2064 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2065 {
2066 newPhyMode = eCSR_DOT11_MODE_AUTO;
2067 }
2068 else
2069 {
2070 //Check for dual band and higher capability first
2071 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2072 {
2073 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2074 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2075 }
2076 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2077 {
2078 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2079 if(eCSR_BAND_24 == eBand) break;
2080 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2081 eBand = eCSR_BAND_5G;
2082 }
2083 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2084 {
2085 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2086 if(eCSR_BAND_5G == eBand) break;
2087 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2088 eBand = eCSR_BAND_24;
2089 }
2090 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2091 {
2092 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2093 if(eCSR_BAND_5G == eBand) break;
2094 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2095 eBand = eCSR_BAND_24;
2096 }
2097 else if(eCSR_DOT11_MODE_11n & phyMode)
2098 {
2099 newPhyMode = eCSR_DOT11_MODE_11n;
2100 }
2101 else if(eCSR_DOT11_MODE_abg & phyMode)
2102 {
2103 newPhyMode = eCSR_DOT11_MODE_abg;
2104 }
2105 else if(eCSR_DOT11_MODE_11a & phyMode)
2106 {
2107 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2108 {
2109 if(eCSR_BAND_ALL == eBand)
2110 {
2111 newPhyMode = eCSR_DOT11_MODE_abg;
2112 }
2113 else
2114 {
2115 //bad setting
2116 break;
2117 }
2118 }
2119 else
2120 {
2121 newPhyMode = eCSR_DOT11_MODE_11a;
2122 eBand = eCSR_BAND_5G;
2123 }
2124 }
2125 else if(eCSR_DOT11_MODE_11g & phyMode)
2126 {
2127 newPhyMode = eCSR_DOT11_MODE_11g;
2128 eBand = eCSR_BAND_24;
2129 }
2130 else if(eCSR_DOT11_MODE_11b & phyMode)
2131 {
2132 newPhyMode = eCSR_DOT11_MODE_11b;
2133 eBand = eCSR_BAND_24;
2134 }
2135 else
2136 {
2137 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002138 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 newPhyMode = eCSR_DOT11_MODE_AUTO;
2140 }
2141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 //Done validating
2143 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002144 //Now we need to check whether a restart is needed.
2145 if(eBand != pMac->roam.configParam.eBand)
2146 {
2147 fRestartNeeded = eANI_BOOLEAN_TRUE;
2148 break;
2149 }
2150 if(newPhyMode != pMac->roam.configParam.phyMode)
2151 {
2152 fRestartNeeded = eANI_BOOLEAN_TRUE;
2153 break;
2154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002155 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 if(HAL_STATUS_SUCCESS(status))
2157 {
2158 pMac->roam.configParam.eBand = eBand;
2159 pMac->roam.configParam.phyMode = newPhyMode;
2160 if(pfRestartNeeded)
2161 {
2162 *pfRestartNeeded = fRestartNeeded;
2163 }
2164 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 return (status);
2166}
2167
Jeff Johnson295189b2012-06-20 16:38:30 -07002168void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2169{
2170 tANI_U8 Index;
2171 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 // for dual band NICs, don't need to trim the channel list....
2173 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2174 {
2175 // 2.4 GHz band operation requires the channel list to be trimmed to
2176 // the 2.4 GHz channels only...
2177 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2178 {
2179 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2180 Index++ )
2181 {
2182 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2183 {
2184 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2185 cChannels++;
2186 }
2187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002188 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2189 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2190 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2191 // only if we need to.
2192 //
2193 // The amount of memory to clear is the number of channesl that we trimmed
2194 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2195
2196 if ( pChannelList->numChannels > cChannels )
2197 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302198 vos_mem_set(&pChannelList->channelList[ cChannels ],
2199 sizeof( pChannelList->channelList[ 0 ] ) *
2200 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 }
2202
2203 pChannelList->numChannels = cChannels;
2204 }
2205 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2206 {
2207 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2208 {
2209 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2210 {
2211 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2212 cChannels++;
2213 }
2214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2216 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2217 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2218 // only if we need to.
2219 //
2220 // The amount of memory to clear is the number of channesl that we trimmed
2221 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2222 if ( pChannelList->numChannels > cChannels )
2223 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302224 vos_mem_set(&pChannelList->channelList[ cChannels ],
2225 sizeof( pChannelList->channelList[ 0 ] ) *
2226 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 }
2228
2229 pChannelList->numChannels = cChannels;
2230 }
2231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002232}
Jeff Johnson295189b2012-06-20 16:38:30 -07002233#define INFRA_AP_DEFAULT_CHANNEL 6
2234eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2235{
2236 tANI_U8 index= 0;
2237 eHalStatus status = eHAL_STATUS_FAILURE;
2238 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2239 {
2240 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2241 status = eHAL_STATUS_SUCCESS;
2242 break;
2243 }
2244 }
2245 return status;
2246}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002247
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002248
Jeff Johnson295189b2012-06-20 16:38:30 -07002249eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2250{
2251 eHalStatus status = eHAL_STATUS_SUCCESS;
2252 tANI_U8 num20MHzChannelsFound = 0;
2253 VOS_STATUS vosStatus;
2254 tANI_U8 Index = 0;
2255 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002256
Jeff Johnson295189b2012-06-20 16:38:30 -07002257
2258 //TODO: this interface changed to include the 40MHz channel list
2259 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2260 // Read the scan channel list (including the power limit) from EEPROM
2261 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2262 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2263 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2264 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002265 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 status = eHAL_STATUS_FAILURE;
2267 }
2268 else
2269 {
2270 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2271 {
2272 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2273 }
2274 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2275 // Move the channel list to the global data
2276 // structure -- this will be used as the scan list
2277 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2278 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002279 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 }
2281 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2282 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2283 {
2284 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2285 }
2286 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2287 {
2288 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2289 }
2290 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 return (status);
2293}
Jeff Johnson295189b2012-06-20 16:38:30 -07002294eHalStatus csrInitChannelList( tHalHandle hHal )
2295{
2296 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2297 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2299 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002300 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2301 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002303 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302304 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 return (status);
2306}
Jeff Johnson295189b2012-06-20 16:38:30 -07002307eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2308 tCsrUpdateConfigParam *pUpdateConfigParam)
2309{
2310 eHalStatus status = eHAL_STATUS_FAILURE;
2311 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2313 status = CsrInit11dInfo(pMac, ps11dinfo);
2314 return status;
2315}
2316
Jeff Johnson295189b2012-06-20 16:38:30 -07002317static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2318{
2319 eHalStatus status = eHAL_STATUS_FAILURE;
2320 tANI_U8 index;
2321 tANI_U32 count=0;
2322 tSirMacChanInfo *pChanInfo;
2323 tSirMacChanInfo *pChanInfoStart;
2324 tANI_BOOLEAN applyConfig = TRUE;
2325
Mihir Shetebc866f62014-02-13 16:08:53 +05302326 pMac->scan.currentCountryRSSI = -128;
2327
Jeff Johnson295189b2012-06-20 16:38:30 -07002328 if(!ps11dinfo)
2329 {
2330 return (status);
2331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2333 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302334 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2335 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2336 ps11dinfo->Channels.channelList,
2337 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002338 }
2339 else
2340 {
2341 //No change
2342 return (eHAL_STATUS_SUCCESS);
2343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002344 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302345
2346 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2347 WNI_CFG_COUNTRY_CODE_LEN);
2348
2349
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 //Tush: at csropen get this initialized with default, during csr reset if this
2351 // already set with some value no need initilaize with default again
2352 if(0 == pMac->scan.countryCodeCurrent[0])
2353 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302354 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2355 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002356 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002357 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302358 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2359 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002360 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302361 vos_mem_set(pChanInfo,
2362 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2363 0);
2364
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002366 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2367 {
2368 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2369 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2370 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2371 pChanInfo++;
2372 count++;
2373 }
2374 if(count)
2375 {
2376 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2377 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302378 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002379 }
2380 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2381 if( HAL_STATUS_SUCCESS(status) )
2382 {
2383 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2384 {
2385 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2386 {
2387 applyConfig = FALSE;
2388 }
2389 }
2390
2391 if(TRUE == applyConfig)
2392 {
2393 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002394 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002395 }
2396
2397 }
2398 return (status);
2399}
2400/* Initialize the Channel + Power List in the local cache and in the CFG */
2401eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2402{
2403 tANI_U8 index;
2404 tANI_U32 count=0;
2405 tSirMacChanInfo *pChanInfo;
2406 tSirMacChanInfo *pChanInfoStart;
2407
2408 if(!ps11dinfo || !pMac)
2409 {
2410 return eHAL_STATUS_FAILURE;
2411 }
2412
Kiet Lam64c1b492013-07-12 13:56:44 +05302413 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2414 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002415 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302416 vos_mem_set(pChanInfo,
2417 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2418 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002419 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002420
2421 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2422 {
2423 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2424 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2425 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2426 pChanInfo++;
2427 count++;
2428 }
2429 if(count)
2430 {
2431 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2432 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302433 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 }
2435
Jeff Johnsone7245742012-09-05 17:12:55 -07002436 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002437}
2438
2439//pCommand may be NULL
2440//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2441void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2442{
2443 tListElem *pEntry, *pNextEntry;
2444 tSmeCmd *pDupCommand;
2445 tDblLinkList localList;
2446
2447 vos_mem_zero(&localList, sizeof(tDblLinkList));
2448 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2449 {
2450 smsLog(pMac, LOGE, FL(" failed to open list"));
2451 return;
2452 }
2453 csrLLLock( &pMac->sme.smeCmdPendingList );
2454 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2455 while( pEntry )
2456 {
2457 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2458 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 // Remove the previous command if..
2460 // - the new roam command is for the same RoamReason...
2461 // - the new roam command is a NewProfileList.
2462 // - the new roam command is a Forced Dissoc
2463 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2464 if (
2465 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2466 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002467 /* This peermac check is requried for Softap/GO scenarios
2468 * For STA scenario below OR check will suffice as pCommand will
2469 * always be NULL for STA scenarios
2470 */
2471 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002472 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2473 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2474 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2475 ||
2476 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002477 ( (sessionId == pDupCommand->sessionId) &&
2478 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002479 ((eCsrForcedDisassoc == eRoamReason) ||
2480 (eCsrHddIssued == eRoamReason))
2481 )
2482 )
2483 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002484 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002485 // Remove the 'stale' roam command from the pending list...
2486 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2487 {
2488 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2489 }
2490 }
2491 pEntry = pNextEntry;
2492 }
2493 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2494
2495 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2496 {
2497 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2498 //Tell caller that the command is cancelled
2499 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2500 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2501 csrReleaseCommandRoam(pMac, pDupCommand);
2502 }
2503 csrLLClose(&localList);
2504}
Jeff Johnson295189b2012-06-20 16:38:30 -07002505eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2506 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2507{
2508 eHalStatus status = eHAL_STATUS_SUCCESS;
2509#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2510 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2511#endif
2512 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2514 {
2515 pSession = CSR_GET_SESSION( pMac, sessionId );
2516 }
2517 else
2518 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002519 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 VOS_ASSERT(0);
2521 return eHAL_STATUS_FAILURE;
2522 }
krunal soni587bf012014-02-04 12:35:11 -08002523
2524 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2525 {
2526 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2527 return eHAL_STATUS_FAILURE;
2528 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002529
krunal soni587bf012014-02-04 12:35:11 -08002530 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2531
krunal soni7f7d2c92014-02-06 15:08:43 -08002532 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002533 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002534 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002536 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2537 /*
2538 * Decrement bRefAssocStartCnt for FT reassoc failure.
2539 * Reason: For FT reassoc failures, we first call
2540 * csrRoamCallCallback before notifying a failed roam
2541 * completion through csrRoamComplete. The latter in
2542 * turn calls csrRoamProcessResults which tries to
2543 * once again call csrRoamCallCallback if bRefAssocStartCnt
2544 * is non-zero. Since this is redundant for FT reassoc
2545 * failure, decrement bRefAssocStartCnt.
2546 */
2547 pSession->bRefAssocStartCnt--;
2548 }
2549
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 if(NULL != pSession->callback)
2551 {
2552 if( pRoamInfo )
2553 {
2554 pRoamInfo->sessionId = (tANI_U8)sessionId;
2555 }
2556
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302557 /* avoid holding the global lock when making the roaming callback, original change came
2558 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2559 is possible on other OS ports where the callback may need to take locks to protect
2560 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2562 that may actually depend on the lock being held */
2563 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2564 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2565 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2566 }
2567 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2568 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2569#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302570 vos_mem_set(&connectionStatus,
2571 sizeof(vos_event_wlan_status_payload_type), 0);
2572
krunal soni7f7d2c92014-02-06 15:08:43 -08002573 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 {
2575 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2576 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2577 if(NULL != pRoamInfo->pBssDesc)
2578 {
2579 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2580 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002582 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2583 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2584 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302585 vos_mem_copy(connectionStatus.ssid,
2586 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2587
Jeff Johnson295189b2012-06-20 16:38:30 -07002588 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2589 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2592 {
2593 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2594 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2595 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 if(eCSR_ROAM_RESULT_FORCED == u2)
2598 {
2599 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2600 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2601 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2602 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2604 {
2605 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2606 connectionStatus.reason = eCSR_REASON_DISASSOC;
2607 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2610 {
2611 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2612 connectionStatus.reason = eCSR_REASON_DEAUTH;
2613 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2614 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002615#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2616
2617 return (status);
2618}
Jeff Johnson295189b2012-06-20 16:38:30 -07002619// Returns whether handoff is currently in progress or not
2620tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2621{
2622#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2623 return csrNeighborRoamIsHandoffInProgress(pMac);
2624#else
2625 return eANI_BOOLEAN_FALSE;
2626#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002627}
Jeff Johnson295189b2012-06-20 16:38:30 -07002628eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2629 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2630{
2631 eHalStatus status = eHAL_STATUS_SUCCESS;
2632 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2633 tANI_U16 reasonCode;
2634 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002635
2636 if(!pSession)
2637 {
2638 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2639 return eHAL_STATUS_FAILURE;
2640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002641
2642 //Restore AC weight in case we change it
2643 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2644 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002645 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 -07002646 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2647 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2648 }
2649
2650 if ( fMICFailure )
2651 {
2652 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2653 }
2654 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2655 {
2656 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002657 }
2658 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 {
2660 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002662#ifdef WLAN_FEATURE_VOWIFI_11R
2663 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2664 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2665 {
2666 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302667 vos_mem_copy(&bssId,
2668 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2669 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002670 }
2671 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002672#endif
2673 if(pSession->pConnectBssDesc)
2674 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302675 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002676 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002677
Jeff Johnson295189b2012-06-20 16:38:30 -07002678
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302679 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2680 " subState = %s reason=%d"),
2681 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2682 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002683
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2685
2686 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2687
2688 if(HAL_STATUS_SUCCESS(status))
2689 {
2690 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002691#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2692 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2693 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2694 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002695 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2697 }
2698#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002699 }
2700 else
2701 {
2702 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2703 }
2704
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 return (status);
2706}
Jeff Johnson295189b2012-06-20 16:38:30 -07002707
Jeff Johnson295189b2012-06-20 16:38:30 -07002708/* ---------------------------------------------------------------------------
2709 \fn csrRoamIssueDisassociateStaCmd
2710 \brief csr function that HDD calls to disassociate a associated station
2711 \param sessionId - session Id for Soft AP
2712 \param pPeerMacAddr - MAC of associated station to delete
2713 \param reason - reason code, be one of the tSirMacReasonCodes
2714 \return eHalStatus
2715 ---------------------------------------------------------------------------*/
2716eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2717 tANI_U32 sessionId,
2718 tANI_U8 *pPeerMacAddr,
2719 tANI_U32 reason)
2720{
2721 eHalStatus status = eHAL_STATUS_SUCCESS;
2722 tSmeCmd *pCommand;
2723
2724 do
2725 {
2726 pCommand = csrGetCommandBuffer( pMac );
2727 if ( !pCommand )
2728 {
2729 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2730 status = eHAL_STATUS_RESOURCES;
2731 break;
2732 }
2733 pCommand->command = eSmeCommandRoam;
2734 pCommand->sessionId = (tANI_U8)sessionId;
2735 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2736 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2737 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2738 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2739 if( !HAL_STATUS_SUCCESS( status ) )
2740 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002741 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 csrReleaseCommandRoam( pMac, pCommand );
2743 }
2744 }while(0);
2745
2746 return status;
2747}
2748
2749
Jeff Johnson295189b2012-06-20 16:38:30 -07002750/* ---------------------------------------------------------------------------
2751 \fn csrRoamIssueDeauthSta
2752 \brief csr function that HDD calls to delete a associated station
2753 \param sessionId - session Id for Soft AP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302754 \param pDelStaParams- Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 \return eHalStatus
2756 ---------------------------------------------------------------------------*/
2757eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302758 tANI_U32 sessionId,
2759 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002760{
2761 eHalStatus status = eHAL_STATUS_SUCCESS;
2762 tSmeCmd *pCommand;
2763
2764 do
2765 {
2766 pCommand = csrGetCommandBuffer( pMac );
2767 if ( !pCommand )
2768 {
2769 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2770 status = eHAL_STATUS_RESOURCES;
2771 break;
2772 }
2773 pCommand->command = eSmeCommandRoam;
2774 pCommand->sessionId = (tANI_U8)sessionId;
2775 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302776 vos_mem_copy(pCommand->u.roamCmd.peerMac, pDelStaParams->peerMacAddr,
2777 sizeof(tSirMacAddr));
2778 pCommand->u.roamCmd.reason =
2779 (tSirMacReasonCodes)pDelStaParams->reason_code;
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2781 if( !HAL_STATUS_SUCCESS( status ) )
2782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002783 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 csrReleaseCommandRoam( pMac, pCommand );
2785 }
2786 }while(0);
2787
2788 return status;
2789}
Jeff Johnson295189b2012-06-20 16:38:30 -07002790eHalStatus
2791csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2792 tANI_BOOLEAN bEnable )
2793{
2794 eHalStatus status = eHAL_STATUS_FAILURE;
2795 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2796 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 if (!pSession)
2798 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002799 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 return (status);
2801 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002802 if (pSession->pConnectBssDesc)
2803 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302804 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 }
2806 else
2807 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002808 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 return (status);
2810 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002811 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2812 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002813 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2814 return (status);
2815}
Jeff Johnson295189b2012-06-20 16:38:30 -07002816eHalStatus
2817csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2818 VOS_MODULE_ID modId, void *pUsrContext,
2819 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2820{
2821 eHalStatus status = eHAL_STATUS_SUCCESS;
2822 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2823 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 if (!pSession)
2825 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002826 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 return (status);
2828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002829 if(pSession->pConnectBssDesc)
2830 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302831 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 }
2833 else
2834 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002835 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 return (status);
2837 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002838 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2839 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2841 return (status);
2842}
Jeff Johnson295189b2012-06-20 16:38:30 -07002843eHalStatus
2844csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2845 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2846{
2847 eHalStatus status = eHAL_STATUS_SUCCESS;
2848 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2849 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2850
2851 if (!pSession)
2852 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002853 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 return (status);
2855 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 if(pSession->pConnectBssDesc)
2857 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302858 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 }
2860 else
2861 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002862 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 return (status);
2864 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002865 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2866 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002867
2868 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2869
2870 return (status);
2871}
Jeff Johnson295189b2012-06-20 16:38:30 -07002872eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2873{
2874 eHalStatus status = eHAL_STATUS_SUCCESS;
2875 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2876 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002877
2878 if (!pSession)
2879 {
2880 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2881 return eHAL_STATUS_FAILURE;
2882 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002883
2884 if(pSession->pConnectBssDesc)
2885 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302886 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002888 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2889 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002890 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2891
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302892 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05302893 if(HAL_STATUS_SUCCESS(status))
2894 {
2895 csrRoamLinkDown(pMac, sessionId);
2896 }
2897 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002898 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302899 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2900 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002901 }
2902
Jeff Johnson295189b2012-06-20 16:38:30 -07002903 return (status);
2904}
2905
Jeff Johnson295189b2012-06-20 16:38:30 -07002906eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2907{
2908 eHalStatus status = eHAL_STATUS_SUCCESS;
2909 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2910 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002911
2912 if(!pSession)
2913 {
2914 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2915 return eHAL_STATUS_FAILURE;
2916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002917
2918 // If no BSS description was found in this connection (happens with start IBSS), then
2919 // nix the BSS description that we keep around for the connected BSS) and get out...
2920 if(NULL == pBssDesc)
2921 {
2922 csrFreeConnectBssDesc(pMac, sessionId);
2923 }
2924 else
2925 {
2926 size = pBssDesc->length + sizeof( pBssDesc->length );
2927 if(NULL != pSession->pConnectBssDesc)
2928 {
2929 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2930 {
2931 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2932 csrFreeConnectBssDesc(pMac, sessionId);
2933 }
2934 }
2935 if(NULL == pSession->pConnectBssDesc)
2936 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302937 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002938 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302939 if (NULL == pSession->pConnectBssDesc)
2940 status = eHAL_STATUS_FAILURE;
2941 else
2942 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 return (status);
2945}
2946
Jeff Johnson295189b2012-06-20 16:38:30 -07002947eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2948 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2949 tDot11fBeaconIEs *pIes)
2950{
2951 eHalStatus status = eHAL_STATUS_SUCCESS;
2952 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002953 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302954 if (pIes == NULL)
2955 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002956
Jeff Johnson295189b2012-06-20 16:38:30 -07002957 do
2958 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302959 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2960 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002961 //get qos
2962 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2963 //get SSID
2964 if(pIes->SSID.present)
2965 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302966 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2968 }
2969 else
2970 pBssConfig->SSID.length = 0;
2971 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2972 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002973 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 //Return failed if profile doesn't have an SSID either.
2975 if(pProfile->SSIDs.numOfSSIDs == 0)
2976 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002977 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002978 status = eHAL_STATUS_FAILURE;
2979 break;
2980 }
2981 }
2982 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2983 {
2984 pBssConfig->eBand = eCSR_BAND_5G;
2985 }
2986 else
2987 {
2988 pBssConfig->eBand = eCSR_BAND_24;
2989 }
2990 //phymode
2991 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2992 {
2993 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2994 }
2995 else
2996 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002997 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 //force it
2999 if(eCSR_BAND_24 == pBssConfig->eBand)
3000 {
3001 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3002 }
3003 else
3004 {
3005 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3006 }
3007 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 //Qos
3009 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3010 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
3011 {
3012 //Joining BSS is not 11n capable and WMM is disabled on client.
3013 //Disable QoS and WMM
3014 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3015 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303016
3017 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05303018 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303019 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
3020 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
3021 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
3022 {
3023 //Joining BSS is 11n capable and WMM is disabled on AP.
3024 //Assume all HT AP's are QOS AP's and enable WMM
3025 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3026 }
3027
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 //auth type
3029 switch( pProfile->negotiatedAuthType )
3030 {
3031 default:
3032 case eCSR_AUTH_TYPE_WPA:
3033 case eCSR_AUTH_TYPE_WPA_PSK:
3034 case eCSR_AUTH_TYPE_WPA_NONE:
3035 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3036 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3037 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 case eCSR_AUTH_TYPE_SHARED_KEY:
3039 pBssConfig->authType = eSIR_SHARED_KEY;
3040 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 case eCSR_AUTH_TYPE_AUTOSWITCH:
3042 pBssConfig->authType = eSIR_AUTO_SWITCH;
3043 break;
3044 }
3045 //short slot time
3046 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3047 {
3048 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3049 }
3050 else
3051 {
3052 pBssConfig->uShortSlotTime = 0;
3053 }
3054 if(pBssConfig->BssCap.ibss)
3055 {
3056 //We don't support 11h on IBSS
3057 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3058 }
3059 else
3060 {
3061 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3062 }
3063 //power constraint
3064 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3065 //heartbeat
3066 if ( CSR_IS_11A_BSS( pBssDesc ) )
3067 {
3068 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3069 }
3070 else
3071 {
3072 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3073 }
3074 //Join timeout
3075 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07003076 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 if ( pBssDesc->beaconInterval )
3078 {
3079 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07003080 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 }
3082 else
3083 {
3084 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3085 }
3086 //validate CB
3087 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sandeep Puligilla60342762014-01-30 21:05:37 +05303088
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 return (status);
3091}
3092
Jeff Johnson295189b2012-06-20 16:38:30 -07003093static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3094 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3095{
3096 eHalStatus status = eHAL_STATUS_SUCCESS;
3097 tANI_U8 operationChannel = 0;
3098 tANI_U8 qAPisEnabled = FALSE;
3099 //SSID
3100 pBssConfig->SSID.length = 0;
3101 if(pProfile->SSIDs.numOfSSIDs)
3102 {
3103 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303104 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3105 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 }
3107 else
3108 {
3109 //SSID must present
3110 return eHAL_STATUS_FAILURE;
3111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 //Settomg up the capabilities
3113 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3114 {
3115 pBssConfig->BssCap.ibss = 1;
3116 }
3117 else
3118 {
3119 pBssConfig->BssCap.ess = 1;
3120 }
3121 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3122 {
3123 pBssConfig->BssCap.privacy = 1;
3124 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003125 pBssConfig->eBand = pMac->roam.configParam.eBand;
3126 //phymode
3127 if(pProfile->ChannelInfo.ChannelList)
3128 {
3129 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3132 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 //QOS
3134 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 if ( pBssConfig->BssCap.ess == 1 )
3136 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 /*For Softap case enable WMM*/
3138 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3139 qAPisEnabled = TRUE;
3140 }
3141 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3143 qAPisEnabled = TRUE;
3144 } else {
3145 qAPisEnabled = FALSE;
3146 }
3147 } else {
3148 qAPisEnabled = TRUE;
3149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003150 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3151 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3152 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3153 )
3154 {
3155 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3156 } else {
3157 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3158 }
3159
3160 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003161 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 {
3163 default:
3164 case eCSR_AUTH_TYPE_WPA:
3165 case eCSR_AUTH_TYPE_WPA_PSK:
3166 case eCSR_AUTH_TYPE_WPA_NONE:
3167 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3168 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3169 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003170 case eCSR_AUTH_TYPE_SHARED_KEY:
3171 pBssConfig->authType = eSIR_SHARED_KEY;
3172 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003173 case eCSR_AUTH_TYPE_AUTOSWITCH:
3174 pBssConfig->authType = eSIR_AUTO_SWITCH;
3175 break;
3176 }
3177 //short slot time
3178 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3179 {
3180 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3181 }
3182 else
3183 {
3184 pBssConfig->uShortSlotTime = 0;
3185 }
3186 //power constraint. We don't support 11h on IBSS
3187 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3188 pBssConfig->uPowerLimit = 0;
3189 //heartbeat
3190 if ( eCSR_BAND_5G == pBssConfig->eBand )
3191 {
3192 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3193 }
3194 else
3195 {
3196 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3197 }
3198 //Join timeout
3199 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003200
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 return (status);
3202}
Jeff Johnson295189b2012-06-20 16:38:30 -07003203static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3204{
3205 eHalStatus status = eHAL_STATUS_FAILURE;
3206 tDot11fBeaconIEs *pIes = NULL;
3207
3208 do
3209 {
3210 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3211 {
3212 //err msg
3213 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003214 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 break;
3216 }
3217 //check if the AP is QAP & it supports APSD
3218 if( CSR_IS_QOS_BSS(pIes) )
3219 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303220 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 }
3222 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303223
3224 if (NULL != pIes)
3225 {
3226 vos_mem_free(pIes);
3227 }
3228
Jeff Johnson295189b2012-06-20 16:38:30 -07003229 return status;
3230}
3231
Jeff Johnson295189b2012-06-20 16:38:30 -07003232void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3233{
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3235 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3236 // See !!Note: below in this function...
3237 tANI_U32 PrivacyEnabled = 0;
3238 tANI_U32 RsnEnabled = 0;
3239 tANI_U32 WepDefaultKeyId = 0;
3240 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3241 tANI_U32 Key0Length = 0;
3242 tANI_U32 Key1Length = 0;
3243 tANI_U32 Key2Length = 0;
3244 tANI_U32 Key3Length = 0;
3245
3246 // Reserve for the biggest key
3247 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3248 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3249 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3250 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3251
3252 switch ( pProfile->negotiatedUCEncryptionType )
3253 {
3254 case eCSR_ENCRYPT_TYPE_NONE:
3255
3256 // for NO encryption, turn off Privacy and Rsn.
3257 PrivacyEnabled = 0;
3258 RsnEnabled = 0;
3259
3260 // WEP key length and Wep Default Key ID don't matter in this case....
3261
3262 // clear out the WEP keys that may be hanging around.
3263 Key0Length = 0;
3264 Key1Length = 0;
3265 Key2Length = 0;
3266 Key3Length = 0;
3267
3268 break;
3269
3270 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303271 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003272
3273 // Privacy is ON. NO RSN for Wep40 static key.
3274 PrivacyEnabled = 1;
3275 RsnEnabled = 0;
3276
3277 // Set the Wep default key ID.
3278 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 // Wep key size if 5 bytes (40 bits).
3280 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3281
3282 // set encryption keys in the CFG database or clear those that are not present in this profile.
3283 if ( pProfile->Keys.KeyLength[0] )
3284 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303285 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3286 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3288 }
3289 else
3290 {
3291 Key0Length = 0;
3292 }
3293
3294 if ( pProfile->Keys.KeyLength[1] )
3295 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303296 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3297 WNI_CFG_WEP_KEY_LENGTH_5);
3298 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 }
3300 else
3301 {
3302 Key1Length = 0;
3303 }
3304
3305 if ( pProfile->Keys.KeyLength[2] )
3306 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303307 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3308 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3310 }
3311 else
3312 {
3313 Key2Length = 0;
3314 }
3315
3316 if ( pProfile->Keys.KeyLength[3] )
3317 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303318 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3319 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003320 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3321 }
3322 else
3323 {
3324 Key3Length = 0;
3325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 break;
3327
3328 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303329 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003330
3331 // Privacy is ON. NO RSN for Wep40 static key.
3332 PrivacyEnabled = 1;
3333 RsnEnabled = 0;
3334
3335 // Set the Wep default key ID.
3336 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3337
3338 // Wep key size if 13 bytes (104 bits).
3339 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3340
3341 // set encryption keys in the CFG database or clear those that are not present in this profile.
3342 if ( pProfile->Keys.KeyLength[0] )
3343 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303344 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3345 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3347 }
3348 else
3349 {
3350 Key0Length = 0;
3351 }
3352
3353 if ( pProfile->Keys.KeyLength[1] )
3354 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303355 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3356 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3358 }
3359 else
3360 {
3361 Key1Length = 0;
3362 }
3363
3364 if ( pProfile->Keys.KeyLength[2] )
3365 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303366 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3367 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3369 }
3370 else
3371 {
3372 Key2Length = 0;
3373 }
3374
3375 if ( pProfile->Keys.KeyLength[3] )
3376 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303377 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3378 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3380 }
3381 else
3382 {
3383 Key3Length = 0;
3384 }
3385
3386 break;
3387
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 case eCSR_ENCRYPT_TYPE_TKIP:
3389 case eCSR_ENCRYPT_TYPE_AES:
3390#ifdef FEATURE_WLAN_WAPI
3391 case eCSR_ENCRYPT_TYPE_WPI:
3392#endif /* FEATURE_WLAN_WAPI */
3393 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3394 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3395 PrivacyEnabled = (0 != fPrivacy);
3396
3397 // turn on RSN enabled for WPA associations
3398 RsnEnabled = 1;
3399
3400 // WEP key length and Wep Default Key ID don't matter in this case....
3401
3402 // clear out the static WEP keys that may be hanging around.
3403 Key0Length = 0;
3404 Key1Length = 0;
3405 Key2Length = 0;
3406 Key3Length = 0;
3407
3408 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003409 default:
3410 PrivacyEnabled = 0;
3411 RsnEnabled = 0;
3412 break;
3413 }
3414
3415 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3416 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3417 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3418 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3419 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3420 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3421 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3422 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3423}
3424
Jeff Johnson295189b2012-06-20 16:38:30 -07003425static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3426{
3427 tANI_U32 len = 0;
3428 if(pSSID->length <= WNI_CFG_SSID_LEN)
3429 {
3430 len = pSSID->length;
3431 }
3432 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3433}
3434
Jeff Johnson295189b2012-06-20 16:38:30 -07003435eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3436{
3437 eHalStatus status = eHAL_STATUS_SUCCESS;
3438 tANI_U32 QoSEnabled;
3439 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 // set the CFG enable/disable variables based on the qosType being configured...
3441 switch( qosType )
3442 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3444 QoSEnabled = FALSE;
3445 WmeEnabled = TRUE;
3446 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3448 QoSEnabled = FALSE;
3449 WmeEnabled = TRUE;
3450 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3452 QoSEnabled = FALSE;
3453 WmeEnabled = TRUE;
3454 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3456 QoSEnabled = TRUE;
3457 WmeEnabled = FALSE;
3458 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 case eCSR_MEDIUM_ACCESS_11e_HCF:
3460 QoSEnabled = TRUE;
3461 WmeEnabled = FALSE;
3462 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003463 default:
3464 case eCSR_MEDIUM_ACCESS_DCF:
3465 QoSEnabled = FALSE;
3466 WmeEnabled = FALSE;
3467 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 }
3469 //save the WMM setting for later use
3470 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303471 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 return (status);
3473}
Jeff Johnson295189b2012-06-20 16:38:30 -07003474static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3475 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3476{
3477 eHalStatus status = eHAL_STATUS_FAILURE;
3478 int i;
3479 eCsrCfgDot11Mode cfgDot11Mode;
3480 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303481 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3482 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003484
3485 if( NULL != pIes )
3486 {
3487 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003488 // Originally, we thought that for 11a networks, the 11a rates are always
3489 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3490 // appear in the Operational Rate set. Consequently, in either case, we
3491 // would blindly put the rates we support into our Operational Rate set
3492 // (including the basic rates, which we have already verified are
3493 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003494 // However, it turns out that this is not always the case. Some AP's
3495 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3496 // too. Now, we're a little more careful:
3497 pDstRate = pOpRateSet->rate;
3498 if(pIes->SuppRates.present)
3499 {
3500 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3501 {
3502 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3503 {
3504 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003505 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 }
3507 }
3508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3510 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3511 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3512 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3513 {
3514 // If there are Extended Rates in the beacon, we will reflect those
3515 // extended rates that we support in out Extended Operational Rate
3516 // set:
3517 pDstRate = pExRateSet->rate;
3518 if(pIes->ExtSuppRates.present)
3519 {
3520 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3521 {
3522 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3523 {
3524 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3525 pExRateSet->numRates++;
3526 }
3527 }
3528 }
3529 }
3530 }//Parsing BSSDesc
3531 else
3532 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003533 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 }
3535 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3536 return status;
3537}
3538
3539static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3540 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3541{
3542 int i;
3543 tANI_U8 *pDstRate;
3544 eCsrCfgDot11Mode cfgDot11Mode;
3545 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3546 tANI_U32 OperationalRatesLength = 0;
3547 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3548 tANI_U32 ExtendedOperationalRatesLength = 0;
3549 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3550 tANI_U32 ProprietaryOperationalRatesLength = 0;
3551 tANI_U32 PropRatesEnable = 0;
3552 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3553 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003555 if( NULL != pIes )
3556 {
3557 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 // Originally, we thought that for 11a networks, the 11a rates are always
3559 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3560 // appear in the Operational Rate set. Consequently, in either case, we
3561 // would blindly put the rates we support into our Operational Rate set
3562 // (including the basic rates, which we have already verified are
3563 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003564 // However, it turns out that this is not always the case. Some AP's
3565 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3566 // too. Now, we're a little more careful:
3567 pDstRate = OperationalRates;
3568 if(pIes->SuppRates.present)
3569 {
3570 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3571 {
3572 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3573 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3574 {
3575 *pDstRate++ = pIes->SuppRates.rates[ i ];
3576 OperationalRatesLength++;
3577 }
3578 }
3579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3581 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3582 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3583 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3584 {
3585 // If there are Extended Rates in the beacon, we will reflect those
3586 // extended rates that we support in out Extended Operational Rate
3587 // set:
3588 pDstRate = ExtendedOperationalRates;
3589 if(pIes->ExtSuppRates.present)
3590 {
3591 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3592 {
3593 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3594 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3595 {
3596 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3597 ExtendedOperationalRatesLength++;
3598 }
3599 }
3600 }
3601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003602 // Enable proprietary MAC features if peer node is Airgo node and STA
3603 // user wants to use them
3604 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3605 {
3606 PropRatesEnable = 1;
3607 }
3608 else
3609 {
3610 PropRatesEnable = 0;
3611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 // For ANI network companions, we need to populate the proprietary rate
3613 // set with any proprietary rates we found in the beacon, only if user
3614 // allows them...
3615 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3616 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3617 {
3618 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3619 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3620 {
3621 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3622 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303623 vos_mem_copy(ProprietaryOperationalRates,
3624 pIes->Airgo.PropSuppRates.rates,
3625 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 }
3627 else {
3628 // No proprietary modes...
3629 ProprietaryOperationalRatesLength = 0;
3630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 /* Get MCS Rate */
3632 pDstRate = MCSRateIdxSet;
3633 if ( pIes->HTCaps.present )
3634 {
3635 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3636 {
3637 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3638 {
3639 MCSRateLength++;
3640 *pDstRate++ = i;
3641 }
3642 }
3643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 // Set the operational rate set CFG variables...
3645 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3646 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3647 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3648 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3649 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3650 ProprietaryOperationalRates,
3651 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3652 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3653 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3654 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3655 }//Parsing BSSDesc
3656 else
3657 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003658 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 }
3660}
3661
Jeff Johnson295189b2012-06-20 16:38:30 -07003662static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3663 tCsrRoamProfile *pProfile )
3664{
3665 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3666 { 8,
3667 { SIR_MAC_RATE_6,
3668 SIR_MAC_RATE_9,
3669 SIR_MAC_RATE_12,
3670 SIR_MAC_RATE_18,
3671 SIR_MAC_RATE_24,
3672 SIR_MAC_RATE_36,
3673 SIR_MAC_RATE_48,
3674 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3676 { 4,
3677 { SIR_MAC_RATE_1,
3678 SIR_MAC_RATE_2,
3679 SIR_MAC_RATE_5_5,
3680 SIR_MAC_RATE_11 } } };
3681
3682
3683 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3684 { SIR_MAC_RATE_72,
3685 SIR_MAC_RATE_96,
3686 SIR_MAC_RATE_108 } };
3687 eCsrCfgDot11Mode cfgDot11Mode;
3688 eCsrBand eBand;
3689 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3690 tANI_U32 OperationalRatesLength = 0;
3691 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3692 tANI_U32 ExtendedOperationalRatesLength = 0;
3693 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3694 tANI_U32 ProprietaryOperationalRatesLength = 0;
3695 tANI_U32 PropRatesEnable = 0;
3696 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003697 if(pProfile->ChannelInfo.ChannelList)
3698 {
3699 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3703 // networks, the 11b rates appear in the Operational Rate set. In either case,
3704 // we can blindly put the rates we support into our Operational Rate set
3705 // (including the basic rates, which we have already verified are supported
3706 // earlier in the roaming decision).
3707 if ( eCSR_BAND_5G == eBand )
3708 {
3709 // 11a rates into the Operational Rate Set.
3710 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3711 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303712 vos_mem_copy(OperationalRates,
3713 DefaultSupportedRates11a.supportedRateSet.rate,
3714 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003715
3716 // Nothing in the Extended rate set.
3717 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 // populate proprietary rates if user allows them
3719 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3720 {
3721 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3722 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303723 vos_mem_copy(ProprietaryOperationalRates,
3724 DefaultSupportedPropRates.propRate,
3725 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 }
3727 else
3728 {
3729 // No proprietary modes
3730 ProprietaryOperationalRatesLength = 0;
3731 }
3732 }
3733 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3734 {
3735 // 11b rates into the Operational Rate Set.
3736 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3737 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303738 vos_mem_copy(OperationalRates,
3739 DefaultSupportedRates11b.supportedRateSet.rate,
3740 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 // Nothing in the Extended rate set.
3742 ExtendedOperationalRatesLength = 0;
3743 // No proprietary modes
3744 ProprietaryOperationalRatesLength = 0;
3745 }
3746 else
3747 {
3748 // 11G
3749
3750 // 11b rates into the Operational Rate Set.
3751 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3752 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303753 vos_mem_copy(OperationalRates,
3754 DefaultSupportedRates11b.supportedRateSet.rate,
3755 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003756
3757 // 11a rates go in the Extended rate set.
3758 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3759 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303760 vos_mem_copy(ExtendedOperationalRates,
3761 DefaultSupportedRates11a.supportedRateSet.rate,
3762 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003763
3764 // populate proprietary rates if user allows them
3765 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3766 {
3767 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3768 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303769 vos_mem_copy(ProprietaryOperationalRates,
3770 DefaultSupportedPropRates.propRate,
3771 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 }
3773 else
3774 {
3775 // No proprietary modes
3776 ProprietaryOperationalRatesLength = 0;
3777 }
3778 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3780 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3781 {
3782 PropRatesEnable = 1;
3783 }
3784 else
3785 {
3786 PropRatesEnable = 0;
3787 }
3788
3789 // Set the operational rate set CFG variables...
3790 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3791 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3792 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3793 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3794 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3795 ProprietaryOperationalRates,
3796 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3797 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003798}
Jeff Johnson295189b2012-06-20 16:38:30 -07003799void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3800{
3801 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003802
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3804 tANI_U32 sessionId;
3805 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 if(NULL == pEntry)
3807 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003808 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 return;
3810 }
3811 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3812 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05303813 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
3814 " current state : %d sub state : %d "),
3815 result, pMac->roam.curState[sessionId],
3816 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003817 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3818 {
3819 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3820 }
3821}
3822
Jeff Johnson295189b2012-06-20 16:38:30 -07003823//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3824tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3825{
3826 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3827 {
3828 return (WNI_CFG_PHY_MODE_11B);
3829 }
3830 else
3831 {
3832 if(eCSR_BAND_24 == band)
3833 return (WNI_CFG_PHY_MODE_11G);
3834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 return (WNI_CFG_PHY_MODE_11A);
3836}
Jeff Johnson295189b2012-06-20 16:38:30 -07003837
Jeff Johnsone7245742012-09-05 17:12:55 -07003838
3839#ifdef WLAN_FEATURE_11AC
3840ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3841{
3842 switch ( aniCBMode )
3843 {
3844 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3845 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3846 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3847 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3848 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3849 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3850 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3851 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3852 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003853 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003854 return PHY_SINGLE_CHANNEL_CENTERED;
3855 }
3856}
3857#endif
3858
Jeff Johnson295189b2012-06-20 16:38:30 -07003859//pIes may be NULL
3860eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3861 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303862 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003863{
3864 eHalStatus status = eHAL_STATUS_SUCCESS;
3865 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3866 tANI_U8 channel = 0;
3867 //Make sure we have the domain info for the BSS we try to connect to.
3868 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303869 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003870 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05303871 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003872 {
3873 //Make sure the 11d info from this BSSDesc can be applied
3874 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303875 if (VOS_TRUE == resetCountry)
3876 {
3877 csrApplyCountryInformation(pMac, FALSE);
3878 }
3879 else
3880 {
3881 csrApplyCountryInformation(pMac, TRUE);
3882 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003883 }
Kiran4a17ebe2013-01-31 10:43:43 -08003884 if ((csrIs11dSupported (pMac)) && pIes)
3885 {
3886 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003887 {
Kiran4a17ebe2013-01-31 10:43:43 -08003888 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003889 }
3890 else
3891 {
3892 //Let's also update the below to make sure we don't update CC while
3893 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303894 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003895 pBssDesc->bssId, sizeof(tSirMacAddr));
3896 }
Kiran4a17ebe2013-01-31 10:43:43 -08003897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 //Qos
3900 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3901 //SSID
3902 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3903 //fragment threshold
3904 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3905 //RTS threshold
3906 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3907
3908 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 //Auth type
3910 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3911 //encryption type
3912 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3913 //short slot time
3914 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 //11d
3916 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3917 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3918 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 /*//11h
3920 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3921 */
3922 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3923 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003924
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003925 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 {
3927 channel = pProfile->operationChannel;
3928 }
3929 else
3930 {
3931 if(pBssDesc)
3932 {
3933 channel = pBssDesc->channelId;
3934 }
3935 }
3936 if(0 != channel)
3937 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05303938 if(CSR_IS_CHANNEL_24GHZ(channel) &&
3939 !pMac->roam.configParam.channelBondingMode24GHz &&
3940 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
3941 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07003942 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05303943 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3944 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
3945 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07003946 }
3947 else
3948 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003949 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 }
3951 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003952#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003953 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3954 // in function csrConvertCBIniValueToPhyCBState()
3955 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3956 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003957 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003958 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003959 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003960 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05303961 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003962 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003963 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003964 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003965 }
3966 else
3967#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003968 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3969 //Rate
3970 //Fixed Rate
3971 if(pBssDesc)
3972 {
3973 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3974 }
3975 else
3976 {
3977 csrSetCfgRateSetFromProfile(pMac, pProfile);
3978 }
3979 //Make this the last CFG to set. The callback will trigger a join_req
3980 //Join time out
3981 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3982
3983 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 return (status);
3985}
3986
Jeff Johnson295189b2012-06-20 16:38:30 -07003987eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3988 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3989{
3990 eHalStatus status;
3991 tBssConfigParam *pBssConfig;
3992 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003993
3994 if(!pSession)
3995 {
3996 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3997 return eHAL_STATUS_FAILURE;
3998 }
3999
Kiet Lam64c1b492013-07-12 13:56:44 +05304000 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4001 if ( NULL == pBssConfig )
4002 status = eHAL_STATUS_FAILURE;
4003 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304005 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4007 if(HAL_STATUS_SUCCESS(status))
4008 {
4009 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004010 /* This will allow to pass cbMode during join req */
4011 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004012 //For IBSS, we need to prepare some more information
4013 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 )
4016 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004017 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 }
4019 // If we are in an IBSS, then stop the IBSS...
4020 ////Not worry about WDS connection for now
4021 if ( csrIsConnStateIbss( pMac, sessionId ) )
4022 {
4023 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4024 }
4025 else
4026 {
4027 // if we are in an Infrastructure association....
4028 if ( csrIsConnStateInfra( pMac, sessionId ) )
4029 {
4030 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4031 // across SSIDs (roaming to a new SSID)... //
4032 //Not worry about WDS connection for now
4033 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304034 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 {
4036 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304037 status = csrRoamIssueDisassociate( pMac, sessionId,
4038 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304040 else
4041 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4043 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304044 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304046 // Set parameters for this Bss.
4047 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4048 pBssDesc, pBssConfig,
4049 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304053 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 {
4055 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4056 // Nothing to stop.
4057 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304059 )
4060 {
4061 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4062 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4063 // Set parameters for this Bss.
4064 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4065 pBssDesc, pBssConfig,
4066 pIes, is11rRoamingFlag);
4067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 }
4069 }
4070 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304071 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 return (status);
4074}
4075
Jeff Johnson295189b2012-06-20 16:38:30 -07004076eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4077 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4078{
4079 eCsrJoinState eRoamState = eCsrContinueRoaming;
4080 eHalStatus status;
4081 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4082 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4083 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004084
4085 if(!pSession)
4086 {
4087 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4088 return (eCsrStopRoaming);
4089 }
4090
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 if( CSR_IS_WDS_STA( pProfile ) )
4092 {
4093 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4094 if( !HAL_STATUS_SUCCESS( status ) )
4095 {
4096 eRoamState = eCsrStopRoaming;
4097 }
4098 }
4099 else
4100 {
4101 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4102 {
4103 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4104 return (eCsrStopRoaming);
4105 }
4106 if ( csrIsInfraBssDesc( pBssDesc ) )
4107 {
4108 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4109 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4110 // have changed and handle the changes (without disturbing the current association).
4111
4112 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4113 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4114 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4115 )
4116 {
4117 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4118 // with Authenticating first. To force this, stop the current association (Disassociate) and
4119 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4120 // a new Association.
4121 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4122 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004123 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4125 {
4126 eRoamState = eCsrReassocToSelfNoCapChange;
4127 }
4128 else
4129 {
4130 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304132 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4134 if(HAL_STATUS_SUCCESS(status))
4135 {
4136 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004137 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304139 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4140 pBssDesc, &bssConfig,
4141 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004142 if(!HAL_STATUS_SUCCESS(status))
4143 {
4144 eRoamState = eCsrStopRoaming;
4145 }
4146 }
4147 else
4148 {
4149 eRoamState = eCsrStopRoaming;
4150 }
4151 }//same profile
4152 }
4153 else
4154 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304155 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4157 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304158 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4159 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304161 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004162 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304163 }
4164 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 {
4166 // note: we used to pre-auth here with open authentication networks but that was not working so well.
Jeff Johnson295189b2012-06-20 16:38:30 -07004167 // stop the existing network before attempting to join the new network...
4168 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4169 {
4170 eRoamState = eCsrStopRoaming;
4171 }
4172 }
4173 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304174 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 {
4176 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4177 {
4178 eRoamState = eCsrStopRoaming;
4179 }
4180 }
4181 if( pIesLocal && !pScanResult->pvIes )
4182 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304183 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004184 }
4185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 return( eRoamState );
4187}
4188
Jeff Johnson295189b2012-06-20 16:38:30 -07004189eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4190 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4191{
4192 eHalStatus status = eHAL_STATUS_SUCCESS;
4193 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304194 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 roamInfo.pBssDesc = pBssDesc;
4196 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4197 return (status);
4198}
Jeff Johnson295189b2012-06-20 16:38:30 -07004199//In case no matching BSS is found, use whatever default we can find
4200static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4201{
4202 //Need to get all negotiated types in place first
4203 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004204 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 {
4206 default:
4207 case eCSR_AUTH_TYPE_WPA:
4208 case eCSR_AUTH_TYPE_WPA_PSK:
4209 case eCSR_AUTH_TYPE_WPA_NONE:
4210 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4211 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4212 break;
4213
4214 case eCSR_AUTH_TYPE_SHARED_KEY:
4215 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4216 break;
4217
4218 case eCSR_AUTH_TYPE_AUTOSWITCH:
4219 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4220 break;
4221 }
4222 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4223 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4224 //In this case, the multicast encryption needs to follow the uncast ones.
4225 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4226 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4227}
4228
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004229
4230static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4231{
4232 switch(pCommand->u.roamCmd.roamReason)
4233 {
4234 case eCsrLostLink1:
4235 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4236 break;
4237 case eCsrLostLink2:
4238 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4239 break;
4240 case eCsrLostLink3:
4241 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4242 break;
4243 default:
4244 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4245 pCommand->u.roamCmd.roamReason);
4246 break;
4247 }
4248}
4249
Jeff Johnson295189b2012-06-20 16:38:30 -07004250static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4251{
4252 eHalStatus status;
4253 tCsrScanResult *pScanResult = NULL;
4254 eCsrJoinState eRoamState = eCsrStopRoaming;
4255 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4256 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4257 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4258#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4259 v_U8_t acm_mask = 0;
4260#endif
4261 tANI_U32 sessionId = pCommand->sessionId;
4262 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4263 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4264 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004265
4266 if(!pSession)
4267 {
4268 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4269 return (eCsrStopRoaming);
4270 }
4271
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 do
4273 {
4274 // Check for Cardbus eject condition, before trying to Roam to any BSS
4275 //***if( !balIsCardPresent(pAdapter) ) break;
4276
Kiet Lam64c1b492013-07-12 13:56:44 +05304277 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304278 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004279 if(NULL != pBSSList)
4280 {
4281 // When handling AP's capability change, continue to associate to
4282 // same BSS and make sure pRoamBssEntry is not Null.
4283 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4284 {
4285 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4286 {
4287 //Try the first BSS
4288 pCommand->u.roamCmd.pLastRoamBss = NULL;
4289 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4290 }
4291 else
4292 {
4293 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4294 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4295 {
4296 //Done with all the BSSs
4297 //In this case, will tell HDD the completion
4298 break;
4299 }
4300 else
4301 {
4302 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304303 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4305 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4306 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4307 pRoamInfo = &roamInfo;
4308 }
4309 }
4310 while(pCommand->u.roamCmd.pRoamBssEntry)
4311 {
4312 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 /*If concurrency enabled take the concurrent connected channel first. */
4314 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304315 if (vos_concurrent_open_sessions_running() &&
4316 !csrIsValidMcConcurrentSession(pMac, sessionId,
4317 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 {
4319 concurrentChannel =
4320 csrGetConcurrentOperationChannel(pMac);
4321 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004322 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 if ((concurrentChannel) &&
4324 (concurrentChannel ==
4325 pScanResult->Result.BssDescriptor.channelId))
4326 {
4327 //make this 0 because we do not want the
4328 //below check to pass as we don't want to
4329 //connect on other channel
4330 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4331 FL("Concurrent channel match =%d"),
4332 concurrentChannel);
4333 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 }
4335 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004336
4337 if (!concurrentChannel)
4338 {
4339
4340 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4341 sessionId, &pScanResult->Result.BssDescriptor,
4342 pCommand->u.roamCmd.roamId)))
4343 {
4344 //Ok to roam this
4345 break;
4346 }
4347 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004348 else
4349 {
4350 eRoamState = eCsrStopRoamingDueToConcurrency;
4351 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004352 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4353 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4354 {
4355 //Done with all the BSSs
4356 fDone = eANI_BOOLEAN_TRUE;
4357 break;
4358 }
4359 }
4360 if(fDone)
4361 {
4362 break;
4363 }
4364 }
4365 }
4366 //We have something to roam, tell HDD when it is infra.
4367 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4368 //For WDS, the indication is eCSR_ROAM_WDS_IND
4369 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4370 {
4371 if(pRoamInfo)
4372 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004373 if(pSession->bRefAssocStartCnt)
4374 {
4375 pSession->bRefAssocStartCnt--;
4376 //Complete the last association attemp because a new one is about to be tried
4377 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4378 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004380 }
4381 }
4382 /* If the roaming has stopped, not to continue the roaming command*/
4383 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4384 {
4385 //No need to complete roaming here as it already completes
4386 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4387 pCommand->u.roamCmd.roamReason);
4388 eRoamState = eCsrStopRoaming;
4389 csrSetAbortRoamingCommand(pMac, pCommand);
4390 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304392 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 if(pScanResult)
4394 {
4395 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4397 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004398 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 fDone = eANI_BOOLEAN_TRUE;
4400 eRoamState = eCsrStopRoaming;
4401 break;
4402 }
4403 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4404 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4405 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4406 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4407 CSR_IS_QOS_BSS(pIesLocal) &&
4408 CSR_IS_UAPSD_BSS(pIesLocal) )
4409 {
4410#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4412 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004413#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004414 }
4415 else
4416 {
4417 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4418 }
4419 if( pIesLocal && !pScanResult->Result.pvIes)
4420 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304421 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 }
4423 }
4424 else
4425 {
4426 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4427 }
4428 roamInfo.pProfile = pProfile;
4429 pSession->bRefAssocStartCnt++;
4430 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4431 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004433 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4434 {
4435 // If this is a start IBSS profile, then we need to start the IBSS.
4436 if ( CSR_IS_START_IBSS(pProfile) )
4437 {
4438 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 // Attempt to start this IBSS...
4440 csrRoamAssignDefaultParam( pMac, pCommand );
4441 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4442 if(HAL_STATUS_SUCCESS(status))
4443 {
4444 if ( fSameIbss )
4445 {
4446 eRoamState = eCsrStartIbssSameIbss;
4447 }
4448 else
4449 {
4450 eRoamState = eCsrContinueRoaming;
4451 }
4452 }
4453 else
4454 {
4455 //it somehow fail need to stop
4456 eRoamState = eCsrStopRoaming;
4457 }
4458 break;
4459 }
4460 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 )
4463 {
4464 // Attempt to start this WDS...
4465 csrRoamAssignDefaultParam( pMac, pCommand );
4466 /* For AP WDS, we dont have any BSSDescription */
4467 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4468 if(HAL_STATUS_SUCCESS(status))
4469 {
4470 eRoamState = eCsrContinueRoaming;
4471 }
4472 else
4473 {
4474 //it somehow fail need to stop
4475 eRoamState = eCsrStopRoaming;
4476 }
4477 }
4478 else
4479 {
4480 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004481 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 eRoamState = eCsrStopRoaming;
4483 break;
4484 }
4485 }
4486 else //We have BSS
4487 {
4488 //Need to assign these value because they are used in csrIsSameProfile
4489 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004490 /* The OSEN IE doesn't provide the cipher suite.
4491 * Therefore set to constant value of AES */
4492 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4493 {
4494 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4495 eCSR_ENCRYPT_TYPE_AES;
4496 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4497 eCSR_ENCRYPT_TYPE_AES;
4498 }
4499 else
4500 {
4501 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4502 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4503 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4504 pScanResult->mcEncryptionType;
4505 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4507 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4508 {
4509 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4510 {
4511 eRoamState = eCsrStartIbssSameIbss;
4512 break;
4513 }
4514 }
4515 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4516 {
4517 //trying to connect to the one already connected
4518 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4519 eRoamState = eCsrReassocToSelfNoCapChange;
4520 break;
4521 }
4522 // Attempt to Join this Bss...
4523 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4524 break;
4525 }
4526
4527 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4529 {
4530 //Need to indicate association_completion if association_start has been done
4531 if(pSession->bRefAssocStartCnt > 0)
4532 {
4533 pSession->bRefAssocStartCnt--;
4534 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004535 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4537 eCSR_ROAM_ASSOCIATION_COMPLETION,
4538 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4539 }
4540 }
4541
4542 return( eRoamState );
4543}
4544
Jeff Johnson295189b2012-06-20 16:38:30 -07004545static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4546{
4547 eHalStatus status = eHAL_STATUS_SUCCESS;
4548 eCsrJoinState RoamState;
4549 tANI_U32 sessionId = pCommand->sessionId;
4550
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 //***if( hddIsRadioStateOn( pAdapter ) )
4552 {
4553 // Attept to join a Bss...
4554 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004555
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004557 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 {
4559 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 // and if connected in Infrastructure mode...
4561 if ( csrIsConnStateInfra(pMac, sessionId) )
4562 {
4563 //... then we need to issue a disassociation
4564 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4565 if(!HAL_STATUS_SUCCESS(status))
4566 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004567 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 //roam command is completed by caller in the failed case
4569 fComplete = eANI_BOOLEAN_TRUE;
4570 }
4571 }
4572 else if( csrIsConnStateIbss(pMac, sessionId) )
4573 {
4574 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4575 if(!HAL_STATUS_SUCCESS(status))
4576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004577 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 //roam command is completed by caller in the failed case
4579 fComplete = eANI_BOOLEAN_TRUE;
4580 }
4581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4583 {
4584 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4585 if(!HAL_STATUS_SUCCESS(status))
4586 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004587 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 //roam command is completed by caller in the failed case
4589 fComplete = eANI_BOOLEAN_TRUE;
4590 }
4591 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 else
4593 {
4594 fComplete = eANI_BOOLEAN_TRUE;
4595 }
4596 if(fComplete)
4597 {
4598 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004599 if(eCsrStopRoamingDueToConcurrency == RoamState)
4600 {
4601 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4602 }
4603 else
4604 {
4605 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 }
4608 }
4609 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4610 {
4611 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4612 }
4613 else if ( eCsrStartIbssSameIbss == RoamState )
4614 {
4615 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4616 }
4617 }//hddIsRadioStateOn
4618
4619 return status;
4620}
Jeff Johnson295189b2012-06-20 16:38:30 -07004621eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4622{
4623 tANI_U32 sessionId;
4624 tCsrRoamSession *pSession;
4625 tCsrScanResult *pScanResult = NULL;
4626 tSirBssDescription *pBssDesc = NULL;
4627 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004628 sessionId = pCommand->sessionId;
4629 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004630
4631 if(!pSession)
4632 {
4633 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4634 return eHAL_STATUS_FAILURE;
4635 }
4636
Jeff Johnson295189b2012-06-20 16:38:30 -07004637 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4638 {
4639 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004640 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4642 return eHAL_STATUS_FAILURE;
4643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 if (pCommand->u.roamCmd.pRoamBssEntry)
4645 {
4646 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4647 pBssDesc = &pScanResult->Result.BssDescriptor;
4648 }
4649 else
4650 {
4651 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004652 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4654 return eHAL_STATUS_FAILURE;
4655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4657 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4658 return status;
4659}
4660
Jeff Johnson295189b2012-06-20 16:38:30 -07004661eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4662{
4663 eHalStatus status = eHAL_STATUS_SUCCESS;
4664 tCsrRoamInfo roamInfo;
4665 tANI_U32 sessionId = pCommand->sessionId;
4666 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004667
4668 if(!pSession)
4669 {
4670 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4671 return eHAL_STATUS_FAILURE;
4672 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05304673
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 switch ( pCommand->u.roamCmd.roamReason )
4675 {
4676 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004678 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 case eCsrSmeIssuedDisassocForHandoff:
4681 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4682#if 0 // TODO : Confirm this change
4683 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4684#else
4685 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4686#endif
4687
4688 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004690 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004691 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004693 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004695 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 case eCsrHddIssuedReassocToSameAP:
4698 case eCsrSmeIssuedReassocToSameAP:
4699 {
4700 tDot11fBeaconIEs *pIes = NULL;
4701
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 if( pSession->pConnectBssDesc )
4703 {
4704 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4705 if(!HAL_STATUS_SUCCESS(status) )
4706 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004707 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 }
4709 else
4710 {
4711 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4712 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4713 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4715 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4716 pSession->bRefAssocStartCnt++;
4717 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4718 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4719
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004720 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004721 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4722 &pCommand->u.roamCmd.roamProfile );
4723 if(!HAL_STATUS_SUCCESS(status))
4724 {
4725 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004726 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004727 }
4728
Kiet Lam64c1b492013-07-12 13:56:44 +05304729 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004730 pIes = NULL;
4731 }
4732 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05304733 else
4734 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004735 break;
4736 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004738 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004739 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4740 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4741 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004742 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004743 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004744 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4745 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004746
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 case eCsrStopBss:
4748 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4749 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4750 break;
4751
4752 case eCsrForcedDisassocSta:
4753 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4754 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4755 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4756 pCommand->u.roamCmd.reason);
4757 break;
4758
4759 case eCsrForcedDeauthSta:
4760 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4761 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4762 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4763 pCommand->u.roamCmd.reason);
4764 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004765
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004766 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004767 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004768 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4769 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004770 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004771
4772 default:
4773 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4774
4775 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4776 {
4777 //Remember the roaming profile
4778 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304779 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4780 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004781 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304782 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004783 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4784 }
4785 }
4786
4787 //At this point, original uapsd_mask is saved in pCurRoamProfile
4788 //uapsd_mask in the pCommand may change from this point on.
4789
4790 // Attempt to roam with the new scan results (if we need to..)
4791 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004792 if(!HAL_STATUS_SUCCESS(status))
4793 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004794 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004795 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 break;
4797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004798 return (status);
4799}
4800
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004801void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4802{
4803 pCommand->u.roamCmd.pLastRoamBss = NULL;
4804 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4805 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304806 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004807}
4808
Jeff Johnson295189b2012-06-20 16:38:30 -07004809void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4810{
4811 if(pCommand->u.roamCmd.fReleaseBssList)
4812 {
4813 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4814 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4815 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4816 }
4817 if(pCommand->u.roamCmd.fReleaseProfile)
4818 {
4819 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4820 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4821 }
4822 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4823 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304824 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004825}
4826
Jeff Johnson295189b2012-06-20 16:38:30 -07004827void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4828{
Kiet Lam64c1b492013-07-12 13:56:44 +05304829 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004830}
Jeff Johnson295189b2012-06-20 16:38:30 -07004831void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4832{
4833 tListElem *pEntry;
4834 tSmeCmd *pCommand;
4835 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004836 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004837 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4838 if ( pEntry )
4839 {
4840 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004841 // If the head of the queue is Active and it is a ROAM command, remove
4842 // and put this on the Free queue.
4843 if ( eSmeCommandRoam == pCommand->command )
4844 {
4845 //we need to process the result first before removing it from active list because state changes
4846 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4847 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4848 if( fReleaseCommand )
4849 {
4850 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4851 {
4852 csrReleaseCommandRoam( pMac, pCommand );
4853 }
4854 else
4855 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004856 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004857 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 }
4859 }
4860 else
4861 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004862 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004863 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 }
4865 }
4866 else
4867 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004868 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004869 }
4870 }
4871 else
4872 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004873 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004874 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004875 if( fReleaseCommand )
4876 {
4877 smeProcessPendingQueue( pMac );
4878 }
4879}
4880
Jeff Johnson295189b2012-06-20 16:38:30 -07004881void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4882{
4883 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004884 if(!pSession)
4885 {
4886 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4887 return;
4888 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304889 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4890 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 pSession->NumPmkidCandidate = 0;
4892}
Jeff Johnson295189b2012-06-20 16:38:30 -07004893#ifdef FEATURE_WLAN_WAPI
4894void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4895{
4896 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004897 if(!pSession)
4898 {
4899 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4900 return;
4901 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304902 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4903 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 pSession->NumBkidCandidate = 0;
4905}
4906#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004907extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4908
Jeff Johnson295189b2012-06-20 16:38:30 -07004909static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4910 tSirBssDescription *pSirBssDesc,
4911 tDot11fBeaconIEs *pIes)
4912{
4913 eHalStatus status = eHAL_STATUS_SUCCESS;
4914 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4915 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004916
4917 if(!pSession)
4918 {
4919 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4920 return eHAL_STATUS_FAILURE;
4921 }
4922
Jeff Johnson295189b2012-06-20 16:38:30 -07004923 if((eCSR_AUTH_TYPE_WPA == authType) ||
4924 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4925 (eCSR_AUTH_TYPE_RSN == authType) ||
4926 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4927#if defined WLAN_FEATURE_VOWIFI_11R
4928 ||
4929 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4930 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4931#endif /* FEATURE_WLAN_WAPI */
4932#ifdef FEATURE_WLAN_WAPI
4933 ||
4934 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4935 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4936#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004937#ifdef WLAN_FEATURE_11W
4938 ||
Abhishek Singhae408032014-09-25 17:22:04 +05304939 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4940 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07004941#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 )
4943 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004944 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4945 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004946 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 }
4948 if( pIesLocal )
4949 {
4950 tANI_U32 nIeLen;
4951 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 if((eCSR_AUTH_TYPE_RSN == authType) ||
4953#if defined WLAN_FEATURE_VOWIFI_11R
4954 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4955 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4956#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004957#if defined WLAN_FEATURE_11W
4958 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05304959 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07004960#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4962 {
4963 if(pIesLocal->RSN.present)
4964 {
4965 //Calculate the actual length
4966 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4967 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4968 + 2 //akm_suite_count
4969 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4970 + 2; //reserved
4971 if( pIesLocal->RSN.pmkid_count )
4972 {
4973 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4974 }
4975 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304976 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4977 if (NULL == pSession->pWpaRsnRspIE)
4978 status = eHAL_STATUS_FAILURE;
4979 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304981 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4983 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4984 //copy upto akm_suites
4985 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304986 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4987 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004988 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304989 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4990 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004991 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304992 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4993 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004994 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 if( pIesLocal->RSN.pwise_cipher_suite_count )
4996 {
4997 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304998 vos_mem_copy(pIeBuf,
4999 pIesLocal->RSN.pwise_cipher_suites,
5000 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005001 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5002 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305003 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 pIeBuf += 2;
5005 if( pIesLocal->RSN.akm_suite_count )
5006 {
5007 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305008 vos_mem_copy(pIeBuf,
5009 pIesLocal->RSN.akm_suites,
5010 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
5012 }
5013 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305014 vos_mem_copy(pIeBuf,
5015 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
5016 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005017 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5018 }
5019 }
5020 }
5021 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5022 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5023 {
5024 if(pIesLocal->WPA.present)
5025 {
5026 //Calculate the actual length
5027 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5028 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5029 + 2 //auth_suite_count
5030 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5031 // The WPA capabilities follows the Auth Suite (two octects)--
5032 // this field is optional, and we always "send" zero, so just
5033 // remove it. This is consistent with our assumptions in the
5034 // frames compiler; c.f. bug 15234:
5035 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305036
5037 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5038 if ( NULL == pSession->pWpaRsnRspIE )
5039 status = eHAL_STATUS_FAILURE;
5040 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005041 {
5042 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5043 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5044 pIeBuf = pSession->pWpaRsnRspIE + 2;
5045 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305046 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305048 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5049 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305051 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5052 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005053 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5054 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5055 }
5056 }
5057 }
5058#ifdef FEATURE_WLAN_WAPI
5059 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5060 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5061 {
5062 if(pIesLocal->WAPI.present)
5063 {
5064 //Calculate the actual length
5065 nIeLen = 4 //version + akm_suite_count
5066 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5067 + 2 //pwise_cipher_suite_count
5068 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5069 + 6; //gp_cipher_suite + preauth + reserved
5070 if( pIesLocal->WAPI.bkid_count )
5071 {
5072 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5073 }
5074
5075 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305076 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5077 if ( NULL == pSession->pWapiRspIE )
5078 status = eHAL_STATUS_FAILURE;
5079 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005080 {
5081 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5082 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5083 pIeBuf = pSession->pWapiRspIE + 2;
5084 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305085 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 pIeBuf += 4;
5087 if( pIesLocal->WAPI.akm_suite_count )
5088 {
5089 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305090 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5091 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305093 }
5094 vos_mem_copy(pIeBuf,
5095 &pIesLocal->WAPI.unicast_cipher_suite_count,
5096 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005098 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5099 {
5100 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305101 vos_mem_copy( pIeBuf,
5102 pIesLocal->WAPI.unicast_cipher_suites,
5103 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005104 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5105 }
lukez3c809222013-05-03 10:23:02 -07005106 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305107 vos_mem_copy(pIeBuf,
5108 pIesLocal->WAPI.multicast_cipher_suite,
5109 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005110 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305111 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305112 vos_mem_copy(pIeBuf,
5113 pIesLocal->WAPI.multicast_cipher_suite + 4,
5114 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005115 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305116 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305117 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5118
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005119 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005120 if( pIesLocal->WAPI.bkid_count )
5121 {
5122 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305123 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5124 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005125 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5126 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305127 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005129 }
5130 }
5131#endif /* FEATURE_WLAN_WAPI */
5132 if( !pIes )
5133 {
5134 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305135 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005136 }
5137 }
5138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005139 return (status);
5140}
5141
Jeff Johnson295189b2012-06-20 16:38:30 -07005142static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5143{
5144 v_U8_t bACWeights[WLANTL_MAX_AC];
5145 v_U8_t paramBk, paramBe, paramVi, paramVo;
5146 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5148 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5149 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5150 //This doesn't address the case where the lower AC needs a real higher weight
5151 if( pIEs->WMMParams.present )
5152 {
5153 //no change to the lowest ones
5154 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5155 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5156 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5157 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5158 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5159 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5160 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5161 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5162 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5163 {
5164 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5165 fWeightChange = VOS_TRUE;
5166 }
5167 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5168 {
5169 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5170 fWeightChange = VOS_TRUE;
5171 }
5172 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5173 {
5174 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5175 fWeightChange = VOS_TRUE;
5176 }
5177 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5178 {
5179 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5180 fWeightChange = VOS_TRUE;
5181 }
5182 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5183 {
5184 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5185 fWeightChange = VOS_TRUE;
5186 }
5187 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5188 {
5189 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5190 fWeightChange = VOS_TRUE;
5191 }
5192 if(fWeightChange)
5193 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005194 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005195 bACWeights[2], bACWeights[3]);
5196 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5197 }
5198 }
5199}
Jeff Johnson295189b2012-06-20 16:38:30 -07005200#ifdef WLAN_FEATURE_VOWIFI_11R
5201//Returns whether the current association is a 11r assoc or not
5202tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5203{
5204#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5205 return csrNeighborRoamIs11rAssoc(pMac);
5206#else
5207 return eANI_BOOLEAN_FALSE;
5208#endif
5209}
5210#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005211#ifdef FEATURE_WLAN_ESE
5212//Returns whether the current association is a ESE assoc or not
5213tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005214{
5215#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005216 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005217#else
5218 return eANI_BOOLEAN_FALSE;
5219#endif
5220}
5221#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005222#ifdef FEATURE_WLAN_LFR
5223//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305224tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005225{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305226 tCsrRoamSession *pSession = NULL;
5227
5228 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5229 {
5230 pSession = CSR_GET_SESSION( pMac, sessionId );
5231 if (NULL != pSession->pCurRoamProfile)
5232 {
5233 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5234 {
5235 return eANI_BOOLEAN_FALSE;
5236 }
5237 }
5238 }
5239
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005240#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5241 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5242 {
5243 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5244 }
5245 else
5246#endif
5247 {
5248 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005249 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005250 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005251}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005252
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005253#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005254/* ---------------------------------------------------------------------------
5255
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005256 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005257
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005258 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005259
5260 \param pMac - The handle returned by macOpen.
5261
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005262 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005263
5264---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005265tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005266{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005267 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005268}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005269#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005270
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005271#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5272//Returns whether "FW based BG scan" is currently enabled...or not
5273tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5274{
5275 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5276}
5277#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005278#endif
5279
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005280#if defined(FEATURE_WLAN_ESE)
5281tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005282{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005283 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005284}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005285#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005286
Jeff Johnson295189b2012-06-20 16:38:30 -07005287//Return true means the command can be release, else not
5288static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5289 eCsrRoamCompleteResult Result, void *Context )
5290{
5291 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5292 tSirBssDescription *pSirBssDesc = NULL;
5293 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5294 tCsrScanResult *pScanResult = NULL;
5295 tCsrRoamInfo roamInfo;
5296 sme_QosAssocInfo assocInfo;
5297 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5298 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5299 tDot11fBeaconIEs *pIes = NULL;
5300 tANI_U32 sessionId = pCommand->sessionId;
5301 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5302 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5303 eRoamCmdStatus roamStatus;
5304 eCsrRoamResult roamResult;
5305 eHalStatus status;
5306 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005307 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005308
Jeff Johnson32d95a32012-09-10 13:15:23 -07005309 if(!pSession)
5310 {
5311 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5312 return eANI_BOOLEAN_FALSE;
5313 }
5314
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005315 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005316 switch( Result )
5317 {
5318 case eCsrJoinSuccess:
5319 // reset the IDLE timer
5320 // !!
5321 // !! fall through to the next CASE statement here is intentional !!
5322 // !!
5323 case eCsrReassocSuccess:
5324 if(eCsrReassocSuccess == Result)
5325 {
5326 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5327 }
5328 else
5329 {
5330 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5331 }
5332 // Success Join Response from LIM. Tell NDIS we are connected and save the
5333 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005334 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305335 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005336 //always free the memory here
5337 if(pSession->pWpaRsnRspIE)
5338 {
5339 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305340 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005341 pSession->pWpaRsnRspIE = NULL;
5342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005343#ifdef FEATURE_WLAN_WAPI
5344 if(pSession->pWapiRspIE)
5345 {
5346 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305347 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 pSession->pWapiRspIE = NULL;
5349 }
5350#endif /* FEATURE_WLAN_WAPI */
5351#ifdef FEATURE_WLAN_BTAMP_UT_RF
5352 //Reset counter so no join retry is needed.
5353 pSession->maxRetryCount = 0;
5354 csrRoamStopJoinRetryTimer(pMac, sessionId);
5355#endif
5356 /* This creates problem since we have not saved the connected profile.
5357 So moving this after saving the profile
5358 */
5359 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305360
5361 /* Reset remainInPowerActiveTillDHCP as it might have been set
5362 * by last failed secured connection.
5363 * It should be set only for secured connection.
5364 */
5365 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5367 {
5368 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5369 }
5370 else
5371 {
5372 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5373 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005374 //Use the last connected bssdesc for reassoc-ing to the same AP.
5375 //NOTE: What to do when reassoc to a different AP???
5376 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5377 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5378 {
5379 pSirBssDesc = pSession->pConnectBssDesc;
5380 if(pSirBssDesc)
5381 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305382 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5383 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 }
5385 }
5386 else
5387 {
5388
5389 if(pCommand->u.roamCmd.pRoamBssEntry)
5390 {
5391 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5392 if(pScanResult != NULL)
5393 {
5394 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5395 //this can be NULL
5396 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305397 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5398 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 }
5400 }
5401 }
5402 if( pSirBssDesc )
5403 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005404 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5406 //Save WPA/RSN IE
5407 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005408#ifdef FEATURE_WLAN_ESE
5409 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005410#endif
5411
5412 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5413 // substate change.
5414 // Moving even save profile above so that below mentioned conditon is also met.
5415 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5416 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5418 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5419 // will be dropped for the security context may not be set properly.
5420 //
5421 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5422 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5423 //
5424 // this reordering was done on titan_prod_usb branch and is being replicated here.
5425 //
5426
5427 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5428 !pProfile->bWPSAssociation)
5429 {
5430 // Issue the set Context request to LIM to establish the Unicast STA context
5431 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5432 pProfile->negotiatedUCEncryptionType,
5433 pSirBssDesc, &(pSirBssDesc->bssId),
5434 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5435 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005436 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005437 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5438 }
5439 // Issue the set Context request to LIM to establish the Broadcast STA context
5440 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5441 pSirBssDesc, &BroadcastMac,
5442 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5443 }
5444 else
5445 {
5446 //Need to wait for supplicant authtication
5447 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 //Set the subestate to WaitForKey in case authentiation is needed
5449 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5450
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 if(pProfile->bWPSAssociation)
5452 {
5453 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5454 }
5455 else
5456 {
5457 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5458 }
5459
5460 //Save sessionId in case of timeout
5461 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5462 //This time should be long enough for the rest of the process plus setting key
5463 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5464 {
5465 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005466 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5468 }
5469 }
5470
5471 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5472 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 if(Context)
5474 {
5475 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5476 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5478 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5479#ifdef WLAN_FEATURE_VOWIFI_11R
5480 len += pJoinRsp->parsedRicRspLen;
5481#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005482#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 len += pJoinRsp->tspecIeLen;
5484#endif
5485 if(len)
5486 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305487 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5488 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305490 vos_mem_copy(pSession->connectedInfo.pbFrames,
5491 pJoinRsp->frames, len);
5492 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5493 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5494 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005495#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305496 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005497#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005498#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305499 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005500#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305501 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5502 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5503 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5504 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005505 }
5506 }
5507 if(pCommand->u.roamCmd.fReassoc)
5508 {
5509 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5510 }
5511 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5512 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5513 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5514 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305515 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005516 }
5517 else
5518 {
5519 if(pCommand->u.roamCmd.fReassoc)
5520 {
5521 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5522 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5523 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5524 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5525 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5526 }
5527 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305528 /* Update the staId from the previous connected profile info
5529 as the reassociation is triggred at SME/HDD */
5530 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5531 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5532 {
5533 roamInfo.staId = pSession->connectedInfo.staId;
5534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005535#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5536 // Indicate SME-QOS with reassoc success event, only after
5537 // copying the frames
5538 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5539#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 roamInfo.pBssDesc = pSirBssDesc;
5541 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5542 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5543#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5544 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5545#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5546 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5548 //It may be better to let QoS do this????
5549 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5550 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005551 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5553 pmcStartUapsd( pMac, NULL, NULL );
5554 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305555 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5557 if( pSession->bRefAssocStartCnt > 0 )
5558 {
5559 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005560 //Remove this code once SLM_Sessionization is supported
5561 //BMPS_WORKAROUND_NOT_NEEDED
5562 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005563 {
5564 pMac->roam.configParam.doBMPSWorkaround = 1;
5565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5567 }
5568
5569 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 // reset the PMKID candidate list
5571 csrResetPMKIDCandidateList( pMac, sessionId );
5572 //Update TL's AC weight base on the current EDCA parameters
5573 //These parameters may change in the course of the connection, that sictuation
5574 //is not taken care here. This change is mainly to address a WIFI WMM test where
5575 //BE has a equal or higher TX priority than VI.
5576 //We only do this for infra link
5577 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5578 {
5579 csrCheckAndUpdateACWeight(pMac, pIes);
5580 }
5581#ifdef FEATURE_WLAN_WAPI
5582 // reset the BKID candidate list
5583 csrResetBKIDCandidateList( pMac, sessionId );
5584#endif /* FEATURE_WLAN_WAPI */
5585 }
5586 else
5587 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005588 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 csrScanCancelIdleScan(pMac);
5591 //Not to signal link up because keys are yet to be set.
5592 //The linkup function will overwrite the sub-state that we need to keep at this point.
5593 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5594 {
5595 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5598 //enough to let security and DHCP handshake succeed before entry into BMPS
5599 if (pmcShouldBmpsTimerRun(pMac))
5600 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305601 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5602 * until keys are set before going into BMPS.
5603 */
5604 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5605 {
5606 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5607 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5608 "to make sure we wait until keys are set before"
5609 " going to BMPS"));
5610 }
5611
Jeff Johnson295189b2012-06-20 16:38:30 -07005612 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5613 != eHAL_STATUS_SUCCESS)
5614 {
5615 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5616 }
5617 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005619 break;
5620
Jeff Johnson295189b2012-06-20 16:38:30 -07005621 case eCsrStartBssSuccess:
5622 // on the StartBss Response, LIM is returning the Bss Description that we
5623 // are beaconing. Add this Bss Description to our scan results and
5624 // chain the Profile to this Bss Description. On a Start BSS, there was no
5625 // detected Bss description (no partner) so we issued the Start Bss to
5626 // start the Ibss without any Bss description. Lim was kind enough to return
5627 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005628 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005629 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305631 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 if( CSR_IS_IBSS( pProfile ) )
5633 {
5634 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005636 else if (CSR_IS_INFRA_AP(pProfile))
5637 {
5638 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5639 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005640 else
5641 {
5642 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5643 }
5644 if( !CSR_IS_WDS_STA( pProfile ) )
5645 {
5646 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5649 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305650 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 roamInfo.pBssDesc = pSirBssDesc;
5652 //We need to associate_complete it first, becasue Associate_start already indicated.
5653 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5654 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5655 break;
5656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005659 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 }
5661 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5662 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5663 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5664 if(pSirBssDesc)
5665 {
5666 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305667 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5668 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 }
5670 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305671 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005672#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5673 {
5674 vos_log_ibss_pkt_type *pIbssLog;
5675 tANI_U32 bi;
5676
5677 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5678 if(pIbssLog)
5679 {
5680 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5681 {
5682 //We start the IBSS (didn't find any matched IBSS out there)
5683 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5684 }
5685 else
5686 {
5687 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5688 }
5689 if(pSirBssDesc)
5690 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305691 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5693 }
5694 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5695 {
5696 //***U8 is not enough for beacon interval
5697 pIbssLog->beaconInterval = (v_U8_t)bi;
5698 }
5699 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5700 }
5701 }
5702#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5703 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5704 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5706 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005707 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5708 csrRoamIssueSetContextReq( pMac, sessionId,
5709 pProfile->negotiatedMCEncryptionType,
5710 pSirBssDesc, &BroadcastMac,
5711 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5712 }
5713 }
5714 else
5715 {
5716 //Keep the state to eCSR_ROAMING_STATE_JOINING
5717 //Need to send join_req.
5718 if(pCommand->u.roamCmd.pRoamBssEntry)
5719 {
5720 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5721 {
5722 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5723 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5724 // Set the roaming substate to 'join attempt'...
5725 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005726 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005727 }
5728 }
5729 else
5730 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005731 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005732 VOS_ASSERT( 0 );
5733 }
5734 }
5735 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5736 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5737 //trigger the connection start indication in Vista
5738 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5739 {
5740 roamStatus = eCSR_ROAM_IBSS_IND;
5741 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5742 if( CSR_IS_WDS( pProfile ) )
5743 {
5744 roamStatus = eCSR_ROAM_WDS_IND;
5745 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5746 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005747 if( CSR_IS_INFRA_AP( pProfile ) )
5748 {
5749 roamStatus = eCSR_ROAM_INFRA_IND;
5750 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5751 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005752
5753 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5754 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5755 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305756 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5758 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005759 //We start the IBSS (didn't find any matched IBSS out there)
5760 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005761 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305762 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5763 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005764 //Remove this code once SLM_Sessionization is supported
5765 //BMPS_WORKAROUND_NOT_NEEDED
5766 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005767 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005768 {
5769 pMac->roam.configParam.doBMPSWorkaround = 1;
5770 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005771
Jeff Johnson295189b2012-06-20 16:38:30 -07005772 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5773 }
5774
5775 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005776
5777 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005778 {
5779 //need to send stop BSS because we fail to send join_req
5780 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5781 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5782 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 case eCsrStartBssFailure:
5786#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5787 {
5788 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5790 if(pIbssLog)
5791 {
5792 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5793 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5794 }
5795 }
5796#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 roamStatus = eCSR_ROAM_IBSS_IND;
5798 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5799 if( CSR_IS_WDS( pProfile ) )
5800 {
5801 roamStatus = eCSR_ROAM_WDS_IND;
5802 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5803 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 if( CSR_IS_INFRA_AP( pProfile ) )
5805 {
5806 roamStatus = eCSR_ROAM_INFRA_IND;
5807 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5808 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005809 if(Context)
5810 {
5811 pSirBssDesc = (tSirBssDescription *)Context;
5812 }
5813 else
5814 {
5815 pSirBssDesc = NULL;
5816 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305817 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 roamInfo.pBssDesc = pSirBssDesc;
5819 //We need to associate_complete it first, becasue Associate_start already indicated.
5820 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5821 csrSetDefaultDot11Mode( pMac );
5822 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 case eCsrSilentlyStopRoaming:
5824 // We are here because we try to start the same IBSS
5825 //No message to PE
5826 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005827 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5829 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305830 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005831 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5832 if( roamInfo.pBssDesc )
5833 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305834 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5835 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 }
5837 //Since there is no change in the current state, simply pass back no result otherwise
5838 //HDD may be mistakenly mark to disconnected state.
5839 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5840 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 case eCsrSilentlyStopRoamingSaveState:
5843 //We are here because we try to connect to the same AP
5844 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005845 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305846 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005847
5848 //to aviod resetting the substate to NONE
5849 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5850 //No need to change substate to wai_for_key because there is no state change
5851 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5852 if( roamInfo.pBssDesc )
5853 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305854 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5855 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005856 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5858 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5859 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5860 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5861 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5862 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5863 roamInfo.staId = pSession->connectedInfo.staId;
5864 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 pSession->bRefAssocStartCnt--;
5867 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5868 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5869 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5870 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005871 case eCsrReassocFailure:
5872#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5873 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5874#endif
5875 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005876 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 csrFreeConnectBssDesc(pMac, sessionId);
5878 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5879 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
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;
5884 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5885 eCSR_ROAM_WDS_IND,
5886 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5887 //Need to issue stop_bss
5888 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005889 case eCsrJoinFailure:
5890 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005891 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 default:
5893 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005894 smsLog(pMac, LOGW, FL("receives no association indication"));
5895 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005896 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005897 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5898 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5899 {
5900 //do not free for the other profiles as we need to send down stop BSS later
5901 csrFreeConnectBssDesc(pMac, sessionId);
5902 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5903 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5904 csrSetDefaultDot11Mode( pMac );
5905 }
5906
5907 switch( pCommand->u.roamCmd.roamReason )
5908 {
5909 // If this transition is because of an 802.11 OID, then we transition
5910 // back to INIT state so we sit waiting for more OIDs to be issued and
5911 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005912 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005913 case eCsrSmeIssuedAssocToSimilarAP:
5914 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005915 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305917 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5919 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5920 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305921 vos_mem_copy(&roamInfo.bssid,
5922 &pSession->joinFailStatusCode.bssId,
5923 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005924
Jeff Johnson295189b2012-06-20 16:38:30 -07005925 /* Defeaturize this later if needed */
5926#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5927 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5928 if (csrRoamIsHandoffInProgress(pMac))
5929 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 /* Should indicate neighbor roam algorithm about the connect failure here */
5931 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5932 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005933#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 if(pSession->bRefAssocStartCnt > 0)
5935 {
5936 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005937 if(eCsrJoinFailureDueToConcurrency == Result)
5938 {
5939 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5940 eCSR_ROAM_ASSOCIATION_COMPLETION,
5941 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5942 }
5943 else
5944 {
5945 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 eCSR_ROAM_ASSOCIATION_COMPLETION,
5947 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005949 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005950 else
5951 {
5952 /* bRefAssocStartCnt is not incremented when
5953 * eRoamState == eCsrStopRoamingDueToConcurrency
5954 * in csrRoamJoinNextBss API. so handle this in
5955 * else case by sending assoc failure
5956 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005957 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005958 pCommand->u.scanCmd.roamId,
5959 eCSR_ROAM_ASSOCIATION_FAILURE,
5960 eCSR_ROAM_RESULT_FAILURE);
5961 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005962 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005963#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05305964 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5966#endif
5967 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5968 csrScanStartIdleScan(pMac);
5969#ifdef FEATURE_WLAN_BTAMP_UT_RF
5970 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5971 //BT activity and not able to recevie WLAN traffic. Retry the join
5972 if( CSR_IS_WDS_STA(pProfile) )
5973 {
5974 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5975 }
5976#endif
5977 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 case eCsrHddIssuedReassocToSameAP:
5979 case eCsrSmeIssuedReassocToSameAP:
5980 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5981
5982 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5983#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5984 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5985#endif
5986 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5987 csrScanStartIdleScan(pMac);
5988 break;
5989 case eCsrForcedDisassoc:
5990 case eCsrForcedDeauth:
5991 case eCsrSmeIssuedIbssJoinFailure:
5992 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5993
5994 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5995 {
5996 // Notify HDD that IBSS join failed
5997 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5998 }
5999 else
6000 {
6001 csrRoamCallCallback(pMac, sessionId, NULL,
6002 pCommand->u.roamCmd.roamId,
6003 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6004 }
6005#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6006 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6007#endif
6008 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006009 /*
6010 *DelSta not done FW still in conneced state so dont
6011 *issue IMPS req
6012 */
6013 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6014 {
6015 smsLog(pMac, LOGW, FL("FW still in connected state "));
6016 break;
6017 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 csrScanStartIdleScan(pMac);
6019 break;
6020 case eCsrForcedIbssLeave:
6021 csrRoamCallCallback(pMac, sessionId, NULL,
6022 pCommand->u.roamCmd.roamId,
6023 eCSR_ROAM_IBSS_LEAVE,
6024 eCSR_ROAM_RESULT_IBSS_STOP);
6025 break;
6026 case eCsrForcedDisassocMICFailure:
6027 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6028
6029 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6030#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6031 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6032#endif
6033 csrScanStartIdleScan(pMac);
6034 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 case eCsrStopBss:
6036 csrRoamCallCallback(pMac, sessionId, NULL,
6037 pCommand->u.roamCmd.roamId,
6038 eCSR_ROAM_INFRA_IND,
6039 eCSR_ROAM_RESULT_INFRA_STOPPED);
6040 break;
6041 case eCsrForcedDisassocSta:
6042 case eCsrForcedDeauthSta:
6043 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
6044 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
6045 {
6046 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006047
6048 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6049 {
6050 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05306051 vos_mem_copy(roamInfo.peerMac,
6052 pCommand->u.roamCmd.peerMac,
6053 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6055 roamInfo.statusCode = eSIR_SME_SUCCESS;
6056 status = csrRoamCallCallback(pMac, sessionId,
6057 &roamInfo, pCommand->u.roamCmd.roamId,
6058 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
6059 }
6060 }
6061 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 case eCsrLostLink1:
6063 // if lost link roam1 failed, then issue lost link Scan2 ...
6064 csrScanRequestLostLink2(pMac, sessionId);
6065 break;
6066 case eCsrLostLink2:
6067 // if lost link roam2 failed, then issue lost link scan3 ...
6068 csrScanRequestLostLink3(pMac, sessionId);
6069 break;
6070 case eCsrLostLink3:
6071 default:
6072 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6073
6074 //We are done with one round of lostlink roaming here
6075 csrScanHandleFailedLostlink3(pMac, sessionId);
6076 break;
6077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 break;
6079 }
6080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006081 return ( fReleaseCommand );
6082}
6083
Jeff Johnson295189b2012-06-20 16:38:30 -07006084eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6085{
6086 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 return (status);
6088}
6089
Jeff Johnson295189b2012-06-20 16:38:30 -07006090eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6091{
6092 eHalStatus status = eHAL_STATUS_SUCCESS;
6093 tANI_U32 size = 0;
6094
6095 do
6096 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306097 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6099 {
6100 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306101 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6102 if ( NULL == pDstProfile->BSSIDs.bssid )
6103 status = eHAL_STATUS_FAILURE;
6104 else
6105 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 if(!HAL_STATUS_SUCCESS(status))
6107 {
6108 break;
6109 }
6110 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306111 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6112 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006113 }
6114 if(pSrcProfile->SSIDs.numOfSSIDs)
6115 {
6116 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306117 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6118 if ( NULL == pDstProfile->SSIDs.SSIDList )
6119 status = eHAL_STATUS_FAILURE;
6120 else
6121 status = eHAL_STATUS_SUCCESS;
6122 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006123 {
6124 break;
6125 }
6126 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306127 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6128 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 }
6130 if(pSrcProfile->nWPAReqIELength)
6131 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306132 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6133 if ( NULL == pDstProfile->pWPAReqIE )
6134 status = eHAL_STATUS_FAILURE;
6135 else
6136 status = eHAL_STATUS_SUCCESS;
6137
6138 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006139 {
6140 break;
6141 }
6142 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306143 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6144 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 }
6146 if(pSrcProfile->nRSNReqIELength)
6147 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306148 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6149 if ( NULL == pDstProfile->pRSNReqIE )
6150 status = eHAL_STATUS_FAILURE;
6151 else
6152 status = eHAL_STATUS_SUCCESS;
6153
6154 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 {
6156 break;
6157 }
6158 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306159 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6160 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 }
6162#ifdef FEATURE_WLAN_WAPI
6163 if(pSrcProfile->nWAPIReqIELength)
6164 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306165 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6166 if ( NULL == pDstProfile->pWAPIReqIE )
6167 status = eHAL_STATUS_FAILURE;
6168 else
6169 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 if(!HAL_STATUS_SUCCESS(status))
6171 {
6172 break;
6173 }
6174 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306175 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6176 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 }
6178#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 if(pSrcProfile->nAddIEScanLength)
6180 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306181 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6182 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006183 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306184 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306185 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306186 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6187 }
6188 else
6189 {
6190 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6191 FL(" AddIEScanLength is not valid %u"),
6192 pSrcProfile->nAddIEScanLength);
6193 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006194 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006195 if(pSrcProfile->nAddIEAssocLength)
6196 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306197 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6198 if ( NULL == pDstProfile->pAddIEAssoc )
6199 status = eHAL_STATUS_FAILURE;
6200 else
6201 status = eHAL_STATUS_SUCCESS;
6202
Jeff Johnson295189b2012-06-20 16:38:30 -07006203 if(!HAL_STATUS_SUCCESS(status))
6204 {
6205 break;
6206 }
6207 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306208 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6209 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 if(pSrcProfile->ChannelInfo.ChannelList)
6212 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306213 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6214 pSrcProfile->ChannelInfo.numOfChannels);
6215 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6216 status = eHAL_STATUS_FAILURE;
6217 else
6218 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 if(!HAL_STATUS_SUCCESS(status))
6220 {
6221 break;
6222 }
6223 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306224 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6225 pSrcProfile->ChannelInfo.ChannelList,
6226 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 pDstProfile->AuthType = pSrcProfile->AuthType;
6229 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6230 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6231 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6232 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6233 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006234#ifdef WLAN_FEATURE_11W
6235 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6236 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6237 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6238#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006239 pDstProfile->BSSType = pSrcProfile->BSSType;
6240 pDstProfile->phyMode = pSrcProfile->phyMode;
6241 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6242
6243#ifdef FEATURE_WLAN_WAPI
6244 if(csrIsProfileWapi(pSrcProfile))
6245 {
6246 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6247 {
6248 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6249 }
6250 }
6251#endif /* FEATURE_WLAN_WAPI */
6252 pDstProfile->CBMode = pSrcProfile->CBMode;
6253 /*Save the WPS info*/
6254 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006255 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006256 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 pDstProfile->privacy = pSrcProfile->privacy;
6259 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6260 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6261 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6262 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6263 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6264 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6265 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6266 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6267 pDstProfile->wps_state = pSrcProfile->wps_state;
6268 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306269 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6270 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006271#ifdef WLAN_FEATURE_VOWIFI_11R
6272 if (pSrcProfile->MDID.mdiePresent)
6273 {
6274 pDstProfile->MDID.mdiePresent = 1;
6275 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6276 }
6277#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006278 }while(0);
6279
6280 if(!HAL_STATUS_SUCCESS(status))
6281 {
6282 csrReleaseProfile(pMac, pDstProfile);
6283 pDstProfile = NULL;
6284 }
6285
6286 return (status);
6287}
Jeff Johnson295189b2012-06-20 16:38:30 -07006288eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6289{
6290 eHalStatus status = eHAL_STATUS_SUCCESS;
6291 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6292 do
6293 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306294 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 if(pSrcProfile->bssid)
6296 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306297 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6298 if ( NULL == pDstProfile->BSSIDs.bssid )
6299 status = eHAL_STATUS_FAILURE;
6300 else
6301 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 if(!HAL_STATUS_SUCCESS(status))
6303 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306304 smsLog( pMac, LOGE,
6305 FL("failed to allocate memory for BSSID"
6306 "%02x:%02x:%02x:%02x:%02x:%02x"),
6307 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6308 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 break;
6310 }
6311 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306312 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6313 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006314 }
6315 if(pSrcProfile->SSID.ssId)
6316 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306317 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6318 if ( NULL == pDstProfile->SSIDs.SSIDList )
6319 status = eHAL_STATUS_FAILURE;
6320 else
6321 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006322 if(!HAL_STATUS_SUCCESS(status))
6323 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306324 smsLog( pMac, LOGE,
6325 FL("failed to allocate memory for SSIDList"
6326 "%02x:%02x:%02x:%02x:%02x:%02x"),
6327 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6328 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006329 break;
6330 }
6331 pDstProfile->SSIDs.numOfSSIDs = 1;
6332 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6333 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306334 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6335 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006336 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006337 if(pSrcProfile->nAddIEAssocLength)
6338 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306339 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6340 if ( NULL == pDstProfile->pAddIEAssoc)
6341 status = eHAL_STATUS_FAILURE;
6342 else
6343 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006344 if(!HAL_STATUS_SUCCESS(status))
6345 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006346 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006347 break;
6348 }
6349 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306350 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6351 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006352 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306353 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6354 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6355 status = eHAL_STATUS_FAILURE;
6356 else
6357 status = eHAL_STATUS_SUCCESS;
6358
Jeff Johnson295189b2012-06-20 16:38:30 -07006359 if(!HAL_STATUS_SUCCESS(status))
6360 {
6361 break;
6362 }
6363 pDstProfile->ChannelInfo.numOfChannels = 1;
6364 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 pDstProfile->AuthType.numEntries = 1;
6366 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6367 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6368 pDstProfile->EncryptionType.numEntries = 1;
6369 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6370 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6371 pDstProfile->mcEncryptionType.numEntries = 1;
6372 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6373 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6374 pDstProfile->BSSType = pSrcProfile->BSSType;
6375 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306376 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6377 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006378#ifdef WLAN_FEATURE_VOWIFI_11R
6379 if (pSrcProfile->MDID.mdiePresent)
6380 {
6381 pDstProfile->MDID.mdiePresent = 1;
6382 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6383 }
6384#endif
6385
6386 }while(0);
6387
6388 if(!HAL_STATUS_SUCCESS(status))
6389 {
6390 csrReleaseProfile(pMac, pDstProfile);
6391 pDstProfile = NULL;
6392 }
6393
6394 return (status);
6395}
6396
Jeff Johnson295189b2012-06-20 16:38:30 -07006397eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6398 tScanResultHandle hBSSList,
6399 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6400 tANI_BOOLEAN fClearScan)
6401{
6402 eHalStatus status = eHAL_STATUS_SUCCESS;
6403 tSmeCmd *pCommand;
6404
6405 pCommand = csrGetCommandBuffer(pMac);
6406 if(NULL == pCommand)
6407 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006408 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 status = eHAL_STATUS_RESOURCES;
6410 }
6411 else
6412 {
6413 if( fClearScan )
6414 {
6415 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306416 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 }
6418 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6419 if(NULL == pProfile)
6420 {
6421 //We can roam now
6422 //Since pProfile is NULL, we need to build our own profile, set everything to default
6423 //We can only support open and no encryption
6424 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6425 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6426 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6427 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6428 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6429 }
6430 else
6431 {
6432 //make a copy of the profile
6433 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6434 if(HAL_STATUS_SUCCESS(status))
6435 {
6436 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6437 }
6438 }
6439 pCommand->command = eSmeCommandRoam;
6440 pCommand->sessionId = (tANI_U8)sessionId;
6441 pCommand->u.roamCmd.hBSSList = hBSSList;
6442 pCommand->u.roamCmd.roamId = roamId;
6443 pCommand->u.roamCmd.roamReason = reason;
6444 //We need to free the BssList when the command is done
6445 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6446 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006447 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6448 FL("CSR PERSONA=%d"),
6449 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006450 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6451 if( !HAL_STATUS_SUCCESS( status ) )
6452 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006453 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 csrReleaseCommandRoam( pMac, pCommand );
6455 }
6456 }
6457
6458 return (status);
6459}
Jeff Johnson295189b2012-06-20 16:38:30 -07006460eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6461 tCsrRoamModifyProfileFields *pMmodProfileFields,
6462 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6463{
6464 eHalStatus status = eHAL_STATUS_SUCCESS;
6465 tSmeCmd *pCommand;
6466
6467 pCommand = csrGetCommandBuffer(pMac);
6468 if(NULL == pCommand)
6469 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006470 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 status = eHAL_STATUS_RESOURCES;
6472 }
6473 else
6474 {
6475 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306476 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006477 if(pProfile)
6478 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 //This is likely trying to reassoc to different profile
6480 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6481 //make a copy of the profile
6482 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6483 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006484 }
6485 else
6486 {
6487 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6488 //how to update WPA/WPA2 info in roamProfile??
6489 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006491 if(HAL_STATUS_SUCCESS(status))
6492 {
6493 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6494 }
6495 pCommand->command = eSmeCommandRoam;
6496 pCommand->sessionId = (tANI_U8)sessionId;
6497 pCommand->u.roamCmd.roamId = roamId;
6498 pCommand->u.roamCmd.roamReason = reason;
6499 //We need to free the BssList when the command is done
6500 //For reassoc there is no BSS list, so the boolean set to false
6501 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6502 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6503 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006504 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6505 if( !HAL_STATUS_SUCCESS( status ) )
6506 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006507 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006508 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6509 csrReleaseCommandRoam( pMac, pCommand );
6510 }
6511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006512 return (status);
6513}
6514
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006515eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6516 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306517// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006518{
6519 eHalStatus status = eHAL_STATUS_SUCCESS;
6520 tSmeCmd *pCommand;
6521
6522 pCommand = csrGetCommandBuffer(pMac);
6523 if(NULL == pCommand)
6524 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006525 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006526 status = eHAL_STATUS_RESOURCES;
6527 }
6528 else
6529 {
6530 if(pBssDescription)
6531 {
6532 //copy over the parameters we need later
6533 pCommand->command = eSmeCommandRoam;
6534 pCommand->sessionId = (tANI_U8)sessionId;
6535 pCommand->u.roamCmd.roamReason = reason;
6536 //this is the important parameter
6537 //in this case we are using this field for the "next" BSS
6538 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6539 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6540 if( !HAL_STATUS_SUCCESS( status ) )
6541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006542 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006543 csrReleaseCommandPreauth( pMac, pCommand );
6544 }
6545 }
6546 else
6547 {
6548 //Return failure
6549 status = eHAL_STATUS_RESOURCES;
6550 }
6551 }
6552 return (status);
6553}
6554
6555eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6556{
6557 tListElem *pEntry;
6558 tSmeCmd *pCommand;
6559 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6560 if ( pEntry )
6561 {
6562 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6563 if ( (eSmeCommandRoam == pCommand->command) &&
6564 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6565 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006566 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006567 pCommand->command, pCommand->u.roamCmd.roamReason);
6568 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6569 csrReleaseCommandPreauth( pMac, pCommand );
6570 }
6571 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006572 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006573 pCommand->command, pCommand->u.roamCmd.roamReason);
6574 }
6575 }
6576 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006577 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006578 }
6579 smeProcessPendingQueue( pMac );
6580 return eHAL_STATUS_SUCCESS;
6581}
6582
Jeff Johnson295189b2012-06-20 16:38:30 -07006583eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6584 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6585{
6586 eHalStatus status = eHAL_STATUS_FAILURE;
6587 tScanResultHandle hBSSList;
6588 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006589 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6590 if(HAL_STATUS_SUCCESS(status))
6591 {
6592 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6593 if(pRoamId)
6594 {
6595 *pRoamId = roamId;
6596 }
6597 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6598 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6599 if(!HAL_STATUS_SUCCESS(status))
6600 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006601 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 csrScanResultPurge(pMac, hBSSList);
6603 }
6604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 return (status);
6606}
6607
Jeff Johnson295189b2012-06-20 16:38:30 -07006608eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6609 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6610{
6611 eHalStatus status = eHAL_STATUS_SUCCESS;
6612 tScanResultHandle hBSSList;
6613 tCsrScanResultFilter *pScanFilter;
6614 tANI_U32 roamId = 0;
6615 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6616 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 if (NULL == pProfile)
6618 {
6619 smsLog(pMac, LOGP, FL("No profile specified"));
6620 return eHAL_STATUS_FAILURE;
6621 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306622 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6623 "encryType = %d"),
6624 lim_BssTypetoString(pProfile->BSSType),
6625 pProfile->BSSType,
6626 pProfile->AuthType.authType[0],
6627 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006628 if( CSR_IS_WDS( pProfile ) &&
6629 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6630 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006631 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006632 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006633 return status;
6634 }
6635 csrRoamCancelRoaming(pMac, sessionId);
6636 csrScanRemoveFreshScanCommand(pMac, sessionId);
6637 csrScanCancelIdleScan(pMac);
6638 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306639 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306640
6641 if (!vos_concurrent_open_sessions_running() &&
6642 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07006643 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306644 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 csrScanDisable(pMac);
6646 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306647
Jeff Johnson295189b2012-06-20 16:38:30 -07006648 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6649 //Check whether ssid changes
6650 if(csrIsConnStateConnected(pMac, sessionId))
6651 {
6652 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6653 {
6654 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6655 }
6656 }
6657#ifdef FEATURE_WLAN_BTAMP_UT_RF
6658 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6659#endif
6660 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6661 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006662 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6664 if(pRoamId)
6665 {
6666 roamId = *pRoamId;
6667 }
6668 if(!HAL_STATUS_SUCCESS(status))
6669 {
6670 fCallCallback = eANI_BOOLEAN_TRUE;
6671 }
6672 }
6673 else
6674 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306675 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6676 if ( NULL == pScanFilter )
6677 status = eHAL_STATUS_FAILURE;
6678 else
6679 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 if(HAL_STATUS_SUCCESS(status))
6681 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306682 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006683 //Try to connect to any BSS
6684 if(NULL == pProfile)
6685 {
6686 //No encryption
6687 pScanFilter->EncryptionType.numEntries = 1;
6688 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6689 }//we don't have a profile
6690 else
6691 {
6692 //Here is the profile we need to connect to
6693 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6694 }//We have a profile
6695 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6696 if(pRoamId)
6697 {
6698 *pRoamId = roamId;
6699 }
6700
6701 if(HAL_STATUS_SUCCESS(status))
6702 {
6703 /*Save the WPS info*/
6704 if(NULL != pProfile)
6705 {
6706 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006707 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 }
6709 else
6710 {
6711 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006712 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006714 do
6715 {
6716 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006717 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 )
6719 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006720 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006721 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6722 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6723 if(!HAL_STATUS_SUCCESS(status))
6724 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006725 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 fCallCallback = eANI_BOOLEAN_TRUE;
6727 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006728 else
6729 {
6730 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6731 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 break;
6733 }
6734 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006735 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 if(HAL_STATUS_SUCCESS(status))
6737 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6739 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6740 if(!HAL_STATUS_SUCCESS(status))
6741 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006742 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006743 csrScanResultPurge(pMac, hBSSList);
6744 fCallCallback = eANI_BOOLEAN_TRUE;
6745 }
6746 }//Have scan result
6747 else if(NULL != pProfile)
6748 {
6749 //Check whether it is for start ibss
6750 if(CSR_IS_START_IBSS(pProfile))
6751 {
6752 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6753 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6754 if(!HAL_STATUS_SUCCESS(status))
6755 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006756 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006757 fCallCallback = eANI_BOOLEAN_TRUE;
6758 }
6759 }
6760 else
6761 {
6762 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006763 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 if(!HAL_STATUS_SUCCESS(status))
6765 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006766 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006767 fCallCallback = eANI_BOOLEAN_TRUE;
6768 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006769 else
6770 {
6771 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6772 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006773 }
6774 }
6775 else
6776 {
6777 fCallCallback = eANI_BOOLEAN_TRUE;
6778 }
6779 } while (0);
6780 if(NULL != pProfile)
6781 {
6782 //we need to free memory for filter if profile exists
6783 csrFreeScanFilter(pMac, pScanFilter);
6784 }
6785 }//Got the scan filter from profile
6786
Kiet Lam64c1b492013-07-12 13:56:44 +05306787 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006788 }//allocated memory for pScanFilter
6789 }//No Bsslist coming in
6790 //tell the caller if we fail to trigger a join request
6791 if( fCallCallback )
6792 {
6793 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6794 }
6795
6796 return (status);
6797}
Jeff Johnson295189b2012-06-20 16:38:30 -07006798eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6799 tCsrRoamModifyProfileFields modProfileFields,
6800 tANI_U32 *pRoamId)
6801{
6802 eHalStatus status = eHAL_STATUS_SUCCESS;
6803 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6804 tANI_U32 roamId = 0;
6805 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006806 if (NULL == pProfile)
6807 {
6808 smsLog(pMac, LOGP, FL("No profile specified"));
6809 return eHAL_STATUS_FAILURE;
6810 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306811 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6812 "encryType = %d"),
6813 lim_BssTypetoString(pProfile->BSSType),
6814 pProfile->BSSType,
6815 pProfile->AuthType.authType[0],
6816 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 csrRoamCancelRoaming(pMac, sessionId);
6818 csrScanRemoveFreshScanCommand(pMac, sessionId);
6819 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306820 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006821 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 if(csrIsConnStateConnected(pMac, sessionId))
6823 {
6824 if(pProfile)
6825 {
6826 if(pProfile->SSIDs.numOfSSIDs &&
6827 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6828 {
6829 fCallCallback = eANI_BOOLEAN_FALSE;
6830 }
6831 else
6832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006833 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006834 }
6835 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306836 else if (!vos_mem_compare(&modProfileFields,
6837 &pSession->connectedProfile.modifyProfileFields,
6838 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006839 {
6840 fCallCallback = eANI_BOOLEAN_FALSE;
6841 }
6842 else
6843 {
6844 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006845 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006846 }
6847 }
6848 else
6849 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006850 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 if(!fCallCallback)
6853 {
6854 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6855 if(pRoamId)
6856 {
6857 *pRoamId = roamId;
6858 }
6859
Jeff Johnson295189b2012-06-20 16:38:30 -07006860 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6861 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006862 }
6863 else
6864 {
6865 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6866 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6867 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006868 return status;
6869}
Jeff Johnson295189b2012-06-20 16:38:30 -07006870eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6871{
6872 eHalStatus status = eHAL_STATUS_FAILURE;
6873 tScanResultHandle hBSSList = NULL;
6874 tCsrScanResultFilter *pScanFilter = NULL;
6875 tANI_U32 roamId;
6876 tCsrRoamProfile *pProfile = NULL;
6877 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006878
6879 if(!pSession)
6880 {
6881 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6882 return eHAL_STATUS_FAILURE;
6883 }
6884
Jeff Johnson295189b2012-06-20 16:38:30 -07006885 do
6886 {
6887 if(pSession->pCurRoamProfile)
6888 {
6889 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306890 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006891 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306892 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6893 if ( NULL == pProfile )
6894 status = eHAL_STATUS_FAILURE;
6895 else
6896 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006897 if(!HAL_STATUS_SUCCESS(status))
6898 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306899 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006900 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306901 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006902 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306903 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6904 if ( NULL == pScanFilter )
6905 status = eHAL_STATUS_FAILURE;
6906 else
6907 status = eHAL_STATUS_SUCCESS;
6908
Jeff Johnson295189b2012-06-20 16:38:30 -07006909 if(!HAL_STATUS_SUCCESS(status))
6910 {
6911 break;
6912 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306913 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006914 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6915 if(!HAL_STATUS_SUCCESS(status))
6916 {
6917 break;
6918 }
6919 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6920 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6921 if(HAL_STATUS_SUCCESS(status))
6922 {
6923 //we want to put the last connected BSS to the very beginning, if possible
6924 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6925 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6926 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6927 if(!HAL_STATUS_SUCCESS(status))
6928 {
6929 csrScanResultPurge(pMac, hBSSList);
6930 break;
6931 }
6932 }
6933 else
6934 {
6935 //Do a scan on this profile
6936 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006937 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006938 if(!HAL_STATUS_SUCCESS(status))
6939 {
6940 break;
6941 }
6942 }
6943 }//We have a profile
6944 else
6945 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006946 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006947 break;
6948 }
6949 }while(0);
6950 if(pScanFilter)
6951 {
6952 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306953 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006954 }
6955 if(NULL != pProfile)
6956 {
6957 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306958 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006959 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006960 return (status);
6961}
Jeff Johnson295189b2012-06-20 16:38:30 -07006962eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6963{
6964 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006965 if(csrIsConnStateConnected(pMac, sessionId))
6966 {
6967 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6968 if(HAL_STATUS_SUCCESS(status))
6969 {
6970 status = csrRoamJoinLastProfile(pMac, sessionId);
6971 }
6972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006973 return (status);
6974}
6975
Jeff Johnson295189b2012-06-20 16:38:30 -07006976eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6977{
6978 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006979 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006980 csrRoamCancelRoaming(pMac, sessionId);
6981 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6982 if(csrIsConnStateDisconnected(pMac, sessionId))
6983 {
6984 status = csrRoamJoinLastProfile(pMac, sessionId);
6985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 return (status);
6987}
6988
Jeff Johnson295189b2012-06-20 16:38:30 -07006989eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6990{
6991 eHalStatus status = eHAL_STATUS_SUCCESS;
6992 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6993 eCsrRoamSubState NewSubstate;
6994 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05306995
6996 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6997 {
6998 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
6999 " eCSR_ROAM_SUBSTATE_NONE"));
7000 csrRoamStopWaitForKeyTimer( pMac );
7001 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7002 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007003 // change state to 'Roaming'...
7004 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7005
7006 if ( csrIsConnStateIbss( pMac, sessionId ) )
7007 {
7008 // If we are in an IBSS, then stop the IBSS...
7009 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7010 fComplete = (!HAL_STATUS_SUCCESS(status));
7011 }
7012 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7013 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007014 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 -07007015 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7016 //Restore AC weight in case we change it
7017 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7018 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7019 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7020 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7021 {
7022 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7023 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307024 else
7025 {
7026 // If we are in neighbor preauth done state then on receiving
7027 // disassoc or deauth we dont roam instead we just disassoc
7028 // from current ap and then go to disconnected state
7029 // This happens for ESE and 11r FT connections ONLY.
7030#ifdef WLAN_FEATURE_VOWIFI_11R
7031 if (csrRoamIs11rAssoc(pMac) &&
7032 (csrNeighborRoamStatePreauthDone(pMac)))
7033 {
7034 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7035 }
7036#endif
7037#ifdef FEATURE_WLAN_ESE
7038 if (csrRoamIsESEAssoc(pMac) &&
7039 (csrNeighborRoamStatePreauthDone(pMac)))
7040 {
7041 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7042 }
7043#endif
7044#ifdef FEATURE_WLAN_LFR
7045 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7046 (csrNeighborRoamStatePreauthDone(pMac)))
7047 {
7048 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7049 }
7050#endif
7051 }
7052
Jeff Johnson295189b2012-06-20 16:38:30 -07007053 if( fDisassoc )
7054 {
7055 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307056#ifdef DEBUG_ROAM_DELAY
7057 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7058#endif /* DEBUG_ROAM_DELAY */
Jeff Johnson295189b2012-06-20 16:38:30 -07007059 }
7060 else
7061 {
7062 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7063 }
7064 fComplete = (!HAL_STATUS_SUCCESS(status));
7065 }
7066 else if ( csrIsConnStateWds( pMac, sessionId ) )
7067 {
7068 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7069 {
7070 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7071 fComplete = (!HAL_STATUS_SUCCESS(status));
7072 }
7073 //This has to be WDS station
7074 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7075 {
7076
7077 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7078 if( fDisassoc )
7079 {
7080 status = csrRoamIssueDisassociate( pMac, sessionId,
7081 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7082 fComplete = (!HAL_STATUS_SUCCESS(status));
7083 }
7084 }
7085 } else {
7086 // we got a dis-assoc request while not connected to any peer
7087 // just complete the command
7088 fComplete = eANI_BOOLEAN_TRUE;
7089 status = eHAL_STATUS_FAILURE;
7090 }
7091 if(fComplete)
7092 {
7093 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7094 }
7095
7096 if(HAL_STATUS_SUCCESS(status))
7097 {
7098 if ( csrIsConnStateInfra( pMac, sessionId ) )
7099 {
7100 //Set the state to disconnect here
7101 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7102 }
7103 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007104 else
7105 {
7106 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7107 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007108 return (status);
7109}
7110
Jeff Johnson295189b2012-06-20 16:38:30 -07007111/* This is been removed from latest code base */
7112/*
7113static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7114{
7115 eHalStatus status;
7116 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007117 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7118 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 return ( status );
7120}
7121*/
7122
Jeff Johnson295189b2012-06-20 16:38:30 -07007123eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7124{
7125 eHalStatus status = eHAL_STATUS_SUCCESS;
7126 tSmeCmd *pCommand;
7127 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007128 do
7129 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08007130 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 pCommand = csrGetCommandBuffer( pMac );
7132 if ( !pCommand )
7133 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007134 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007135 status = eHAL_STATUS_RESOURCES;
7136 break;
7137 }
7138 //Change the substate in case it is wait-for-key
7139 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7140 {
7141 csrRoamStopWaitForKeyTimer( pMac );
7142 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7143 }
7144 pCommand->command = eSmeCommandRoam;
7145 pCommand->sessionId = (tANI_U8)sessionId;
7146 switch ( reason )
7147 {
7148 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7149 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7150 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007151 case eCSR_DISCONNECT_REASON_DEAUTH:
7152 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7153 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007154 case eCSR_DISCONNECT_REASON_HANDOFF:
7155 fHighPriority = eANI_BOOLEAN_TRUE;
7156 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7157 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007158 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7159 case eCSR_DISCONNECT_REASON_DISASSOC:
7160 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7161 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7163 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7164 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007165 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7166 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7167 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007168 default:
7169 break;
7170 }
7171 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7172 if( !HAL_STATUS_SUCCESS( status ) )
7173 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007174 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007175 csrReleaseCommandRoam( pMac, pCommand );
7176 }
7177 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007178 return( status );
7179}
7180
Jeff Johnson295189b2012-06-20 16:38:30 -07007181eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7182{
7183 eHalStatus status = eHAL_STATUS_SUCCESS;
7184 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007185 pCommand = csrGetCommandBuffer( pMac );
7186 if ( NULL != pCommand )
7187 {
7188 //Change the substate in case it is wait-for-key
7189 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7190 {
7191 csrRoamStopWaitForKeyTimer( pMac );
7192 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7193 }
7194 pCommand->command = eSmeCommandRoam;
7195 pCommand->sessionId = (tANI_U8)sessionId;
7196 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7197 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7198 if( !HAL_STATUS_SUCCESS( status ) )
7199 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007200 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 csrReleaseCommandRoam( pMac, pCommand );
7202 }
7203 }
7204 else
7205 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007206 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007207 status = eHAL_STATUS_RESOURCES;
7208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 return ( status );
7210}
7211
Jeff Johnson295189b2012-06-20 16:38:30 -07007212eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7213{
7214 eHalStatus status = eHAL_STATUS_SUCCESS;
7215 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007216
7217 if(!pSession)
7218 {
7219 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7220 return eHAL_STATUS_FAILURE;
7221 }
7222
Jeff Johnson295189b2012-06-20 16:38:30 -07007223#ifdef FEATURE_WLAN_BTAMP_UT_RF
7224 //Stop te retry
7225 pSession->maxRetryCount = 0;
7226 csrRoamStopJoinRetryTimer(pMac, sessionId);
7227#endif
7228 //Not to call cancel roaming here
7229 //Only issue disconnect when necessary
7230 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7231 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7232 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7233
7234 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007235 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007236 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7237 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307238 else
7239 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307240 csrScanAbortScanForSSID(pMac, sessionId);
7241 status = eHAL_STATUS_CMD_NOT_QUEUED;
7242 smsLog( pMac, LOG1, FL(" Disconnect cmd not queued, Roam command is not present"
7243 " return with status %d"), status);
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307244 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007245 return (status);
7246}
7247
Jeff Johnson295189b2012-06-20 16:38:30 -07007248eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7249{
7250 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007251
7252 if(!pSession)
7253 {
7254 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7255 return eHAL_STATUS_FAILURE;
7256 }
7257
Jeff Johnson295189b2012-06-20 16:38:30 -07007258 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007259 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7260
7261 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7262}
7263
Jeff Johnson295189b2012-06-20 16:38:30 -07007264eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7265 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7266{
7267 eHalStatus status = eHAL_STATUS_SUCCESS;
7268 tDot11fBeaconIEs *pIesTemp = pIes;
7269 tANI_U8 index;
7270 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7271 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007272
7273 if(!pSession)
7274 {
7275 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7276 return eHAL_STATUS_FAILURE;
7277 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007278 if(pConnectProfile->pAddIEAssoc)
7279 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307280 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007281 pConnectProfile->pAddIEAssoc = NULL;
7282 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307283 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007284 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7285 pConnectProfile->AuthInfo = pProfile->AuthType;
7286 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7287 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7288 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7289 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7290 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7291 pConnectProfile->BSSType = pProfile->BSSType;
7292 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7293 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007294 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307295 if (!pConnectProfile->beaconInterval)
7296 {
7297 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7298 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307299 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007300 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7301 if(pProfile->nAddIEAssocLength)
7302 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307303 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7304 if ( NULL == pConnectProfile->pAddIEAssoc )
7305 status = eHAL_STATUS_FAILURE;
7306 else
7307 status = eHAL_STATUS_SUCCESS;
7308 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007309 {
7310 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7311 return eHAL_STATUS_FAILURE;
7312 }
7313 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307314 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7315 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007316 }
7317
Jeff Johnson295189b2012-06-20 16:38:30 -07007318 //Save bssid
7319 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7320#ifdef WLAN_FEATURE_VOWIFI_11R
7321 if (pSirBssDesc->mdiePresent)
7322 {
7323 pConnectProfile->MDID.mdiePresent = 1;
7324 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7325 }
7326#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007327 if( NULL == pIesTemp )
7328 {
7329 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7330 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007331#ifdef FEATURE_WLAN_ESE
7332 if ((csrIsProfileESE(pProfile) ||
7333 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307334 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7335 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7336 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7337 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7338#ifdef WLAN_FEATURE_11W
7339 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
7340#endif
7341 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007342 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007343 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007344 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007345 }
7346#endif
7347 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 if(HAL_STATUS_SUCCESS(status))
7349 {
7350 if(pIesTemp->SSID.present)
7351 {
7352 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307353 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7354 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007355 }
7356
7357 //Save the bss desc
7358 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307359
7360 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007361 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307362 //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 -07007363 pConnectProfile->qap = TRUE;
7364 }
7365 else
7366 {
7367 pConnectProfile->qap = FALSE;
7368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007369 if ( NULL == pIes )
7370 {
7371 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307372 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007373 }
7374 }
7375 //Save Qos connection
7376 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7377
7378 if(!HAL_STATUS_SUCCESS(status))
7379 {
7380 csrFreeConnectBssDesc(pMac, sessionId);
7381 }
7382 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7383 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307384 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7385 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7386 pConnectProfile->SSID.ssId,
7387 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007388 {
7389 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7390 break;
7391 }
7392 pConnectProfile->handoffPermitted = FALSE;
7393 }
7394
7395 return (status);
7396}
7397
Jeff Johnson295189b2012-06-20 16:38:30 -07007398static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7399{
7400 tListElem *pEntry = NULL;
7401 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007402 //The head of the active list is the request we sent
7403 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7404 if(pEntry)
7405 {
7406 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7407 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007408 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7409 {
7410 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7411 {
7412#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7413 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7414#endif
7415 }
7416 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7417 }
7418 else
7419 {
7420 tANI_U32 roamId = 0;
7421 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007422 if(!pSession)
7423 {
7424 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7425 return;
7426 }
7427
Jeff Johnson295189b2012-06-20 16:38:30 -07007428
7429 //The head of the active list is the request we sent
7430 //Try to get back the same profile and roam again
7431 if(pCommand)
7432 {
7433 roamId = pCommand->u.roamCmd.roamId;
7434 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007435 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7436 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007437 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007438#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7439 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7440 if (csrRoamIsHandoffInProgress(pMac))
7441 {
7442 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7443 /* Should indicate neighbor roam algorithm about the connect failure here */
7444 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7445 }
7446#endif
7447 if (pCommand)
7448 {
7449 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7450 {
7451 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7452 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7453 csrRoamReissueRoamCommand(pMac);
7454 }
7455 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7456 {
7457 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7458 }
7459 else
7460 {
7461 csrRoam(pMac, pCommand);
7462 }
7463 }
7464 else
7465 {
7466 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7467 }
7468 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7469}
7470
Jeff Johnson295189b2012-06-20 16:38:30 -07007471eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7472 tDot11fBeaconIEs *pIes,
7473 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7474{
7475 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007476 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7477 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007478
7479 // Set the roaming substate to 'join attempt'...
7480 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007481 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007482 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007483 return (status);
7484}
7485
Jeff Johnson295189b2012-06-20 16:38:30 -07007486static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7487 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7488{
7489 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 // Set the roaming substate to 'join attempt'...
7491 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7492
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307493 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7494 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307495#ifdef DEBUG_ROAM_DELAY
7496 //HACK usign buff len as Auth type
7497 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7498 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7499#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007500 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007501 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007502}
7503
Jeff Johnson295189b2012-06-20 16:38:30 -07007504void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7505{
7506 tListElem *pEntry;
7507 tSmeCmd *pCommand;
7508 tCsrRoamInfo roamInfo;
7509 tANI_U32 sessionId;
7510 tCsrRoamSession *pSession;
7511
7512 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7513 if(pEntry)
7514 {
7515 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7516 if ( eSmeCommandRoam == pCommand->command )
7517 {
7518 sessionId = pCommand->sessionId;
7519 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007520
7521 if(!pSession)
7522 {
7523 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7524 return;
7525 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307526 /* While switching between two AP, csr will reissue roam command again
7527 to the nextbss if it was interrupted by the dissconnect req for the
7528 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7529 so reset the bRefAssocStartCnt.
7530 */
7531 if(pSession->bRefAssocStartCnt > 0)
7532 {
7533 pSession->bRefAssocStartCnt--;
7534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007535 if( pCommand->u.roamCmd.fStopWds )
7536 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307537 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007538 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7539 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7540 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007541 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007542 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7543 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7544 eCSR_ROAM_WDS_IND,
7545 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007546 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7547 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7548 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7549 eCSR_ROAM_INFRA_IND,
7550 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7551 }
7552
Jeff Johnson295189b2012-06-20 16:38:30 -07007553
Jeff Johnson295189b2012-06-20 16:38:30 -07007554 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7555 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007556 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007557 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7558 }
7559 }
7560 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7561 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007562 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007563 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7564 }
7565 }
7566 else
7567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007568 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007569 }
7570 }
7571 else
7572 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007573 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007574 }
7575}
7576
Jeff Johnson295189b2012-06-20 16:38:30 -07007577tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7578{
7579 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7580 tListElem *pEntry;
7581 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 //alwasy lock active list before locking pending list
7583 csrLLLock( &pMac->sme.smeCmdActiveList );
7584 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7585 if(pEntry)
7586 {
7587 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7588 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7589 {
7590 fRet = eANI_BOOLEAN_TRUE;
7591 }
7592 }
7593 if(eANI_BOOLEAN_FALSE == fRet)
7594 {
7595 csrLLLock(&pMac->sme.smeCmdPendingList);
7596 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7597 while(pEntry)
7598 {
7599 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7600 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7601 {
7602 fRet = eANI_BOOLEAN_TRUE;
7603 break;
7604 }
7605 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7606 }
7607 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7608 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307609 if (eANI_BOOLEAN_FALSE == fRet)
7610 {
7611 csrLLLock(&pMac->roam.roamCmdPendingList);
7612 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7613 while (pEntry)
7614 {
7615 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7616 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7617 {
7618 fRet = eANI_BOOLEAN_TRUE;
7619 break;
7620 }
7621 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7622 }
7623 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007625 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007626 return (fRet);
7627}
7628
Jeff Johnson295189b2012-06-20 16:38:30 -07007629tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7630{
7631 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7632 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007633 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7634 {
7635 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7636 {
7637 break;
7638 }
7639 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007640 return ( fRet );
7641}
7642
Jeff Johnson295189b2012-06-20 16:38:30 -07007643tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7644{
7645 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007646 //alwasy lock active list before locking pending list
7647 csrLLLock( &pMac->sme.smeCmdActiveList );
7648 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7649 if(eANI_BOOLEAN_FALSE == fRet)
7650 {
7651 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7652 }
7653 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007654 return (fRet);
7655}
7656
Jeff Johnson295189b2012-06-20 16:38:30 -07007657tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7658{
7659 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7660 tListElem *pEntry;
7661 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007662 //alwasy lock active list before locking pending list
7663 csrLLLock( &pMac->sme.smeCmdActiveList );
7664 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7665 if( pEntry )
7666 {
7667 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7668 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7669 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7670 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7671 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7672 {
7673 fRet = eANI_BOOLEAN_TRUE;
7674 }
7675 }
7676 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007677 return (fRet);
7678}
Jeff Johnson295189b2012-06-20 16:38:30 -07007679eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7680{
7681 eHalStatus status = eHAL_STATUS_SUCCESS;
7682 tSmeCmd *pCommand = NULL;
7683 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7684 tANI_BOOLEAN fRemoveCmd = FALSE;
7685 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007686 // Delete the old assoc command. All is setup for reassoc to be serialized
7687 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7688 if ( pEntry )
7689 {
7690 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7691 if ( !pCommand )
7692 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007693 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007694 return eHAL_STATUS_RESOURCES;
7695 }
7696 if ( eSmeCommandRoam == pCommand->command )
7697 {
7698 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7699 {
7700 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7701 }
7702 else
7703 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007704 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007705 }
7706 if (fRemoveCmd == FALSE)
7707 {
7708 // Implies we did not get the serialized assoc command we
7709 // were expecting
7710 pCommand = NULL;
7711 }
7712 }
7713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007714 if(NULL == pCommand)
7715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007716 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007717 return eHAL_STATUS_RESOURCES;
7718 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007719 do
7720 {
7721 //Change the substate in case it is wait-for-key
7722 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7723 {
7724 csrRoamStopWaitForKeyTimer( pMac );
7725 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7726 }
7727 pCommand->command = eSmeCommandRoam;
7728 pCommand->sessionId = (tANI_U8)sessionId;
7729 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007730 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7731 if( !HAL_STATUS_SUCCESS( status ) )
7732 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007733 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007734 csrReleaseCommandRoam( pMac, pCommand );
7735 }
7736 } while( 0 );
7737
Jeff Johnson295189b2012-06-20 16:38:30 -07007738 return( status );
7739}
7740static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7741{
7742 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7743 tCsrScanResult *pScanResult = NULL;
7744 tSirBssDescription *pBssDesc = NULL;
7745 tSmeCmd *pCommand = NULL;
7746 tANI_U32 sessionId;
7747 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007748 if(NULL == pEntry)
7749 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307750 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007751 return;
7752 }
7753 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7754 sessionId = pCommand->sessionId;
7755 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007756
7757 if(!pSession)
7758 {
7759 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7760 return;
7761 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307762 smsLog(pMac, LOG1, FL("CFG return value is %d "
7763 " current state is : %d substate is : %d "),
7764 result, pMac->roam.curState[sessionId],
7765 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007766 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7767 {
7768 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007769 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007770 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7771 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007772 /* If the roaming has stopped, not to continue the roaming command*/
7773 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7774 {
7775 //No need to complete roaming here as it already completes
7776 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7777 pCommand->u.roamCmd.roamReason);
7778 csrSetAbortRoamingCommand( pMac, pCommand );
7779 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7780 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007781 else
7782 {
7783 if ( CCM_IS_RESULT_SUCCESS(result) )
7784 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307785 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007786 // Successfully set the configuration parameters for the new Bss. Attempt to
7787 // join the roaming Bss.
7788 if(pCommand->u.roamCmd.pRoamBssEntry)
7789 {
7790 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7791 pBssDesc = &pScanResult->Result.BssDescriptor;
7792 }
7793 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7794 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007795 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007796 )
7797 {
7798 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7799 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7800 pBssDesc, pCommand->u.roamCmd.roamId )))
7801 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307802 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007803 //We need to complete the command
7804 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7805 }
7806 }
7807 else
7808 {
7809 if (!pCommand->u.roamCmd.pRoamBssEntry)
7810 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307811 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007812 //We need to complete the command
7813 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7814 return;
7815 }
7816 // If we are roaming TO an Infrastructure BSS...
7817 VOS_ASSERT(pScanResult != NULL);
7818 if ( csrIsInfraBssDesc( pBssDesc ) )
7819 {
7820 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307821 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007822 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7823 {
7824 // ..and currently in an Infrastructure connection....
7825 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7826 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307827 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007828 // ...and the SSIDs are equal, then we Reassoc.
7829 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7830 pIesLocal ) )
7831 // ..and currently in an infrastructure connection
7832 {
7833 // then issue a Reassoc.
7834 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7835 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7836 &pCommand->u.roamCmd.roamProfile );
7837 }
7838 else
7839 {
7840
7841 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7842 // previously associated AP.
7843 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7844 pIesLocal,
7845 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7846 {
7847 //try something else
7848 csrRoam( pMac, pCommand );
7849 }
7850 }
7851 }
7852 else
7853 {
7854 eHalStatus status = eHAL_STATUS_SUCCESS;
7855
7856 /* We need to come with other way to figure out that this is because of HO in BMP
7857 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007858 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007859 * use join request */
7860#ifdef WLAN_FEATURE_VOWIFI_11R
7861 if (csrRoamIsHandoffInProgress(pMac) &&
7862 csrRoamIs11rAssoc(pMac))
7863 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307864 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007865 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7866 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7867 }
7868 else
7869#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007870#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007871 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007872 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307874 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007875 // Now serialize the reassoc command.
7876 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7877 }
7878 else
7879#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007880#ifdef FEATURE_WLAN_LFR
7881 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307882 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007883 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307884 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007885 // Now serialize the reassoc command.
7886 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7887 }
7888 else
7889#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007890 // else we are not connected and attempting to Join. Issue the
7891 // Join request.
7892 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307893 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07007894 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7895 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7896 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7897 }
7898 if(!HAL_STATUS_SUCCESS(status))
7899 {
7900 //try something else
7901 csrRoam( pMac, pCommand );
7902 }
7903 }
7904 if( !pScanResult->Result.pvIes )
7905 {
7906 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307907 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007908 }
7909 }
7910 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7911 else
7912 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007913 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007914 }
7915 }//else
7916 }//if ( WNI_CFG_SUCCESS == result )
7917 else
7918 {
7919 // In the event the configuration failed, for infra let the roam processor
7920 //attempt to join something else...
7921 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7922 {
7923 csrRoam(pMac, pCommand);
7924 }
7925 else
7926 {
7927 //We need to complete the command
7928 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7929 {
7930 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7931 }
7932 else
7933 {
7934 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7935 }
7936 }
7937 }
7938 }//we have active entry
7939}
7940
Jeff Johnson295189b2012-06-20 16:38:30 -07007941static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7942{
7943 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007944 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007945 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7946 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007947 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007948 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7949 // join the new one...
7950 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007951 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7952 }
7953 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007954 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007955 /***profHandleLostLinkAfterReset(pAdapter);
7956 // In the event the authenticate fails, let the roam processor attempt to join something else...
7957 roamRoam( pAdapter );***/
7958 }
7959}
7960
Jeff Johnson295189b2012-06-20 16:38:30 -07007961static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7962{
7963 eCsrRoamCompleteResult result;
7964 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7965 tCsrRoamInfo roamInfo;
7966 tANI_U32 roamId = 0;
7967
7968 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7969 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007970 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007971 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007972 /* Defeaturize this part later if needed */
7973#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7974 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7975 * we need the response contents while processing the result in csrRoamProcessResults() */
7976 if (csrRoamIsHandoffInProgress(pMac))
7977 {
7978 /* Need to dig more on indicating events to SME QoS module */
7979 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7980 csrRoamComplete( pMac, result, pSmeJoinRsp);
7981 }
7982 else
7983#endif
7984 {
7985 csrRoamComplete( pMac, result, NULL );
7986 }
7987 }
7988 /* Should we handle this similar to handling the join failure? Is it ok
7989 * to call csrRoamComplete() with state as CsrJoinFailure */
7990 else
7991 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007992 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 result = eCsrReassocFailure;
7994#ifdef WLAN_FEATURE_VOWIFI_11R
7995 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05307996 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
7997 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07007998 {
7999 // Inform HDD to turn off FT flag in HDD
8000 if (pNeighborRoamInfo)
8001 {
8002 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8003 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8004 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008005 /*
8006 * Since the above callback sends a disconnect
8007 * to HDD, we should clean-up our state
8008 * machine as well to be in sync with the upper
8009 * layers. There is no need to send a disassoc
8010 * since: 1) we will never reassoc to the current
8011 * AP in LFR, and 2) there is no need to issue a
8012 * disassoc to the AP with which we were trying
8013 * to reassoc.
8014 */
8015 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8016 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 }
8018 }
8019#endif
8020 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8021 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8022 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8023 //The disassoc rsp message will remove the command from active list
8024 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8025 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8026 {
8027 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8028 }
8029 }
8030}
8031
Jeff Johnson295189b2012-06-20 16:38:30 -07008032static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8033{
Jeff Johnson295189b2012-06-20 16:38:30 -07008034#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8035 {
8036 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008037 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8038 if(pIbssLog)
8039 {
8040 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8041 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8042 {
8043 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8044 }
8045 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8046 }
8047 }
8048#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008049 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8050 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8051 {
8052 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8053 }
8054 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8055 {
8056 csrRoamReissueRoamCommand(pMac);
8057 }
8058}
8059
Jeff Johnson295189b2012-06-20 16:38:30 -07008060void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8061{
8062 tSirResultCodes statusCode;
8063#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8064 tScanResultHandle hBSSList;
8065 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8066 eHalStatus status;
8067 tCsrRoamInfo roamInfo;
8068 tCsrScanResultFilter *pScanFilter = NULL;
8069 tANI_U32 roamId = 0;
8070 tCsrRoamProfile *pCurRoamProfile = NULL;
8071 tListElem *pEntry = NULL;
8072 tSmeCmd *pCommand = NULL;
8073#endif
8074 tANI_U32 sessionId;
8075 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07008076
Jeff Johnson295189b2012-06-20 16:38:30 -07008077 tSirSmeDisassocRsp SmeDisassocRsp;
8078
8079 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8080 sessionId = SmeDisassocRsp.sessionId;
8081 statusCode = SmeDisassocRsp.statusCode;
8082
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008083 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008084
8085 if ( csrIsConnStateInfra( pMac, sessionId ) )
8086 {
8087 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8088 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008090
8091 if(!pSession)
8092 {
8093 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8094 return;
8095 }
8096
Jeff Johnson295189b2012-06-20 16:38:30 -07008097 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8098 {
8099 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8100 }
8101 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8102 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8103 {
8104 if ( eSIR_SME_SUCCESS == statusCode )
8105 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008106 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008107 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8108 }
8109 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008111 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8112 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308113 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8114 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008115#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008116 /*
8117 * First ensure if the roam profile is in the scan cache.
8118 * If not, post a reassoc failure and disconnect.
8119 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308120 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8121 if ( NULL == pScanFilter )
8122 status = eHAL_STATUS_FAILURE;
8123 else
8124 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008125 if(HAL_STATUS_SUCCESS(status))
8126 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308127 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008128 status = csrRoamPrepareFilterFromProfile(pMac,
8129 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8130 if(!HAL_STATUS_SUCCESS(status))
8131 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008132 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008133 __func__, status);
8134 goto POST_ROAM_FAILURE;
8135 }
8136 else
8137 {
8138 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8139 if (!HAL_STATUS_SUCCESS(status))
8140 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008141 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008142 __func__, status);
8143 goto POST_ROAM_FAILURE;
8144 }
8145 }
8146 }
8147 else
8148 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008149 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008150 __func__, status);
8151 goto POST_ROAM_FAILURE;
8152 }
8153
8154 /*
8155 * After ensuring that the roam profile is in the scan result list,
8156 * dequeue the command from the active list.
8157 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008158 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8159 if ( pEntry )
8160 {
8161 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008162 /* If the head of the queue is Active and it is a ROAM command, remove
8163 * and put this on the Free queue.
8164 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008165 if ( eSmeCommandRoam == pCommand->command )
8166 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008167
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008168 /*
8169 * we need to process the result first before removing it from active list
8170 * because state changes still happening insides roamQProcessRoamResults so
8171 * no other roam command should be issued.
8172 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8174 if(pCommand->u.roamCmd.fReleaseProfile)
8175 {
8176 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8177 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008179 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008180 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008181 else
8182 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008183 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008184 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008185 }
8186 }
8187 else
8188 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008189 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008190 }
8191 }
8192 else
8193 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008194 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008195 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008196
8197 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008198 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8199
Kiet Lam64c1b492013-07-12 13:56:44 +05308200 vos_mem_copy(roamInfo.bssid,
8201 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8202 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008203
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008204 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8205 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008206
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008207 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308208 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8209 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008210 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308211 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008212 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8213 //make sure to put it at the head of the cmd queue
8214 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8215 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8216 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8217
Jeff Johnson295189b2012-06-20 16:38:30 -07008218 if(!HAL_STATUS_SUCCESS(status))
8219 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008220 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008221 __func__, status);
8222 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008223 }
8224
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008225 /* Notify sub-modules like QoS etc. that handoff happening */
8226 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008227 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308228 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008229 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308230 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008231 return;
8232 }
8233
8234POST_ROAM_FAILURE:
8235 if (pScanFilter)
8236 {
8237 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308238 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008239 }
8240 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308241 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008242
8243 /* Inform the upper layers that the reassoc failed */
8244 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8245 csrRoamCallCallback(pMac, sessionId,
8246 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8247
8248 /*
8249 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8250 * Upon success, we would re-enter this routine after receiving the disassoc
8251 * response and will fall into the reassoc fail sub-state. And, eventually
8252 * call csrRoamComplete which would remove the roam command from SME active
8253 * queue.
8254 */
8255 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8256 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8257 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008258 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008259 __func__, status);
8260 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008262#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008263
Jeff Johnson295189b2012-06-20 16:38:30 -07008264 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8265 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8266 {
8267 // Disassoc due to Reassoc failure falls into this codepath....
8268 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8269 }
8270 else
8271 {
8272 if ( eSIR_SME_SUCCESS == statusCode )
8273 {
8274 // Successfully disassociated from the 'old' Bss...
8275 //
8276 // We get Disassociate response in three conditions.
8277 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8278 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8279 // Infrastructure network.
8280 // - Third is where we are doing an Infra to Infra roam between networks with different
8281 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8282
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008283 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008284 }
8285 else
8286 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008287 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008288 }
8289 //We are not done yet. Get the data and continue roaming
8290 csrRoamReissueRoamCommand(pMac);
8291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008292}
8293
Jeff Johnson295189b2012-06-20 16:38:30 -07008294static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8295{
8296 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008297 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008298 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008299 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008300 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008301 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8302 {
8303 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8304 }
8305 else
8306 {
8307 if ( eSIR_SME_SUCCESS == statusCode )
8308 {
8309 // Successfully deauth from the 'old' Bss...
8310 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008311 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 }
8313 else
8314 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008315 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008316 }
8317 //We are not done yet. Get the data and continue roaming
8318 csrRoamReissueRoamCommand(pMac);
8319 }
8320}
8321
Jeff Johnson295189b2012-06-20 16:38:30 -07008322static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8323{
8324 eCsrRoamCompleteResult result;
8325
8326 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8327 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008328 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008329 result = eCsrStartBssSuccess;
8330 }
8331 else
8332 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008333 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008334 //Let csrRoamComplete decide what to do
8335 result = eCsrStartBssFailure;
8336 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008337 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008338}
8339
Jeff Johnson295189b2012-06-20 16:38:30 -07008340/*
8341 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8342 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8343 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8344 For the messages where sender allocates memory for specific structures, then it can be
8345 cast accordingly.
8346*/
8347void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8348{
8349 tSirSmeRsp *pSmeRsp;
8350 tSmeIbssPeerInd *pIbssPeerInd;
8351 tCsrRoamInfo roamInfo;
8352 // TODO Session Id need to be acquired in this function
8353 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008354 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308355 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8356 pSmeRsp->messageType, pSmeRsp->messageType,
8357 macTraceGetcsrRoamSubState(
8358 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008359 pSmeRsp->messageType = (pSmeRsp->messageType);
8360 pSmeRsp->length = (pSmeRsp->length);
8361 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 switch (pSmeRsp->messageType)
8363 {
8364
8365 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8366 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8367 {
8368 //We sent a JOIN_REQ
8369 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8370 }
8371 break;
8372
8373 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8374 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8375 {
8376 //We sent a AUTH_REQ
8377 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8378 }
8379 break;
8380
8381 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8382 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8383 {
8384 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8385 }
8386 break;
8387
8388 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8389 {
8390 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8391 }
8392 break;
8393
8394 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8395 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8396 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8397 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8398 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8399 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8400//HO
8401 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8402 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308403 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8404 macTraceGetcsrRoamSubState(
8405 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008406 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05308407#ifdef DEBUG_ROAM_DELAY
8408 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8409#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008410 }
8411 break;
8412
8413 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8414 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8415 {
8416 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8417 }
8418 break;
8419
8420 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8421 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8422 {
8423 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8424 }
8425 break;
8426
8427 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8428 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8429 {
8430 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008432 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008433 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8434 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8435 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008436 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308437 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8438 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8440 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308441 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8442 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008443 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8444 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8445 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8446 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008447 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308448 smsLog(pMac, LOG1,
8449 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8450 pSmeRsp->messageType, pSmeRsp->messageType,
8451 macTraceGetcsrRoamSubState(
8452 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008453
8454 //If we are connected, check the link status change
8455 if(!csrIsConnStateDisconnected(pMac, sessionId))
8456 {
8457 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8458 }
8459 break;
8460 }
8461}
8462
Jeff Johnson295189b2012-06-20 16:38:30 -07008463void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8464{
8465 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008466 switch (pSirMsg->messageType)
8467 {
8468 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008469 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 csrRoamStatsRspProcessor( pMac, pSirMsg );
8471 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008472 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8473 {
8474 tCsrRoamSession *pSession;
8475 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8476 tCsrRoamInfo roamInfo;
8477 tCsrRoamInfo *pRoamInfo = NULL;
8478 tANI_U32 sessionId;
8479 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008480 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308481 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008483 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8484 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8485 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008486
8487 if(!pSession)
8488 {
8489 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8490 return;
8491 }
8492
Jeff Johnson295189b2012-06-20 16:38:30 -07008493 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8494 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008495 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8496 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8497 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008498 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8499 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308500 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8501 sizeof(tSirMacAddr));
8502 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8503 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008504 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8506 {
8507 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8508 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8509 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8510 }
8511 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8512 {
8513 vos_sleep( 100 );
8514 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8515 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8516 }
8517
Jeff Johnson295189b2012-06-20 16:38:30 -07008518 }
8519 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008520 default:
8521 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8522 break;
8523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008524}
8525
Jeff Johnson295189b2012-06-20 16:38:30 -07008526eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8527 tSirBssDescription *pBssDescription,
8528 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8529 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8530 tANI_U8 keyId, tANI_U16 keyLength,
8531 tANI_U8 *pKey, tANI_U8 paeRole )
8532{
8533 eHalStatus status = eHAL_STATUS_SUCCESS;
8534 tAniEdType edType;
8535
8536 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8537 {
8538 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8539 }
8540
8541 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8542
8543 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8544 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8545 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8546 addKey )
8547 {
8548 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008549 setKey.encType = EncryptType;
8550 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308551 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008552 setKey.paeRole = paeRole; //0 for supplicant
8553 setKey.keyId = keyId; // Kye index
8554 setKey.keyLength = keyLength;
8555 if( keyLength )
8556 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308557 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008558 }
8559 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008561 return (status);
8562}
8563
Jeff Johnson295189b2012-06-20 16:38:30 -07008564static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8565 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8566{
8567 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8568 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008569#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008570 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008571#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008572
8573 do
8574 {
8575 pCommand = csrGetCommandBuffer(pMac);
8576 if(NULL == pCommand)
8577 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008578 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008579 status = eHAL_STATUS_RESOURCES;
8580 break;
8581 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05308582 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07008583 pCommand->command = eSmeCommandSetKey;
8584 pCommand->sessionId = (tANI_U8)sessionId;
8585 // validate the key length, Adjust if too long...
8586 // for static WEP the keys are not set thru' SetContextReq
8587 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8588 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8589 {
8590 //KeyLength maybe 0 for static WEP
8591 if( pSetKey->keyLength )
8592 {
8593 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8594 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008595 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008596 break;
8597 }
8598
8599 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308600 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8601 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008602 }
8603 }
8604 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8605 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8606 {
8607 //KeyLength maybe 0 for static WEP
8608 if( pSetKey->keyLength )
8609 {
8610 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8611 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008612 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008613 break;
8614 }
8615
8616 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308617 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8618 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008619 }
8620 }
8621 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8622 {
8623 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8624 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008625 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008626 break;
8627 }
8628 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308629 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8630 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008631 }
8632 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8633 {
8634 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8635 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008636 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008637 break;
8638 }
8639 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308640 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8641 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008642 }
8643#ifdef FEATURE_WLAN_WAPI
8644 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8645 {
8646 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8647 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008648 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008649 break;
8650 }
8651 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308652 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8653 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008654 }
8655#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008656#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008657 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8658 {
8659 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8660 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008661 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008662 break;
8663 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008664 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308665 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008666 pSession->eseCckmInfo.reassoc_req_num=1;
8667 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008668 status = eHAL_STATUS_SUCCESS;
8669 break;
8670 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008671#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008672
Jeff Johnson295189b2012-06-20 16:38:30 -07008673#ifdef WLAN_FEATURE_11W
8674 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008675 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008676 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008677 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008678 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008679 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008680 break;
8681 }
8682 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308683 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008684 }
8685#endif
8686 status = eHAL_STATUS_SUCCESS;
8687 pCommand->u.setKeyCmd.roamId = roamId;
8688 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8689 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308690 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8691 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008692 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8693 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308694 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008695 //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
8696
8697 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8698 if( !HAL_STATUS_SUCCESS( status ) )
8699 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008700 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008701 }
8702 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008703 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008704 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008705 if ( ( NULL != pCommand ) &&
8706 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008707#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008708 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008709#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008710 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008711 {
8712 csrReleaseCommandSetKey( pMac, pCommand );
8713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008714 return( status );
8715}
8716
Jeff Johnson295189b2012-06-20 16:38:30 -07008717eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8718 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8719{
8720 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8721 tSmeCmd *pCommand = NULL;
8722 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008723 do
8724 {
8725 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8726 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008727 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008728 status = eHAL_STATUS_CSR_WRONG_STATE;
8729 break;
8730 }
8731 pCommand = csrGetCommandBuffer(pMac);
8732 if(NULL == pCommand)
8733 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008734 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008735 status = eHAL_STATUS_RESOURCES;
8736 break;
8737 }
8738 pCommand->command = eSmeCommandRemoveKey;
8739 pCommand->sessionId = (tANI_U8)sessionId;
8740 pCommand->u.removeKeyCmd.roamId = roamId;
8741 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308742 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8743 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008744 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8745 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8746 {
8747 //in this case, put it to the end of the Q incase there is a set key pending.
8748 fImediate = eANI_BOOLEAN_FALSE;
8749 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008750 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008751 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008752 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008753 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8754 if( !HAL_STATUS_SUCCESS( status ) )
8755 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008756 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008757 break;
8758 }
8759 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008760 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8761 {
8762 csrReleaseCommandRemoveKey( pMac, pCommand );
8763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008764 return (status );
8765}
8766
Jeff Johnson295189b2012-06-20 16:38:30 -07008767eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8768{
8769 eHalStatus status;
8770 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8771 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8772 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8773 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008774#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8775 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8776 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308777 if(!pSession)
8778 {
8779 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8780 return eHAL_STATUS_FAILURE;
8781 }
lukez3c809222013-05-03 10:23:02 -07008782 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008783 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308784 vos_mem_set(&setKeyEvent,
8785 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8787 {
8788 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8789 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8790 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8791 }
8792 else
8793 {
8794 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8795 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8796 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8797 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308798 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008799 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008800 {
8801 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008802 //It has to be static WEP here
8803 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8804 {
8805 setKeyEvent.keyId = (v_U8_t)defKeyId;
8806 }
8807 }
8808 else
8809 {
8810 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8811 }
8812 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8813 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8814 }
8815#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008816 if( csrIsSetKeyAllowed(pMac, sessionId) )
8817 {
8818 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8819 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8820 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8821 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8822 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8823 pCommand->u.setKeyCmd.keyRsc);
8824 }
8825 else
8826 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008827 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008828 //Set this status so the error handling take care of the case.
8829 status = eHAL_STATUS_CSR_WRONG_STATE;
8830 }
8831 if( !HAL_STATUS_SUCCESS(status) )
8832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008833 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008834 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008835#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008836 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008837 {
8838 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8839 {
8840 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8841 }
8842 else
8843 {
8844 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8845 }
8846 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8847 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8848 }
8849#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008850 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008851 return ( status );
8852}
8853
Jeff Johnson295189b2012-06-20 16:38:30 -07008854eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8855{
8856 eHalStatus status;
8857 tpSirSmeRemoveKeyReq pMsg = NULL;
8858 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8859 tANI_U8 *p;
8860 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008861#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8862 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8863 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308864 if(!pSession)
8865 {
8866 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8867 return eHAL_STATUS_FAILURE;
8868 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308869 vos_mem_set(&removeKeyEvent,
8870 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008871 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8872 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8873 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308874 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008875 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8876 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8877 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8878#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 if( csrIsSetKeyAllowed(pMac, sessionId) )
8880 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308881 pMsg = vos_mem_malloc(wMsgLen);
8882 if ( NULL == pMsg )
8883 status = eHAL_STATUS_FAILURE;
8884 else
8885 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008886 }
8887 else
8888 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008889 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008890 //Set the error status so error handling kicks in below
8891 status = eHAL_STATUS_CSR_WRONG_STATE;
8892 }
8893 if( HAL_STATUS_SUCCESS( status ) )
8894 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308895 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8897 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008898 pMsg->sessionId = (tANI_U8)sessionId;
8899 pMsg->transactionId = 0;
8900 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8901 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8902 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308903 vos_mem_copy(p,
8904 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8905 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008906 p += sizeof(tSirMacAddr);
8907 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308908 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008909 p += sizeof(tSirMacAddr);
8910 // edType
8911 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8912 p++;
8913 // weptype
8914 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8915 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8916 {
8917 *p = (tANI_U8)eSIR_WEP_STATIC;
8918 }
8919 else
8920 {
8921 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8922 }
8923 p++;
8924 //keyid
8925 *p = pCommand->u.removeKeyCmd.keyId;
8926 p++;
8927 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008928 status = palSendMBMessage(pMac->hHdd, pMsg);
8929 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 if( !HAL_STATUS_SUCCESS( status ) )
8931 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008932 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008933#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8934 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008935 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008936 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8937#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008938 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8939 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008940 return ( status );
8941}
8942
Jeff Johnson295189b2012-06-20 16:38:30 -07008943eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8944{
8945 eHalStatus status;
8946
8947 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8948 {
8949 status = eHAL_STATUS_CSR_WRONG_STATE;
8950 }
8951 else
8952 {
8953 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008955 return ( status );
8956}
8957
Jeff Johnson295189b2012-06-20 16:38:30 -07008958/*
8959 Prepare a filter base on a profile for parsing the scan results.
8960 Upon successful return, caller MUST call csrFreeScanFilter on
8961 pScanFilter when it is done with the filter.
8962*/
8963eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8964 tCsrScanResultFilter *pScanFilter)
8965{
8966 eHalStatus status = eHAL_STATUS_SUCCESS;
8967 tANI_U32 size = 0;
8968 tANI_U8 index = 0;
8969
8970 do
8971 {
8972 if(pProfile->BSSIDs.numOfBSSIDs)
8973 {
8974 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308975 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8976 if ( NULL == pScanFilter->BSSIDs.bssid )
8977 status = eHAL_STATUS_FAILURE;
8978 else
8979 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008980 if(!HAL_STATUS_SUCCESS(status))
8981 {
8982 break;
8983 }
8984 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308985 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008986 }
8987 if(pProfile->SSIDs.numOfSSIDs)
8988 {
8989 if( !CSR_IS_WDS_STA( pProfile ) )
8990 {
8991 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8992 }
8993 else
8994 {
8995 //For WDS station
8996 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8997 pScanFilter->SSIDs.numOfSSIDs = 1;
8998 }
8999 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309000 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9001 if ( NULL == pScanFilter->SSIDs.SSIDList )
9002 status = eHAL_STATUS_FAILURE;
9003 else
9004 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009005 if(!HAL_STATUS_SUCCESS(status))
9006 {
9007 break;
9008 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309009 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9010 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009011 }
9012 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9013 {
9014 pScanFilter->ChannelInfo.numOfChannels = 0;
9015 pScanFilter->ChannelInfo.ChannelList = NULL;
9016 }
9017 else if(pProfile->ChannelInfo.numOfChannels)
9018 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309019 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9020 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9021 pProfile->ChannelInfo.numOfChannels);
9022 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9023 status = eHAL_STATUS_FAILURE;
9024 else
9025 status = eHAL_STATUS_SUCCESS;
9026
Jeff Johnson295189b2012-06-20 16:38:30 -07009027 pScanFilter->ChannelInfo.numOfChannels = 0;
9028 if(HAL_STATUS_SUCCESS(status))
9029 {
9030 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9031 {
9032 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9033 {
9034 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9035 = pProfile->ChannelInfo.ChannelList[index];
9036 pScanFilter->ChannelInfo.numOfChannels++;
9037 }
9038 else
9039 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009040 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009042 }
9043 }
9044 else
9045 {
9046 break;
9047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009048 }
9049 else
9050 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309051 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009052 status = eHAL_STATUS_FAILURE;
9053 break;
9054 }
9055 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
9056 pScanFilter->authType = pProfile->AuthType;
9057 pScanFilter->EncryptionType = pProfile->EncryptionType;
9058 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9059 pScanFilter->BSSType = pProfile->BSSType;
9060 pScanFilter->phyMode = pProfile->phyMode;
9061#ifdef FEATURE_WLAN_WAPI
9062 //check if user asked for WAPI with 11n or auto mode, in that case modify
9063 //the phymode to 11g
9064 if(csrIsProfileWapi(pProfile))
9065 {
9066 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9067 {
9068 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9069 }
9070 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9071 {
9072 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9073 }
9074 if(!pScanFilter->phyMode)
9075 {
9076 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9077 }
9078 }
9079#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009080 /*Save the WPS info*/
9081 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009082 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009083 if( pProfile->countryCode[0] )
9084 {
9085 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309086 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9087 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009088 }
9089#ifdef WLAN_FEATURE_VOWIFI_11R
9090 if (pProfile->MDID.mdiePresent)
9091 {
9092 pScanFilter->MDID.mdiePresent = 1;
9093 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9094 }
9095#endif
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309096
9097#ifdef WLAN_FEATURE_11W
9098 // Management Frame Protection
9099 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9100 pScanFilter->MFPRequired = pProfile->MFPRequired;
9101 pScanFilter->MFPCapable = pProfile->MFPCapable;
9102#endif
9103
Jeff Johnson295189b2012-06-20 16:38:30 -07009104 }while(0);
9105
9106 if(!HAL_STATUS_SUCCESS(status))
9107 {
9108 csrFreeScanFilter(pMac, pScanFilter);
9109 }
9110
9111 return(status);
9112}
9113
Jeff Johnson295189b2012-06-20 16:38:30 -07009114tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9115 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9116{
9117 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9118 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009119 do
9120 {
9121 // Validate the type is ok...
9122 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9123 pCommand = csrGetCommandBuffer( pMac );
9124 if ( !pCommand )
9125 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009126 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009127 break;
9128 }
9129 //Change the substate in case it is waiting for key
9130 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9131 {
9132 csrRoamStopWaitForKeyTimer( pMac );
9133 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9134 }
9135 pCommand->command = eSmeCommandWmStatusChange;
9136 pCommand->sessionId = (tANI_U8)sessionId;
9137 pCommand->u.wmStatusChangeCmd.Type = Type;
9138 if ( eCsrDisassociated == Type )
9139 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309140 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9141 pSmeRsp,
9142 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009143 }
9144 else
9145 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309146 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9147 pSmeRsp,
9148 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009149 }
9150 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9151 {
9152 fCommandQueued = eANI_BOOLEAN_TRUE;
9153 }
9154 else
9155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009156 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009157 csrReleaseCommandWmStatusChange( pMac, pCommand );
9158 }
9159
Jeff Johnson295189b2012-06-20 16:38:30 -07009160 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9161 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009162 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009163 return( fCommandQueued );
9164}
9165
Jeff Johnson295189b2012-06-20 16:38:30 -07009166static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9167{
9168 v_S7_t rssi = 0;
9169 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9170 if(pGetRssiReq)
9171 {
9172 if(NULL != pGetRssiReq->pVosContext)
9173 {
9174 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9175 }
9176 else
9177 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009178 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009179 return;
9180 }
9181
9182 if(NULL != pGetRssiReq->rssiCallback)
9183 {
9184 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9185 }
9186 else
9187 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009188 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009189 return;
9190 }
9191 }
9192 else
9193 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009194 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009195 }
9196 return;
9197}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309198
9199static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9200{
9201 tANI_S8 snr = 0;
9202 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9203
9204 if (pGetSnrReq)
9205 {
9206 if (VOS_STATUS_SUCCESS !=
9207 WDA_GetSnr(pGetSnrReq->staId, &snr))
9208 {
9209 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9210 return;
9211 }
9212
9213 if (pGetSnrReq->snrCallback)
9214 {
9215 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9216 pGetSnrReq->pDevContext);
9217 }
9218 else
9219 {
9220 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9221 return;
9222 }
9223 }
9224 else
9225 {
9226 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9227 }
9228 return;
9229}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009230#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009231void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9232{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009233 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9234
Jeff Johnson36d483b2013-04-08 11:08:53 -07009235 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009236 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009237 /* Get roam Rssi request is backed up and passed back to the response,
9238 Extract the request message to fetch callback */
9239 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9240 v_S7_t rssi = pRoamRssiRsp->rssi;
9241
9242 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009243 {
9244 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9245 reqBkp->rssiCallback = NULL;
9246 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009247 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009248 }
9249 else
9250 {
9251 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9252 if (NULL != reqBkp)
9253 {
9254 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009255 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009256 }
9257 }
9258 }
9259 else
9260 {
9261 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9262 }
9263 return;
9264}
9265#endif
9266
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009267
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009268#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009269void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9270{
9271 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9272
9273 if (NULL != pTsmStatsRsp)
9274 {
9275 /* Get roam Rssi request is backed up and passed back to the response,
9276 Extract the request message to fetch callback */
9277 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9278
9279 if (NULL != reqBkp)
9280 {
9281 if (NULL != reqBkp->tsmStatsCallback)
9282 {
9283 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9284 pTsmStatsRsp->staId, reqBkp->pDevContext);
9285 reqBkp->tsmStatsCallback = NULL;
9286 }
9287 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009288 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009289 }
9290 else
9291 {
9292 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9293 if (NULL != reqBkp)
9294 {
9295 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009296 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009297 }
9298 }
9299 }
9300 else
9301 {
9302 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9303 }
9304 return;
9305}
9306
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009307void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009308{
9309 tANI_U32 roamTS2 = 0;
9310 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009311 tpPESession pSessionEntry = NULL;
9312 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009313
9314 if (NULL == pSession)
9315 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009316 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009317 return;
9318 }
9319
9320 roamTS2 = vos_timer_get_system_time();
9321 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009322 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9323 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009324 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009325
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009326 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9327 if (NULL == pSessionEntry)
9328 {
9329 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9330 return;
9331 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009332 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009333 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009334 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009335}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009336#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009337
Jeff Johnsone7245742012-09-05 17:12:55 -07009338static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9339{
9340 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9341 if(pTlRssiInd)
9342 {
9343 if(NULL != pTlRssiInd->tlCallback)
9344 {
9345 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009346 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009347 }
9348 else
9349 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009350 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009351 }
9352 }
9353 else
9354 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009355 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009356 }
9357 return;
9358}
Jeff Johnson295189b2012-06-20 16:38:30 -07009359
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309360eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9361{
9362 tpSirResetAPCapsChange pMsg;
9363 tANI_U16 len;
9364 eHalStatus status = eHAL_STATUS_SUCCESS;
9365
9366 /* Create the message and send to lim */
9367 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309368 pMsg = vos_mem_malloc(len);
9369 if ( NULL == pMsg )
9370 status = eHAL_STATUS_FAILURE;
9371 else
9372 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309373 if (HAL_STATUS_SUCCESS(status))
9374 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309375 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309376 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9377 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309378 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009379 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9380 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309381 status = palSendMBMessage(pMac->hHdd, pMsg);
9382 }
9383 else
9384 {
9385 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9386 }
9387 return status;
9388}
9389
Jeff Johnson295189b2012-06-20 16:38:30 -07009390void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9391{
9392 tSirSmeAssocInd *pAssocInd;
9393 tSirSmeDisassocInd *pDisassocInd;
9394 tSirSmeDeauthInd *pDeauthInd;
9395 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9396 tSirSmeNewBssInfo *pNewBss;
9397 tSmeIbssPeerInd *pIbssPeerInd;
9398 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9399 tSirSmeApNewCaps *pApNewCaps;
9400 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9401 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9402 tCsrRoamInfo *pRoamInfo = NULL;
9403 tCsrRoamInfo roamInfo;
9404 eHalStatus status;
9405 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9406 tCsrRoamSession *pSession = NULL;
9407 tpSirSmeSwitchChannelInd pSwitchChnInd;
9408 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309409 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009410
9411
9412 if (NULL == pSirMsg)
9413 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9414 return;
9415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009416 switch( pSirMsg->messageType )
9417 {
9418 case eWNI_SME_ASSOC_IND:
9419 {
9420 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009421 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009422 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9423 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9424 if( HAL_STATUS_SUCCESS( status ) )
9425 {
9426 pSession = CSR_GET_SESSION(pMac, sessionId);
9427
Jeff Johnson32d95a32012-09-10 13:15:23 -07009428 if(!pSession)
9429 {
9430 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9431 return;
9432 }
9433
Jeff Johnson295189b2012-06-20 16:38:30 -07009434 pRoamInfo = &roamInfo;
9435
9436 // Required for indicating the frames to upper layer
9437 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9438 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9439
9440 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9441 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9442 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9443 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9444
9445 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9446 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9447 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9448
9449 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9450 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309451 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9452 sizeof(tSirMacAddr));
9453 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9454 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009455 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9456 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009457 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009458 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9459 {
9460 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9461 {
9462 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9463 pSession->pConnectBssDesc,
9464 &(pRoamInfo->peerMac),
9465 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9466 pRoamInfo->fAuthRequired = FALSE;
9467 }
9468 else
9469 {
9470 pRoamInfo->fAuthRequired = TRUE;
9471 }
9472 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9473 if (!HAL_STATUS_SUCCESS(status))
9474 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009476 /* Send Association completion message to PE */
9477 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9478
9479 /* send a message to CSR itself just to avoid the EAPOL frames going
9480 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009481 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9482 {
9483 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9484 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9486 {
9487 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9488 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9489 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009491 }
9492 }
9493 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009494 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009495 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309496 // Check if AP dis-associated us because of MIC failure. If so,
9497 // then we need to take action immediately and not wait till the
9498 // the WmStatusChange requests is pushed and processed
9499 tSmeCmd *pCommand;
9500
9501 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9502 status = csrRoamGetSessionIdFromBSSID( pMac,
9503 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9504 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009505 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309506 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9507 " for session %d "), sessionId);
9508 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9509 MAC_ADDRESS_STR " "
9510 " reason = %d status = %d "),
9511 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9512 pDisassocInd->reasonCode,
9513 pDisassocInd->statusCode);
9514 // If we are in neighbor preauth done state then on receiving
9515 // disassoc or deauth we dont roam instead we just disassoc
9516 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009517 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309518#ifdef WLAN_FEATURE_VOWIFI_11R
9519 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9520 {
9521 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009523#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009524#ifdef FEATURE_WLAN_ESE
9525 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309526 {
9527 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009529#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009530#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309531 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9532 {
9533 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9534 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009535#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309536 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009537
Agarwal Ashish4f616132013-12-30 23:32:50 +05309538 if (!pSession)
9539 {
9540 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9541 return;
9542 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009543
Agarwal Ashish4f616132013-12-30 23:32:50 +05309544 if ( csrIsConnStateInfra( pMac, sessionId ) )
9545 {
9546 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009548#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309549 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009550#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309551 csrRoamLinkDown(pMac, sessionId);
9552 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9553 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9554 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309555 pRoamInfo = &roamInfo;
9556 pRoamInfo->statusCode = pDisassocInd->statusCode;
9557 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9558 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009559
Agarwal Ashish4f616132013-12-30 23:32:50 +05309560 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9561 sizeof(tSirMacAddr));
9562 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9563 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009564
Agarwal Ashish4f616132013-12-30 23:32:50 +05309565 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9566 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009567
Agarwal Ashish4f616132013-12-30 23:32:50 +05309568 /*
9569 * STA/P2P client got disassociated so remove any pending deauth
9570 * commands in sme pending list
9571 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309572 pCommand = csrGetCommandBuffer(pMac);
9573 if (NULL == pCommand)
9574 {
9575 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9576 status = eHAL_STATUS_RESOURCES;
9577 return;
9578 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309579 pCommand->command = eSmeCommandRoam;
9580 pCommand->sessionId = (tANI_U8)sessionId;
9581 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9582 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9583 pDisassocInd->peerMacAddr,
9584 sizeof(tSirMacAddr));
9585 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9586 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009587
Agarwal Ashish4f616132013-12-30 23:32:50 +05309588 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009589 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309590 else
9591 {
9592 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9593 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9594 }
Kiet Lam82004c62013-11-11 13:24:28 +05309595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009596 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009598 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009599 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9600 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9601 if( HAL_STATUS_SUCCESS( status ) )
9602 {
9603 // If we are in neighbor preauth done state then on receiving
9604 // disassoc or deauth we dont roam instead we just disassoc
9605 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009606 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009607#ifdef WLAN_FEATURE_VOWIFI_11R
9608 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9609 {
9610 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9611 }
9612#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009613#ifdef FEATURE_WLAN_ESE
9614 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009615 {
9616 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9617 }
9618#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009619#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309620 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009621 {
9622 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9623 }
9624#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009625 pSession = CSR_GET_SESSION( pMac, sessionId );
9626
Jeff Johnson32d95a32012-09-10 13:15:23 -07009627 if(!pSession)
9628 {
9629 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9630 return;
9631 }
9632
Jeff Johnson295189b2012-06-20 16:38:30 -07009633 if ( csrIsConnStateInfra( pMac, sessionId ) )
9634 {
9635 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9636 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009637#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9638 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9639#endif
9640 csrRoamLinkDown(pMac, sessionId);
9641 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009642 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9643 {
9644
9645 pRoamInfo = &roamInfo;
9646
9647 pRoamInfo->statusCode = pDeauthInd->statusCode;
9648 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9649
9650 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9651
Kiet Lam64c1b492013-07-12 13:56:44 +05309652 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9653 sizeof(tSirMacAddr));
9654 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9655 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009656
9657 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9658 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009659 }
9660 break;
9661
9662 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 -08009663 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009664 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9665 //Update with the new channel id.
9666 //The channel id is hidden in the statusCode.
9667 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9668 if( HAL_STATUS_SUCCESS( status ) )
9669 {
9670 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009671 if(!pSession)
9672 {
9673 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9674 return;
9675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009676 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9677 if(pSession->pConnectBssDesc)
9678 {
9679 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9680 }
9681 }
9682 break;
9683
9684 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009685 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009686 {
9687 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9688 sessionId = pDeauthRsp->sessionId;
9689 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9690 {
9691 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009692 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9693 {
9694 pRoamInfo = &roamInfo;
9695 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309696 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9697 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009698 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9699 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9700 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9701 }
9702 }
9703 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009704 break;
9705
9706 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009707 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009708 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009709 {
9710 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9711 sessionId = pDisassocRsp->sessionId;
9712 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9713 {
9714 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009715 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9716 {
9717 pRoamInfo = &roamInfo;
9718 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309719 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9720 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009721 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9722 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9723 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9724 }
9725 }
9726 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009727 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009728 case eWNI_SME_MIC_FAILURE_IND:
9729 {
9730 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9731 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9732 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009733
9734 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9735 if( HAL_STATUS_SUCCESS( status ) )
9736 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309737 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009738 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9739 pRoamInfo = &roamInfo;
9740 if(pMicInd->info.multicast)
9741 {
9742 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9743 }
9744 else
9745 {
9746 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9747 }
9748 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9749 }
9750
Jeff Johnson295189b2012-06-20 16:38:30 -07009751#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9752 {
lukez3c809222013-05-03 10:23:02 -07009753 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009754 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009755 if(!pSession)
9756 {
9757 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9758 return;
9759 }
lukez3c809222013-05-03 10:23:02 -07009760
Kiet Lam64c1b492013-07-12 13:56:44 +05309761 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009762 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9763 secEvent.encryptionModeMulticast =
9764 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9765 secEvent.encryptionModeUnicast =
9766 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9767 secEvent.authMode =
9768 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309769 vos_mem_copy(secEvent.bssid,
9770 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009771 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9772 }
9773#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009774 }
9775 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009776 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9777 {
9778 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9779 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009780 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009781
9782 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9783 if( HAL_STATUS_SUCCESS( status ) )
9784 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309785 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9787 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9788 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9789 }
9790 }
9791 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009792
Jeff Johnson295189b2012-06-20 16:38:30 -07009793 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9794 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9795 switch( pStatusChangeMsg->statusChangeCode )
9796 {
9797 case eSIR_SME_IBSS_ACTIVE:
9798 sessionId = csrFindIbssSession( pMac );
9799 if( CSR_SESSION_ID_INVALID != sessionId )
9800 {
9801 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009802 if(!pSession)
9803 {
9804 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9805 return;
9806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009807 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9808 if(pSession->pConnectBssDesc)
9809 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309810 vos_mem_copy(&roamInfo.bssid,
9811 pSession->pConnectBssDesc->bssId,
9812 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009813 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9814 pRoamInfo = &roamInfo;
9815 }
9816 else
9817 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009818 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009819 }
9820 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9821 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9822 }
9823 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009824 case eSIR_SME_IBSS_INACTIVE:
9825 sessionId = csrFindIbssSession( pMac );
9826 if( CSR_SESSION_ID_INVALID != sessionId )
9827 {
9828 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009829 if(!pSession)
9830 {
9831 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9832 return;
9833 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009834 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9835 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9836 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9837 }
9838 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009839 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9840 sessionId = csrFindIbssSession( pMac );
9841 if( CSR_SESSION_ID_INVALID != sessionId )
9842 {
9843 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009844 if(!pSession)
9845 {
9846 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9847 return;
9848 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009849 // update the connection state information
9850 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009851#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9852 {
9853 vos_log_ibss_pkt_type *pIbssLog;
9854 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009855 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9856 if(pIbssLog)
9857 {
9858 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9859 if(pNewBss)
9860 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309861 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009862 if(pNewBss->ssId.length)
9863 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309864 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9865 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009866 }
9867 pIbssLog->operatingChannel = pNewBss->channelNumber;
9868 }
9869 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9870 {
9871 //***U8 is not enough for beacon interval
9872 pIbssLog->beaconInterval = (v_U8_t)bi;
9873 }
9874 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9875 }
9876 }
9877#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009878 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009879
9880 if ((eCSR_ENCRYPT_TYPE_NONE ==
9881 pSession->connectedProfile.EncryptionType ))
9882 {
9883 csrRoamIssueSetContextReq( pMac, sessionId,
9884 pSession->connectedProfile.EncryptionType,
9885 pSession->pConnectBssDesc,
9886 &Broadcastaddr,
9887 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9888 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009889 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9890 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309891 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9892 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009893 pRoamInfo = &roamInfo;
9894 //This BSSID is th ereal BSSID, let's save it
9895 if(pSession->pConnectBssDesc)
9896 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309897 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9898 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009900 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009901 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009902 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009903 // detection by LIM that the capabilities of the associated AP have changed.
9904 case eSIR_SME_AP_CAPS_CHANGED:
9905 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009906 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009907 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9908 if( HAL_STATUS_SUCCESS( status ) )
9909 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009910 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9911 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309912 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009913 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9914 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9915 )
9916 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309917 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9918 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009919 }
9920 else
9921 {
9922 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309923 FL("Skipping csrScanForCapabilityChange as "
9924 "CSR is in state %s and sub-state %s"),
9925 macTraceGetcsrRoamState(
9926 pMac->roam.curState[sessionId]),
9927 macTraceGetcsrRoamSubState(
9928 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309929 /* We ignore the caps change event if CSR is not in full connected state.
9930 * Send one event to PE to reset limSentCapsChangeNtf
9931 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9932 * otherwise lim cannot send any CAPS change events to SME */
9933 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009934 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009935 }
9936 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309937
Jeff Johnson295189b2012-06-20 16:38:30 -07009938 default:
9939 roamStatus = eCSR_ROAM_FAILED;
9940 result = eCSR_ROAM_RESULT_NONE;
9941 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009942 } // end switch on statusChangeCode
9943 if(eCSR_ROAM_RESULT_NONE != result)
9944 {
9945 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9946 }
9947 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009948 case eWNI_SME_IBSS_NEW_PEER_IND:
9949 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009950#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9951 {
9952 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009953 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9954 if(pIbssLog)
9955 {
9956 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309957 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009958 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9959 }
9960 }
9961#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009962 sessionId = csrFindIbssSession( pMac );
9963 if( CSR_SESSION_ID_INVALID != sessionId )
9964 {
9965 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009966
9967 if(!pSession)
9968 {
9969 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9970 return;
9971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009972 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9973 if(pSession->pConnectBssDesc)
9974 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309975 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9976 sizeof(tCsrBssid));
9977 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9978 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009979 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9980 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309981 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9982 - sizeof(tSmeIbssPeerInd)));
9983 if ( NULL == roamInfo.pbFrames )
9984 status = eHAL_STATUS_FAILURE;
9985 else
9986 status = eHAL_STATUS_SUCCESS;
9987 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009988 {
9989 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309990 vos_mem_copy(roamInfo.pbFrames,
9991 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9992 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009993 }
9994 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9995 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9996 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309997 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9998 if ( NULL == roamInfo.pBssDesc )
9999 status = eHAL_STATUS_FAILURE;
10000 else
10001 status = eHAL_STATUS_SUCCESS;
10002 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010003 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010004 vos_mem_copy(roamInfo.pBssDesc,
10005 pSession->pConnectBssDesc,
10006 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 }
10008 if(HAL_STATUS_SUCCESS(status))
10009 {
10010 pRoamInfo = &roamInfo;
10011 }
10012 else
10013 {
10014 if(roamInfo.pbFrames)
10015 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010016 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010017 }
10018 if(roamInfo.pBssDesc)
10019 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010020 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010021 }
10022 }
10023 }
10024 else
10025 {
10026 pRoamInfo = &roamInfo;
10027 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010028 if ((eCSR_ENCRYPT_TYPE_NONE ==
10029 pSession->connectedProfile.EncryptionType ))
10030 {
10031 csrRoamIssueSetContextReq( pMac, sessionId,
10032 pSession->connectedProfile.EncryptionType,
10033 pSession->pConnectBssDesc,
10034 &(pIbssPeerInd->peerAddr),
10035 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10036 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010037 }
10038 else
10039 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010040 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010041 }
10042 //send up the sec type for the new peer
10043 if (pRoamInfo)
10044 {
10045 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10046 }
10047 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10048 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10049 if(pRoamInfo)
10050 {
10051 if(roamInfo.pbFrames)
10052 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010053 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010054 }
10055 if(roamInfo.pBssDesc)
10056 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010057 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010058 }
10059 }
10060 }
10061 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010062 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10063 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10064 sessionId = csrFindIbssSession( pMac );
10065 if( CSR_SESSION_ID_INVALID != sessionId )
10066 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010067#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10068 {
10069 vos_log_ibss_pkt_type *pIbssLog;
10070
10071 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10072 if(pIbssLog)
10073 {
10074 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10075 if(pIbssPeerInd)
10076 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010077 vos_mem_copy(pIbssLog->peerMacAddr,
10078 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010079 }
10080 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10081 }
10082 }
10083#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010084 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010085 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10086 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10087 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010088 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10089 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010090 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10091 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10092 }
10093 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010094 case eWNI_SME_SETCONTEXT_RSP:
10095 {
10096 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10097 tListElem *pEntry;
10098 tSmeCmd *pCommand;
10099
10100 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10101 if ( pEntry )
10102 {
10103 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10104 if ( eSmeCommandSetKey == pCommand->command )
10105 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010106 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010107 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010108
10109 if(!pSession)
10110 {
10111 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10112 return;
10113 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010114
10115#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10116 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10117 {
10118 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010119 vos_mem_set(&setKeyEvent,
10120 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010121 if( pRsp->peerMacAddr[0] & 0x01 )
10122 {
10123 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
10124 }
10125 else
10126 {
10127 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
10128 }
10129 setKeyEvent.encryptionModeMulticast =
10130 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10131 setKeyEvent.encryptionModeUnicast =
10132 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010133 vos_mem_copy(setKeyEvent.bssid,
10134 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010135 setKeyEvent.authMode =
10136 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010137 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010138 {
10139 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10140 }
10141 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10142 }
10143#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10144 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10145 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010146 csrRoamStopWaitForKeyTimer( pMac );
10147
Jeff Johnson295189b2012-06-20 16:38:30 -070010148 //We are done with authentication, whethere succeed or not
10149 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010150 //We do it here because this linkup function is not called after association
10151 //when a key needs to be set.
10152 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10153 {
10154 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10155 }
10156 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010157 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010158 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010159 vos_mem_copy(&roamInfo.peerMac,
10160 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010161 //Make sure we install the GTK before indicating to HDD as authenticated
10162 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010163 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10164 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010165 {
Yathish9f22e662012-12-10 14:21:35 -080010166#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10167 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10168 {
10169 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010170 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010171 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
10172 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
10173 pMsg->seesionId = sessionId;
10174 status = palSendMBMessage(pMac->hHdd, pMsg );
10175 }
10176#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010177 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010178 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
10179 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE )
10180 {
10181 tpSirSmeHT40OBSSScanInd pMsg;
10182 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10183 pMsg->messageType =
10184 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10185 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010186 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10187 vos_mem_copy(pMsg->peerMacAddr,
10188 pSession->connectedProfile.bssid,
10189 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010190 status = palSendMBMessage(pMac->hHdd,
10191 pMsg );
10192 }
10193 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010194 }
10195 else
10196 {
10197 result = eCSR_ROAM_RESULT_NONE;
10198 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010199 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010200 }
10201 else
10202 {
10203 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010204 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10205 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10206 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010207 }
10208 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10209 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010210 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10211 // can go ahead and initiate the TSPEC if any are pending
10212 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010213#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010214 //Send Adjacent AP repot to new AP.
10215 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10216 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010217 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010218 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010219#ifdef FEATURE_WLAN_ESE_UPLOAD
10220 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010221#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010222 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010223#endif
10224 pSession->isPrevApInfoValid = FALSE;
10225 }
10226#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010227 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10228 {
10229 csrReleaseCommandSetKey( pMac, pCommand );
10230 }
10231 }
10232 else
10233 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010234 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010235 }
10236 }
10237 else
10238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010239 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010240 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010241 smeProcessPendingQueue( pMac );
10242 }
10243 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010244 case eWNI_SME_REMOVEKEY_RSP:
10245 {
10246 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10247 tListElem *pEntry;
10248 tSmeCmd *pCommand;
10249
10250 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10251 if ( pEntry )
10252 {
10253 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10254 if ( eSmeCommandRemoveKey == pCommand->command )
10255 {
10256 sessionId = pCommand->sessionId;
10257 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010258
10259 if(!pSession)
10260 {
10261 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10262 return;
10263 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010264#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10265 {
10266 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010267 vos_mem_set(&removeKeyEvent,
10268 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010269 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10270 removeKeyEvent.encryptionModeMulticast =
10271 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10272 removeKeyEvent.encryptionModeUnicast =
10273 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010274 vos_mem_copy( removeKeyEvent.bssid,
10275 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010276 removeKeyEvent.authMode =
10277 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010278 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010279 {
10280 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10281 }
10282 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10283 }
10284#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010285 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010286 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010287 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10288 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010289 result = eCSR_ROAM_RESULT_NONE;
10290 pRoamInfo = &roamInfo;
10291 }
10292 else
10293 {
10294 result = eCSR_ROAM_RESULT_FAILURE;
10295 }
10296 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10297 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10298 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10299 {
10300 csrReleaseCommandRemoveKey( pMac, pCommand );
10301 }
10302 }
10303 else
10304 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010305 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010306 }
10307 }
10308 else
10309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010310 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010311 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010312 smeProcessPendingQueue( pMac );
10313 }
10314 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010315 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010316 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010317 csrRoamStatsRspProcessor( pMac, pSirMsg );
10318 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010319#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010320 case eWNI_SME_GET_ROAM_RSSI_RSP:
10321 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10322 csrRoamRssiRspProcessor( pMac, pSirMsg );
10323 break;
10324#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010325#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010326 case eWNI_SME_GET_TSM_STATS_RSP:
10327 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10328 csrTsmStatsRspProcessor( pMac, pSirMsg );
10329 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010330#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010331 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010332 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010333 csrUpdateRssi( pMac, pSirMsg );
10334 break;
10335
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010336 case eWNI_SME_GET_SNR_REQ:
10337 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10338 csrUpdateSnr(pMac, pSirMsg);
10339 break;
10340
Jeff Johnson295189b2012-06-20 16:38:30 -070010341#ifdef WLAN_FEATURE_VOWIFI_11R
10342 case eWNI_SME_FT_PRE_AUTH_RSP:
10343 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10344 break;
10345#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010346 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10347 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010348 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 -070010349 sessionId = pSmeMaxAssocInd->sessionId;
10350 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010351 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10352 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010353 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10354 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10355 break;
10356
10357 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010358 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010359 btampEstablishLogLinkHdlr( pSirMsg );
10360 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010361 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010362 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010363 csrRoamRssiIndHdlr( pMac, pSirMsg );
10364 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010365#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10366 case eWNI_SME_CANDIDATE_FOUND_IND:
10367 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10368 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10369 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010370 case eWNI_SME_HANDOFF_REQ:
10371 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10372 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10373 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010374#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010375
10376 default:
10377 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010378 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010379}
10380
Jeff Johnson295189b2012-06-20 16:38:30 -070010381void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10382 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10383{
10384 if(pSession)
10385 {
10386 if(pSession->bRefAssocStartCnt)
10387 {
10388 pSession->bRefAssocStartCnt--;
10389 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10390 //Need to call association_completion because there is an assoc_start pending.
10391 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10392 eCSR_ROAM_ASSOCIATION_COMPLETION,
10393 eCSR_ROAM_RESULT_FAILURE);
10394 }
10395 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10396 }
10397 else
10398 {
10399 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10400 }
10401}
10402
10403
10404eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10405{
10406 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010407 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10408 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10409 {
10410 status = csrScanRequestLostLink1( pMac, sessionId );
10411 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010412 return(status);
10413}
10414
Jeff Johnson295189b2012-06-20 16:38:30 -070010415//return a boolean to indicate whether roaming completed or continue.
10416tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10417 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10418{
10419 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10420 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10421 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10422 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010423 if(!pSession)
10424 {
10425 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10426 return eANI_BOOLEAN_FALSE;
10427 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010428 //Check whether time is up
10429 if(pSession->fCancelRoaming || fForce ||
10430 ((curTime - pSession->roamingStartTime) > roamTime) ||
10431 eCsrReassocRoaming == pSession->roamingReason ||
10432 eCsrDynamicRoaming == pSession->roamingReason)
10433 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010434 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010435 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10436 {
10437 //roaming is cancelled, tell HDD to indicate disconnect
10438 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10439 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10440 //to be eSIR_BEACON_MISSED
10441 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10442 {
10443 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10444 }
10445 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10446 {
10447 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10448 }
10449 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10450 {
10451 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10452 }
10453 else
10454 {
10455 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10456 }
10457 }
10458 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10459 pSession->roamingReason = eCsrNotRoaming;
10460 }
10461 else
10462 {
10463 pSession->roamResult = roamResult;
10464 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10465 {
10466 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10467 pSession->roamingReason = eCsrNotRoaming;
10468 }
10469 else
10470 {
10471 fCompleted = eANI_BOOLEAN_FALSE;
10472 }
10473 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010474 return(fCompleted);
10475}
10476
Jeff Johnson295189b2012-06-20 16:38:30 -070010477void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10478{
10479 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010480
10481 if(!pSession)
10482 {
10483 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10484 return;
10485 }
10486
Jeff Johnson295189b2012-06-20 16:38:30 -070010487 if(CSR_IS_ROAMING(pSession))
10488 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010489 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010490 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10491 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10492 {
10493 //No need to do anything in here because the handler takes care of it
10494 }
10495 else
10496 {
10497 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10498 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10499 //Roaming is stopped after here
10500 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10501 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010502 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010503 csrRoamStopRoamingTimer(pMac, sessionId);
10504 }
10505 }
10506}
10507
Jeff Johnson295189b2012-06-20 16:38:30 -070010508void csrRoamRoamingTimerHandler(void *pv)
10509{
10510 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10511 tpAniSirGlobal pMac = pInfo->pMac;
10512 tANI_U32 sessionId = pInfo->sessionId;
10513 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010514
10515 if(!pSession)
10516 {
10517 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10518 return;
10519 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010520
10521 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10522 {
10523 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10524 {
10525 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10526 pSession->roamingReason = eCsrNotRoaming;
10527 }
10528 }
10529}
10530
Jeff Johnson295189b2012-06-20 16:38:30 -070010531eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10532{
10533 eHalStatus status;
10534 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010535
10536 if(!pSession)
10537 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010538 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010539 return eHAL_STATUS_FAILURE;
10540 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010541
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010542 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010543 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010544 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010545
10546 return (status);
10547}
10548
Jeff Johnson295189b2012-06-20 16:38:30 -070010549eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10550{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010551 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010552}
10553
Jeff Johnson295189b2012-06-20 16:38:30 -070010554void csrRoamWaitForKeyTimeOutHandler(void *pv)
10555{
10556 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10557 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010558 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010559 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010560
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010561 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10562 macTraceGetNeighbourRoamState(
10563 pMac->roam.neighborRoamInfo.neighborRoamState),
10564 macTraceGetcsrRoamSubState(
10565 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010566
Jeff Johnson295189b2012-06-20 16:38:30 -070010567 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10568 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010569#ifdef FEATURE_WLAN_LFR
10570 if (csrNeighborRoamIsHandoffInProgress(pMac))
10571 {
10572 /*
10573 * Enable heartbeat timer when hand-off is in progress
10574 * and Key Wait timer expired.
10575 */
10576 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010577 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010578 pMac->roam.configParam.HeartbeatThresh24);
10579 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10580 pMac->roam.configParam.HeartbeatThresh24,
10581 NULL, eANI_BOOLEAN_FALSE);
10582 }
10583#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010584 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010585
Jeff Johnson295189b2012-06-20 16:38:30 -070010586 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010587 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10588 {
10589 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10590 pInfo->sessionId);
10591 }
10592
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010593 if (pSession)
10594 {
10595 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10596 {
10597 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10598 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010599 if( (pSession->connectedProfile.AuthType ==
10600 eCSR_AUTH_TYPE_SHARED_KEY) &&
10601 ( (pSession->connectedProfile.EncryptionType ==
10602 eCSR_ENCRYPT_TYPE_WEP40) ||
10603 (pSession->connectedProfile.EncryptionType ==
10604 eCSR_ENCRYPT_TYPE_WEP104) ))
10605 {
10606 status = sme_AcquireGlobalLock( &pMac->sme );
10607 if ( HAL_STATUS_SUCCESS( status ) )
10608 {
10609 csrRoamDisconnect( pMac, pInfo->sessionId,
10610 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10611 sme_ReleaseGlobalLock( &pMac->sme );
10612 }
10613 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010614 }
10615 else
10616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010617 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010618 __func__);
10619 }
10620 }
10621 else
10622 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010623 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010624 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010625 }
10626
10627}
10628
Jeff Johnson295189b2012-06-20 16:38:30 -070010629eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10630{
10631 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010632#ifdef FEATURE_WLAN_LFR
10633 if (csrNeighborRoamIsHandoffInProgress(pMac))
10634 {
10635 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010636 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10637 macTraceGetNeighbourRoamState(
10638 pMac->roam.neighborRoamInfo.neighborRoamState),
10639 macTraceGetcsrRoamSubState(
10640 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10641 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010642 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10643 }
10644#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010645 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010646 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010647
10648 return (status);
10649}
10650
Jeff Johnson295189b2012-06-20 16:38:30 -070010651eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10652{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010653 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10654 macTraceGetNeighbourRoamState(
10655 pMac->roam.neighborRoamInfo.neighborRoamState),
10656 macTraceGetcsrRoamSubState(
10657 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010658#ifdef FEATURE_WLAN_LFR
10659 if (csrNeighborRoamIsHandoffInProgress(pMac))
10660 {
10661 /*
10662 * Enable heartbeat timer when hand-off is in progress
10663 * and Key Wait timer got stopped for some reason
10664 */
10665 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010666 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010667 pMac->roam.configParam.HeartbeatThresh24);
10668 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10669 pMac->roam.configParam.HeartbeatThresh24,
10670 NULL, eANI_BOOLEAN_FALSE);
10671 }
10672#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010673 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010674}
10675
Jeff Johnson295189b2012-06-20 16:38:30 -070010676void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10677 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10678{
10679 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10680 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010681 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10682 /* To silence the KW tool Null chaeck is added */
10683 if(!pSession)
10684 {
10685 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10686 return;
10687 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010688
10689 if(pCommand)
10690 {
10691 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010692 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010693 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010694 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10695 {
10696 //if success, force roaming completion
10697 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10698 }
10699 else
10700 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010701 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010702 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010703 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10704 }
10705}
10706
Jeff Johnson295189b2012-06-20 16:38:30 -070010707eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10708{
10709 eHalStatus status = eHAL_STATUS_SUCCESS;
10710 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10711 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10712 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10713 tCsrRoamInfo *pRoamInfo = NULL;
10714 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010715 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010716 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010717 /* To silence the KW tool Null chaeck is added */
10718 if(!pSession)
10719 {
10720 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10721 return eHAL_STATUS_FAILURE;
10722 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010723 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010724 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010725 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10726 if ( eWNI_SME_DISASSOC_IND == type )
10727 {
10728 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10729 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10730 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010731 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010732 }
10733 else if ( eWNI_SME_DEAUTH_IND == type )
10734 {
10735 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10736 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10737 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010738 /* Convert into proper reason code */
10739 pSession->joinFailStatusCode.reasonCode =
10740 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010741 0 : pDeauthIndMsg->reasonCode;
10742 /* cfg layer expects 0 as reason code if
10743 the driver dosent know the reason code
10744 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010745 }
10746 else
10747 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010748 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010749 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010750 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010751 }
10752
10753 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010754 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010755 {
10756 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10757 }
10758
10759 if ( eWNI_SME_DISASSOC_IND == type )
10760 {
10761 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10762 }
10763 else if ( eWNI_SME_DEAUTH_IND == type )
10764 {
10765 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10766 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010767 if(!HAL_STATUS_SUCCESS(status))
10768 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010769 //If fail to send confirmation to PE, not to trigger roaming
10770 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010771 }
10772
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010773 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010774 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010775 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10776 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010777 if( eWNI_SME_DISASSOC_IND == type)
10778 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010779 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010780 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10781 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010782 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10783 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010784 else if( eWNI_SME_DEAUTH_IND == type )
10785 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010786 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010787 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10788 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010789 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10790 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010791 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010792
10793 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10794 that we are roaming. But if we cannot possibly roam, or if we are unable to
10795 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010796 if(fToRoam)
10797 {
10798 //Only remove the connected BSS in infrastructure mode
10799 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10800 //Not to do anying for lostlink with WDS
10801 if( pMac->roam.configParam.nRoamingTime )
10802 {
10803 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10804 ( eWNI_SME_DEAUTH_IND == type ) ?
10805 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10806 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010807 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010808 //For IBSS, we need to give some more info to HDD
10809 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10810 {
10811 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10812 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10813 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10814 }
10815 else
10816 {
10817 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10818 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010819 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010820 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10821 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10822 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10823 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10824 }
10825 else
10826 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010827 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010828 fToRoam = eANI_BOOLEAN_FALSE;
10829 }
10830 }
10831 else
10832 {
10833 //We are told not to roam, indicate lostlink
10834 fToRoam = eANI_BOOLEAN_FALSE;
10835 }
10836 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010837 if(!fToRoam)
10838 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010839 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010840 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010841 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010842 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10843 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10844 * csrRoamCheckForLinkStatusChange API.
10845 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010846 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10847 }
10848
10849 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010850 Still enable idle scan for polling in case concurrent sessions are running */
10851 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10852 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010853 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010854 }
10855 }
10856
10857 return (status);
10858}
10859
Jeff Johnson295189b2012-06-20 16:38:30 -070010860eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10861{
10862 eHalStatus status = eHAL_STATUS_SUCCESS;
10863 tListElem *pEntry = NULL;
10864 tSmeCmd *pCommand = NULL;
10865 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010866
10867 if(!pSession)
10868 {
10869 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10870 return eHAL_STATUS_FAILURE;
10871 }
10872
Jeff Johnson295189b2012-06-20 16:38:30 -070010873 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010874 //Only remove the connected BSS in infrastructure mode
10875 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10876 if(pMac->roam.configParam.nRoamingTime)
10877 {
10878 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10879 {
10880 //before starting the lost link logic release the roam command for handoff
10881 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10882 if(pEntry)
10883 {
10884 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10885 }
10886 if(pCommand)
10887 {
10888 if (( eSmeCommandRoam == pCommand->command ) &&
10889 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10890 {
10891 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10892 {
10893 csrReleaseCommandRoam( pMac, pCommand );
10894 }
10895 }
10896 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010897 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010898 }
10899 }
10900 else
10901 {
10902 //We are told not to roam, indicate lostlink
10903 status = eHAL_STATUS_FAILURE;
10904 }
10905
10906 return (status);
10907}
Jeff Johnson295189b2012-06-20 16:38:30 -070010908void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10909{
10910 tListElem *pEntry;
10911 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010912 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10913 if ( pEntry )
10914 {
10915 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10916 if ( eSmeCommandWmStatusChange == pCommand->command )
10917 {
10918 // Nothing to process in a Lost Link completion.... It just kicks off a
10919 // roaming sequence.
10920 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10921 {
10922 csrReleaseCommandWmStatusChange( pMac, pCommand );
10923 }
10924 else
10925 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010926 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010927 }
10928
10929 }
10930 else
10931 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010932 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010933 }
10934 }
10935 else
10936 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010937 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010938 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010939 smeProcessPendingQueue( pMac );
10940}
10941
Jeff Johnson295189b2012-06-20 16:38:30 -070010942void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10943{
10944 eHalStatus status = eHAL_STATUS_FAILURE;
10945 tSirSmeRsp *pSirSmeMsg;
10946 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010947
10948 if(!pSession)
10949 {
10950 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10951 return;
10952 }
10953
Jeff Johnson295189b2012-06-20 16:38:30 -070010954 switch ( pCommand->u.wmStatusChangeCmd.Type )
10955 {
10956 case eCsrDisassociated:
10957 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10958 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10959 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010960 case eCsrDeauthenticated:
10961 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10962 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10963 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010964 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010965 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010966 break;
10967 }
10968 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10969 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10970 {
10971 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10972 {
10973 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010974 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010975 }
10976 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010977 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10978 // command here since there is nothing else to do.
10979 csrRoamWmStatusChangeComplete( pMac );
10980}
10981
Jeff Johnson295189b2012-06-20 16:38:30 -070010982//This function returns band and mode information.
10983//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10984//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010985static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10986 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010987{
Jeff Johnson295189b2012-06-20 16:38:30 -070010988 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10989 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10990 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010991 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010992
Jeff Johnson295189b2012-06-20 16:38:30 -070010993 //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 -070010994 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10995 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10996 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10997 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010998 {
10999 switch( pMac->roam.configParam.uCfgDot11Mode )
11000 {
11001 case eCSR_CFG_DOT11_MODE_11A:
11002 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11003 eBand = eCSR_BAND_5G;
11004 break;
11005 case eCSR_CFG_DOT11_MODE_11B:
11006 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11007 eBand = eCSR_BAND_24;
11008 break;
11009 case eCSR_CFG_DOT11_MODE_11G:
11010 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11011 eBand = eCSR_BAND_24;
11012 break;
11013 case eCSR_CFG_DOT11_MODE_11N:
11014 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011015 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11016 break;
11017#ifdef WLAN_FEATURE_11AC
11018 case eCSR_CFG_DOT11_MODE_11AC:
11019 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11020 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011021 /* If the operating channel is in 2.4 GHz band, check for
11022 * INI item to disable VHT operation in 2.4 GHz band
11023 */
11024 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11025 !pMac->roam.configParam.enableVhtFor24GHz)
11026 {
11027 /* Disable 11AC operation */
11028 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11029 }
11030 else
11031 {
11032 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11033 }
11034 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011035 }
11036 else
11037 {
11038 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11039 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11040 }
11041 break;
11042 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11043 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11044 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011045 /* If the operating channel is in 2.4 GHz band, check for
11046 * INI item to disable VHT operation in 2.4 GHz band
11047 */
11048 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11049 !pMac->roam.configParam.enableVhtFor24GHz)
11050 {
11051 /* Disable 11AC operation */
11052 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11053 }
11054 else
11055 {
11056 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11057 }
11058 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011059 }
11060 else
11061 {
11062 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11063 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11064 }
11065 break;
11066#endif
11067 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011068#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011069 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11070 {
11071 /* If the operating channel is in 2.4 GHz band, check for
11072 * INI item to disable VHT operation in 2.4 GHz band
11073 */
11074 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11075 !pMac->roam.configParam.enableVhtFor24GHz)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011076 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011077 /* Disable 11AC operation */
11078 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011079 }
11080 else
11081 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011082 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11083 }
11084 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11085 }
11086 else
11087 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011088 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11089 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011090 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011091#else
11092 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11093 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11094#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011095 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011096 default:
11097 // Global dot11 Mode setting is 11a/b/g.
11098 // use the channel number to determine the Mode setting.
11099 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11100 {
11101 eBand = pMac->roam.configParam.eBand;
11102 if(eCSR_BAND_24 == eBand)
11103 {
11104 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11105 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11106 }
11107 else
11108 {
11109 //prefer 5GHz
11110 eBand = eCSR_BAND_5G;
11111 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11112 }
11113 }
11114 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11115 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011116 // WiFi tests require IBSS networks to start in 11b mode
11117 // without any change to the default parameter settings
11118 // on the adapter. We use ACU to start an IBSS through
11119 // creation of a startIBSS profile. This startIBSS profile
11120 // has Auto MACProtocol and the adapter property setting
11121 // for dot11Mode is also AUTO. So in this case, let's
11122 // start the IBSS network in 11b mode instead of 11g mode.
11123 // So this is for Auto=profile->MacProtocol && Auto=Global.
11124 // dot11Mode && profile->channel is < 14, then start the IBSS
11125 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011126 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011127 // Note: we used to have this start as an 11g IBSS for best
11128 // performance... now to specify that the user will have to
11129 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011130 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11131 eBand = eCSR_BAND_24;
11132 }
11133 else
11134 {
11135 // else, it's a 5.0GHz channel. Set mode to 11a.
11136 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11137 eBand = eCSR_BAND_5G;
11138 }
11139 break;
11140 }//switch
11141 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11142 else
11143 {
11144 //dot11 mode is set, lets pick the band
11145 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11146 {
11147 // channel is Auto also.
11148 eBand = pMac->roam.configParam.eBand;
11149 if(eCSR_BAND_ALL == eBand)
11150 {
11151 //prefer 5GHz
11152 eBand = eCSR_BAND_5G;
11153 }
11154 }
11155 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11156 {
11157 eBand = eCSR_BAND_24;
11158 }
11159 else
11160 {
11161 eBand = eCSR_BAND_5G;
11162 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011163 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011164 if(pBand)
11165 {
11166 *pBand = eBand;
11167 }
11168
11169 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011170 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011171 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11172 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011173
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011174 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11175 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 -070011176 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011177#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011178 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011179#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011180 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11181 {
11182 //We cannot do 11n here
11183 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11184 {
11185 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11186 }
11187 else
11188 {
11189 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11190 }
11191 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011192 return( cfgDot11Mode );
11193}
11194
Jeff Johnson295189b2012-06-20 16:38:30 -070011195eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11196{
11197 eHalStatus status;
11198 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011199
11200 if(!pSession)
11201 {
11202 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11203 return eHAL_STATUS_FAILURE;
11204 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011205
11206#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11207 {
11208 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011209 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11210 if(pIbssLog)
11211 {
11212 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11213 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11214 }
11215 }
11216#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011217 // Set the roaming substate to 'stop Bss request'...
11218 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11219
11220 // attempt to stop the Bss (reason code is ignored...)
11221 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011222 if(!HAL_STATUS_SUCCESS(status))
11223 {
11224 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11225 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011226 return (status);
11227}
11228
Jeff Johnson295189b2012-06-20 16:38:30 -070011229//pNumChan is a caller allocated space with the sizeof pChannels
11230eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11231{
11232
11233 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11234 (tANI_U8 *)pChannels,
11235 pNumChan));
11236}
11237
Kiran4a17ebe2013-01-31 10:43:43 -080011238tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11239{
11240 tANI_U32 cfgLength = 0;
11241 tANI_U16 cfgId = 0;
11242 tPowerdBm maxTxPwr = 0;
11243 tANI_U8 *pCountryInfo = NULL;
11244 eHalStatus status;
11245 tANI_U8 count = 0;
11246 tANI_U8 firstChannel;
11247 tANI_U8 maxChannels;
11248
11249 if (CSR_IS_CHANNEL_5GHZ(channel))
11250 {
11251 cfgId = WNI_CFG_MAX_TX_POWER_5;
11252 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11253 }
11254 else if (CSR_IS_CHANNEL_24GHZ(channel))
11255 {
11256 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11257 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11258 }
11259 else
11260 return maxTxPwr;
11261
Kiet Lam64c1b492013-07-12 13:56:44 +053011262 pCountryInfo = vos_mem_malloc(cfgLength);
11263 if ( NULL == pCountryInfo )
11264 status = eHAL_STATUS_FAILURE;
11265 else
11266 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011267 if (status != eHAL_STATUS_SUCCESS)
11268 {
11269 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011270 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011271 __FUNCTION__, status);
11272 goto error;
11273 }
11274 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11275 if (status != eHAL_STATUS_SUCCESS)
11276 {
11277 goto error;
11278 }
11279 /* Identify the channel and maxtxpower */
11280 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11281 {
11282 firstChannel = pCountryInfo[count++];
11283 maxChannels = pCountryInfo[count++];
11284 maxTxPwr = pCountryInfo[count++];
11285
11286 if ((channel >= firstChannel) &&
11287 (channel < (firstChannel + maxChannels)))
11288 {
11289 break;
11290 }
11291 }
11292
11293error:
11294 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011295 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011296
11297 return maxTxPwr;
11298}
11299
11300
Jeff Johnson295189b2012-06-20 16:38:30 -070011301tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11302{
11303 tANI_BOOLEAN fValid = FALSE;
11304 tANI_U32 idxValidChannels;
11305 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11306
11307 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11308 {
11309 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11310 {
11311 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11312 {
11313 fValid = TRUE;
11314 break;
11315 }
11316 }
11317 }
11318 pMac->roam.numValidChannels = len;
11319 return fValid;
11320}
11321
Jeff Johnson295189b2012-06-20 16:38:30 -070011322tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11323{
11324 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11325 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011326 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11327 {
11328 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11329 {
11330 fValid = eANI_BOOLEAN_TRUE;
11331 break;
11332 }
11333 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011334 return (fValid);
11335}
11336
Jeff Johnson295189b2012-06-20 16:38:30 -070011337//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011338 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011339{
Jeff Johnsone7245742012-09-05 17:12:55 -070011340 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011341 tANI_U8 centerChn;
11342 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011343
Jeff Johnson295189b2012-06-20 16:38:30 -070011344 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11345 {
11346 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11347 }
11348 else
11349 {
11350 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11351 }
11352 //Figure what the other side's CB mode
11353 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11354 {
11355 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11356 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011357 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11358 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11359 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11360 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011361 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
11362 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053011363 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011364 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053011365
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011366 {
11367 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11368 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11369 }
11370
11371 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011372 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011373 /* This is called during INFRA STA/CLIENT and should use the merged value of
11374 * supported channel width and recommended tx width as per standard
11375 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011376 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011377 pIes->HTCaps.supportedChannelWidthSet,
11378 pIes->HTInfo.recommendedTxWidthSet,
11379 pIes->HTInfo.secondaryChannelOffset);
11380
11381 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11382 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011383 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011384 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11385 switch (eRet) {
11386 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11387 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11388 break;
11389 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11390 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11391 break;
11392 case PHY_SINGLE_CHANNEL_CENTERED:
11393 default:
11394 centerChn = primaryChn;
11395 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011396 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011397 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011398 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011399 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053011400 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011401 }
11402 }
11403 }
11404 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011405 return eRet;
11406}
Jeff Johnson295189b2012-06-20 16:38:30 -070011407tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11408{
11409 tANI_BOOLEAN fFound = FALSE;
11410 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011411 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11412 {
11413 if( pCipherList->encryptionType[idx] == encryptionType )
11414 {
11415 fFound = TRUE;
11416 break;
11417 }
11418 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011419 return fFound;
11420}
Jeff Johnson295189b2012-06-20 16:38:30 -070011421tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11422{
11423 tANI_BOOLEAN fFound = FALSE;
11424 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011425 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11426 {
11427 if( pAuthList->authType[idx] == authType )
11428 {
11429 fFound = TRUE;
11430 break;
11431 }
11432 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011433 return fFound;
11434}
Jeff Johnson295189b2012-06-20 16:38:30 -070011435tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11436{
11437 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11438 tCsrScanResultFilter *pScanFilter = NULL;
11439 eHalStatus status = eHAL_STATUS_SUCCESS;
11440
11441 if(pProfile1 && pProfile2)
11442 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011443 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11444 if ( NULL == pScanFilter )
11445 status = eHAL_STATUS_FAILURE;
11446 else
11447 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011448 if(HAL_STATUS_SUCCESS(status))
11449 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011450 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011451 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11452 if(HAL_STATUS_SUCCESS(status))
11453 {
11454 fCheck = eANI_BOOLEAN_FALSE;
11455 do
11456 {
11457 tANI_U32 i;
11458 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11459 {
11460 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11461 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11462 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11463 if ( fCheck ) break;
11464 }
11465 if(!fCheck)
11466 {
11467 break;
11468 }
11469 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11470 || pProfile2->BSSType != pProfile1->BSSType
11471 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11472 )
11473 {
11474 fCheck = eANI_BOOLEAN_FALSE;
11475 break;
11476 }
11477#ifdef WLAN_FEATURE_VOWIFI_11R
11478 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11479 {
11480 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11481 {
11482 fCheck = eANI_BOOLEAN_FALSE;
11483 break;
11484 }
11485 }
11486#endif
11487 //Match found
11488 fCheck = eANI_BOOLEAN_TRUE;
11489 }while(0);
11490 csrFreeScanFilter(pMac, pScanFilter);
11491 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011492 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011493 }
11494 }
11495
11496 return (fCheck);
11497}
11498
Jeff Johnson295189b2012-06-20 16:38:30 -070011499tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11500{
11501 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11502 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011503 do
11504 {
11505 //Only check for static WEP
11506 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11507 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11508 {
11509 fCheck = eANI_BOOLEAN_TRUE;
11510 break;
11511 }
11512 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11513 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11514 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11515 {
11516 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011517 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11518 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011519 {
11520 break;
11521 }
11522 }
11523 if( i == CSR_MAX_NUM_KEY)
11524 {
11525 fCheck = eANI_BOOLEAN_TRUE;
11526 }
11527 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011528 return (fCheck);
11529}
11530
Jeff Johnson295189b2012-06-20 16:38:30 -070011531//IBSS
11532
Jeff Johnson295189b2012-06-20 16:38:30 -070011533tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11534{
11535 tANI_U8 channel = 0;
11536 tANI_U32 idx;
11537 tANI_U32 idxValidChannels;
11538 tANI_BOOLEAN fFound = FALSE;
11539 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11540
11541 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11542 {
11543 channel = pMac->roam.configParam.AdHocChannel5G;
11544 if(!csrRoamIsChannelValid(pMac, channel))
11545 {
11546 channel = 0;
11547 }
11548 }
11549 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11550 {
11551 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11552 {
11553 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11554 {
11555 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11556 {
11557 fFound = TRUE;
11558 channel = csrStartIbssChannels50[ idx ];
11559 }
11560 }
11561 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011562 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11563 if (!fFound)
11564 {
11565 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11566 {
Girish Gowli386e76c2014-10-20 22:00:29 +053011567 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idxValidChannels ]) ) // the max channel# in 11g is 14
Jeff Johnson295189b2012-06-20 16:38:30 -070011568 {
Girish Gowli386e76c2014-10-20 22:00:29 +053011569 channel = pMac->roam.validChannelList[ idxValidChannels ];
Jeff Johnson295189b2012-06-20 16:38:30 -070011570 break;
11571 }
11572 }
11573 }
11574 }//if
11575
11576 return( channel );
11577}
11578
Jeff Johnson295189b2012-06-20 16:38:30 -070011579tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11580{
11581 tANI_U8 channel = 1;
11582 tANI_U32 idx;
11583 tANI_U32 idxValidChannels;
11584 tANI_BOOLEAN fFound = FALSE;
11585 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11586
11587 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11588 {
11589 channel = pMac->roam.configParam.AdHocChannel24;
11590 if(!csrRoamIsChannelValid(pMac, channel))
11591 {
11592 channel = 0;
11593 }
11594 }
11595
11596 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11597 {
11598 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11599 {
11600 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11601 {
11602 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11603 {
11604 fFound = TRUE;
11605 channel = csrStartIbssChannels24[ idx ];
11606 }
11607 }
11608 }
11609 }
11610
11611 return( channel );
11612}
11613
Jeff Johnson295189b2012-06-20 16:38:30 -070011614static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11615 tCsrRoamStartBssParams *pParam )
11616{
11617 eCsrCfgDot11Mode cfgDot11Mode;
11618 eCsrBand eBand;
11619 tANI_U8 channel = 0;
11620 tSirNwType nwType;
11621 tANI_U8 operationChannel = 0;
11622
11623 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11624 {
11625 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11626 }
11627
Jeff Johnson295189b2012-06-20 16:38:30 -070011628 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011629
Jeff Johnson295189b2012-06-20 16:38:30 -070011630 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11631 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11632 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11633 )
11634 {
11635 /* This should never happen */
11636 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011637 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011638 pProfile->csrPersona);
11639 VOS_ASSERT(0);
11640 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011641 switch( cfgDot11Mode )
11642 {
11643 case eCSR_CFG_DOT11_MODE_11G:
11644 nwType = eSIR_11G_NW_TYPE;
11645 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011646 case eCSR_CFG_DOT11_MODE_11B:
11647 nwType = eSIR_11B_NW_TYPE;
11648 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011649 case eCSR_CFG_DOT11_MODE_11A:
11650 nwType = eSIR_11A_NW_TYPE;
11651 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 default:
11653 case eCSR_CFG_DOT11_MODE_11N:
11654 case eCSR_CFG_DOT11_MODE_TAURUS:
11655 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11656 if(eCSR_BAND_24 == eBand)
11657 {
11658 nwType = eSIR_11G_NW_TYPE;
11659 }
11660 else
11661 {
11662 nwType = eSIR_11A_NW_TYPE;
11663 }
11664 break;
11665 }
11666
11667 pParam->extendedRateSet.numRates = 0;
11668
11669 switch ( nwType )
11670 {
11671 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011672 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011673 case eSIR_11A_NW_TYPE:
11674
11675 pParam->operationalRateSet.numRates = 8;
11676
11677 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11678 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11679 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11680 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11681 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11682 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11683 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11684 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11685
11686 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11687 {
11688 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11689 if( 0 == channel &&
11690 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11691 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11692 )
11693 {
11694 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11695 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11696 nwType = eSIR_11B_NW_TYPE;
11697 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11698 pParam->operationalRateSet.numRates = 4;
11699 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11700 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11701 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11702 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11703 }
11704 }
11705 else
11706 {
11707 channel = operationChannel;
11708 }
11709 break;
11710
11711 case eSIR_11B_NW_TYPE:
11712 pParam->operationalRateSet.numRates = 4;
11713 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11714 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11715 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11716 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011717 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11718 {
11719 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11720 }
11721 else
11722 {
11723 channel = operationChannel;
11724 }
11725
11726 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011727 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011728 /* For P2P Client and P2P GO, disable 11b rates */
11729 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11730 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11731 )
11732 {
11733 pParam->operationalRateSet.numRates = 8;
11734
11735 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11736 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11737 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11738 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11739 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11740 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11741 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11742 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11743 }
11744 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011745 {
11746 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011747 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11748 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11749 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11750 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11751
11752 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011753 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11754 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11755 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11756 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11757 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11758 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11759 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11760 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11761 }
11762
11763 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11764 {
11765 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11766 }
11767 else
11768 {
11769 channel = operationChannel;
11770 }
11771
11772 break;
11773 }
11774 pParam->operationChn = channel;
11775 pParam->sirNwType = nwType;
11776}
11777
Jeff Johnson295189b2012-06-20 16:38:30 -070011778static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11779 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11780{
11781
11782 if( pParam )
11783 {
11784 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011785 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011786 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011787 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011788
11789 if( pIes )
11790 {
11791 if(pIes->SuppRates.present)
11792 {
11793 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11794 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11795 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011796 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 -070011797 pIes->SuppRates.num_rates);
11798 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11799 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011800 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11801 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011802 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011803 if (pIes->ExtSuppRates.present)
11804 {
11805 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011806 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011807 {
11808 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11809 SIR_MAC_RATESET_EID_MAX, resetting to \
11810 SIR_MAC_RATESET_EID_MAX"),
11811 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011812 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011813 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011814 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011815 pIes->ExtSuppRates.rates,
11816 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11817 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011818 if( pIes->SSID.present )
11819 {
11820 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011821 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11822 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011823 }
11824 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011825 }
11826 else
11827 {
11828 pParam->ssId.length = 0;
11829 pParam->operationalRateSet.numRates = 0;
11830 }
11831 }
11832}
11833
Jeff Johnson295189b2012-06-20 16:38:30 -070011834static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11835{
11836 tANI_U8 MaxRate = 0;
11837 tANI_U32 i;
11838 tANI_U8 *pRate;
11839
11840 pRate = pSirRateSet->rate;
11841 for ( i = 0; i < pSirRateSet->numRates; i++ )
11842 {
11843 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11844 }
11845
11846 // Save the max rate in the connected state information...
11847
11848 // modify LastRates variable as well
11849
11850 return;
11851}
11852
Jeff Johnson295189b2012-06-20 16:38:30 -070011853eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11854 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11855{
11856 eHalStatus status = eHAL_STATUS_SUCCESS;
11857 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011858 // Set the roaming substate to 'Start BSS attempt'...
11859 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011860#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11861 //Need to figure out whether we need to log WDS???
11862 if( CSR_IS_IBSS( pProfile ) )
11863 {
11864 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011865 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11866 if(pIbssLog)
11867 {
11868 if(pBssDesc)
11869 {
11870 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011871 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011872 }
11873 else
11874 {
11875 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11876 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011877 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011878 if(pProfile->ChannelInfo.numOfChannels == 0)
11879 {
11880 pIbssLog->channelSetting = AUTO_PICK;
11881 }
11882 else
11883 {
11884 pIbssLog->channelSetting = SPECIFIED;
11885 }
11886 pIbssLog->operatingChannel = pParam->operationChn;
11887 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11888 }
11889 }
11890#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11891 //Put RSN information in for Starting BSS
Abhishek Singh3f9cbb72014-06-04 15:16:27 +053011892 if (pProfile->nRSNReqIELength && pProfile->pRSNReqIE) {
11893 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11894 pParam->pRSNIE = pProfile->pRSNReqIE;
11895 } else if (pProfile->nWPAReqIELength && pProfile->pWPAReqIE) {
11896 pParam->nRSNIELength = (tANI_U16)pProfile->nWPAReqIELength;
11897 pParam->pRSNIE = pProfile->pWPAReqIE;
11898 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011899
Jeff Johnson295189b2012-06-20 16:38:30 -070011900 pParam->privacy = pProfile->privacy;
11901 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11902 pParam->authType = pProfile->csr80211AuthType;
11903 pParam->beaconInterval = pProfile->beaconInterval;
11904 pParam->dtimPeriod = pProfile->dtimPeriod;
11905 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11906 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11907 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11908 {
11909 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11910 {
11911 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11912 }
11913 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011914 pParam->protEnabled = pProfile->protEnabled;
11915 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11916 pParam->ht_protection = pProfile->cfg_protection;
11917 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011918
Jeff Johnson295189b2012-06-20 16:38:30 -070011919 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11920 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011921 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080011922
11923#ifdef WLAN_FEATURE_11W
11924 pParam->mfpCapable = (0 != pProfile->MFPCapable);
11925 pParam->mfpRequired = (0 != pProfile->MFPRequired);
11926#endif
11927
Jeff Johnson295189b2012-06-20 16:38:30 -070011928 // When starting an IBSS, start on the channel from the Profile.
11929 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011930 return (status);
11931}
11932
Jeff Johnson295189b2012-06-20 16:38:30 -070011933static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011934 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011935{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011936 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011937 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011938 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011939
11940 if(!pSession)
11941 {
11942 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11943 return;
11944 }
11945
Jeff Johnson295189b2012-06-20 16:38:30 -070011946 if( pBssDesc )
11947 {
11948 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11949 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11950 //The following code has to be do after that.
11951 //For WDS station, use selfMac as the self BSSID
11952 if( CSR_IS_WDS_STA( pProfile ) )
11953 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011954 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11955 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011956 }
11957 }
11958 else
11959 {
11960 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011961 //Use the first SSID
11962 if(pProfile->SSIDs.numOfSSIDs)
11963 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011964 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11965 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011966 }
11967 //For WDS station, use selfMac as the self BSSID
11968 if( CSR_IS_WDS_STA( pProfile ) )
11969 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011970 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11971 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011972 }
11973 //Use the first BSSID
11974 else if( pProfile->BSSIDs.numOfBSSIDs )
11975 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011976 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11977 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011978 }
11979 else
11980 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011981 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011982 }
11983 }
11984 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011985 //Set operating channel in pProfile which will be used
11986 //in csrRoamSetBssConfigCfg() to determine channel bonding
11987 //mode and will be configured in CFG later
11988 pProfile->operationChannel = Channel;
11989
11990 if(Channel == 0)
11991 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053011992 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011993 }
11994 else
11995 {
11996
11997 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011998 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011999 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012000 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012001 {
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012002 /* TODO- SAP: HT40 Support in SAP 2.4Ghz mode is not enabled.
12003 so channel bonding in 2.4Ghz is configured as 20MHZ
12004 irrespective of the 'channelBondingMode24GHz' Parameter */
12005 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -070012006 }
12007 else
12008 {
12009 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12010 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012011 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070012012 pBssConfig->cbMode = cbMode;
12013 pSession->bssParams.cbMode = cbMode;
12014 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012015 }
12016}
12017
Jeff Johnson295189b2012-06-20 16:38:30 -070012018static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12019 tANI_BOOLEAN *pfSameIbss )
12020{
12021 eHalStatus status = eHAL_STATUS_SUCCESS;
12022 tANI_BOOLEAN fSameIbss = FALSE;
12023
12024 if ( csrIsConnStateIbss( pMac, sessionId ) )
12025 {
12026 // Check if any profile parameter has changed ? If any profile parameter
12027 // has changed then stop old BSS and start a new one with new parameters
12028 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12029 {
12030 fSameIbss = TRUE;
12031 }
12032 else
12033 {
12034 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12035 }
12036 }
12037 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12038 {
12039 // Disassociate from the connected Infrastructure network...
12040 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12041 }
12042 else
12043 {
12044 tBssConfigParam *pBssConfig;
12045
Kiet Lam64c1b492013-07-12 13:56:44 +053012046 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12047 if ( NULL == pBssConfig )
12048 status = eHAL_STATUS_FAILURE;
12049 else
12050 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012051 if(HAL_STATUS_SUCCESS(status))
12052 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012053 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012054 // there is no Bss description before we start an IBSS so we need to adopt
12055 // all Bss configuration parameters from the Profile.
12056 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12057 if(HAL_STATUS_SUCCESS(status))
12058 {
12059 //save dotMode
12060 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12061 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012062 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012063 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12064 NULL, pBssConfig,
12065 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012066 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012067
12068 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012069 }//Allocate memory
12070 }
12071
12072 if(pfSameIbss)
12073 {
12074 *pfSameIbss = fSameIbss;
12075 }
12076 return( status );
12077}
12078
Jeff Johnson295189b2012-06-20 16:38:30 -070012079static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12080 tSirSmeNewBssInfo *pNewBss )
12081{
12082 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012083
12084 if(!pSession)
12085 {
12086 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12087 return;
12088 }
12089
Jeff Johnson295189b2012-06-20 16:38:30 -070012090 if( pNewBss )
12091 {
12092 // Set the operating channel.
12093 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12094 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012095 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12096 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012097 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012098 return;
12099}
12100
Jeff Johnson295189b2012-06-20 16:38:30 -070012101#ifdef FEATURE_WLAN_WAPI
12102eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12103 tANI_U32 numItems )
12104{
12105 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12106 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012107 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12108 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012109 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012110 return status;
12111 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012112 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012113 pSession = CSR_GET_SESSION( pMac, sessionId );
12114 if(numItems <= CSR_MAX_BKID_ALLOWED)
12115 {
12116 status = eHAL_STATUS_SUCCESS;
12117 //numItems may be 0 to clear the cache
12118 pSession->NumBkidCache = (tANI_U16)numItems;
12119 if(numItems && pBKIDCache)
12120 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012121 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12122 sizeof(tBkidCacheInfo) * numItems);
12123 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012124 }
12125 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012126 return (status);
12127}
Jeff Johnson295189b2012-06-20 16:38:30 -070012128eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12129 tBkidCacheInfo *pBkidCache)
12130{
12131 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12132 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012133 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12134 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012135 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012136 return status;
12137 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012138 pSession = CSR_GET_SESSION( pMac, sessionId );
12139 if(pNum && pBkidCache)
12140 {
12141 if(pSession->NumBkidCache == 0)
12142 {
12143 *pNum = 0;
12144 status = eHAL_STATUS_SUCCESS;
12145 }
12146 else if(*pNum >= pSession->NumBkidCache)
12147 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012148 if(pSession->NumBkidCache > CSR_MAX_BKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012149 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012150 smsLog(pMac, LOGE, FL("NumBkidCache :%d is more than CSR_MAX_BKID_ALLOWED, resetting to CSR_MAX_BKID_ALLOWED"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012151 pSession->NumBkidCache);
Girish Gowli2c26e902014-10-20 22:18:17 +053012152 pSession->NumBkidCache = CSR_MAX_BKID_ALLOWED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012153 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012154 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12155 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012156 *pNum = pSession->NumBkidCache;
12157 status = eHAL_STATUS_SUCCESS;
12158 }
12159 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012160 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012161}
Jeff Johnson295189b2012-06-20 16:38:30 -070012162tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12163{
12164 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012165}
12166#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012167eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012168 tPmkidCacheInfo *pPMKIDCache,
12169 tANI_U32 numItems,
12170 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012171{
12172 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12173 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012174
12175 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012176 {
12177 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12178 return eHAL_STATUS_FAILURE;
12179 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012180
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012181 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012182
12183 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012184 {
12185#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12186 {
12187 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012188 vos_mem_set(&secEvent,
12189 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012190 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12191 secEvent.encryptionModeMulticast =
12192 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12193 secEvent.encryptionModeUnicast =
12194 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012195 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012196 secEvent.authMode =
12197 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12198 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12199 }
12200#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012201 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012202 if (update_entire_cache) {
12203 pSession->NumPmkidCache = (tANI_U16)numItems;
12204 if (numItems && pPMKIDCache)
12205 {
12206 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12207 sizeof(tPmkidCacheInfo) * numItems);
12208 }
12209 } else {
12210 tANI_U32 i = 0, j = 0;
12211 tANI_U8 BSSIDMatched = 0;
12212 tPmkidCacheInfo *pmksa;
12213
12214 for (i = 0; i < numItems; i++) {
12215 pmksa = &pPMKIDCache[i];
12216 for (j = 0; j < CSR_MAX_PMKID_ALLOWED; j++) {
12217 if (vos_mem_compare(pSession->PmkidCacheInfo[j].BSSID,
12218 pmksa->BSSID, VOS_MAC_ADDR_SIZE)) {
12219 /* If a matching BSSID found, update it */
12220 BSSIDMatched = 1;
12221 vos_mem_copy(pSession->PmkidCacheInfo[j].PMKID,
12222 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12223 break;
12224 }
12225 }
12226
12227 if (!BSSIDMatched) {
12228 vos_mem_copy(
12229 pSession->PmkidCacheInfo[pSession->NumPmkidCache].BSSID,
12230 pmksa->BSSID, VOS_MAC_ADDR_SIZE);
12231 vos_mem_copy(
12232 pSession->PmkidCacheInfo[pSession->NumPmkidCache].PMKID,
12233 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12234 /* Increment the CSR local cache index */
12235 if (pSession->NumPmkidCache < (CSR_MAX_PMKID_ALLOWED - 1))
12236 pSession->NumPmkidCache++;
12237 else
12238 pSession->NumPmkidCache = 0;
12239 }
12240 BSSIDMatched = 0;
12241 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012242 }
12243 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012244 return (status);
12245}
12246
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012247eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012248 tANI_U8 *pBSSId,
12249 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012250{
12251 eHalStatus status = eHAL_STATUS_FAILURE;
12252 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12253 tANI_BOOLEAN fMatchFound = FALSE;
12254 tANI_U32 Index;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012255
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012256 if(!pSession)
12257 {
12258 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12259 return eHAL_STATUS_FAILURE;
12260 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012261
12262 /* Check if there are no entries to delete */
12263 if (0 == pSession->NumPmkidCache) {
12264 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
12265 return eHAL_STATUS_SUCCESS;
12266 }
12267
12268 if (!flush_cache) {
12269 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
12270 if (vos_mem_compare(pSession->PmkidCacheInfo[Index].BSSID,
12271 pBSSId, VOS_MAC_ADDR_SIZE)) {
12272 fMatchFound = 1;
12273
12274 /* Clear this - the matched entry */
12275 vos_mem_zero(&pSession->PmkidCacheInfo[Index],
12276 sizeof(tPmkidCacheInfo));
12277 status = eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012278 break;
12279 }
12280 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012281
12282 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12283 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "MAC_ADDRESS_STR),
12284 MAC_ADDR_ARRAY(pBSSId));
12285 return status;
12286 }
12287
12288 return status;
12289 } else {
12290 /* Flush the entire cache */
12291 vos_mem_zero(pSession->PmkidCacheInfo,
12292 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12293 pSession->NumPmkidCache = 0;
12294 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012295 }
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012296}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012297
Jeff Johnson295189b2012-06-20 16:38:30 -070012298tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12299{
12300 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12301}
12302
Jeff Johnson295189b2012-06-20 16:38:30 -070012303eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12304{
12305 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12306 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012307
12308 if(!pSession)
12309 {
12310 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12311 return eHAL_STATUS_FAILURE;
12312 }
12313
Jeff Johnson295189b2012-06-20 16:38:30 -070012314 if(pNum && pPmkidCache)
12315 {
12316 if(pSession->NumPmkidCache == 0)
12317 {
12318 *pNum = 0;
12319 status = eHAL_STATUS_SUCCESS;
12320 }
12321 else if(*pNum >= pSession->NumPmkidCache)
12322 {
12323 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012325 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 -070012326 pSession->NumPmkidCache);
12327 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12328 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012329 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12330 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012331 *pNum = pSession->NumPmkidCache;
12332 status = eHAL_STATUS_SUCCESS;
12333 }
12334 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 return (status);
12336}
12337
Jeff Johnson295189b2012-06-20 16:38:30 -070012338eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12339{
12340 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12341 tANI_U32 len;
12342 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012343
12344 if(!pSession)
12345 {
12346 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12347 return eHAL_STATUS_FAILURE;
12348 }
12349
Jeff Johnson295189b2012-06-20 16:38:30 -070012350 if(pLen)
12351 {
12352 len = *pLen;
12353 *pLen = pSession->nWpaRsnReqIeLength;
12354 if(pBuf)
12355 {
12356 if(len >= pSession->nWpaRsnReqIeLength)
12357 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012358 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12359 pSession->nWpaRsnReqIeLength);
12360 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012361 }
12362 }
12363 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012364 return (status);
12365}
12366
Jeff Johnson295189b2012-06-20 16:38:30 -070012367eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12368{
12369 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12370 tANI_U32 len;
12371 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012372
12373 if(!pSession)
12374 {
12375 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12376 return eHAL_STATUS_FAILURE;
12377 }
12378
Jeff Johnson295189b2012-06-20 16:38:30 -070012379 if(pLen)
12380 {
12381 len = *pLen;
12382 *pLen = pSession->nWpaRsnRspIeLength;
12383 if(pBuf)
12384 {
12385 if(len >= pSession->nWpaRsnRspIeLength)
12386 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012387 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12388 pSession->nWpaRsnRspIeLength);
12389 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012390 }
12391 }
12392 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012393 return (status);
12394}
Jeff Johnson295189b2012-06-20 16:38:30 -070012395#ifdef FEATURE_WLAN_WAPI
12396eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12397{
12398 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12399 tANI_U32 len;
12400 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012401
12402 if(!pSession)
12403 {
12404 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12405 return eHAL_STATUS_FAILURE;
12406 }
12407
Jeff Johnson295189b2012-06-20 16:38:30 -070012408 if(pLen)
12409 {
12410 len = *pLen;
12411 *pLen = pSession->nWapiReqIeLength;
12412 if(pBuf)
12413 {
12414 if(len >= pSession->nWapiReqIeLength)
12415 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012416 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12417 pSession->nWapiReqIeLength);
12418 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012419 }
12420 }
12421 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012422 return (status);
12423}
Jeff Johnson295189b2012-06-20 16:38:30 -070012424eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12425{
12426 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12427 tANI_U32 len;
12428 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012429
12430 if(!pSession)
12431 {
12432 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12433 return eHAL_STATUS_FAILURE;
12434 }
12435
Jeff Johnson295189b2012-06-20 16:38:30 -070012436 if(pLen)
12437 {
12438 len = *pLen;
12439 *pLen = pSession->nWapiRspIeLength;
12440 if(pBuf)
12441 {
12442 if(len >= pSession->nWapiRspIeLength)
12443 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012444 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12445 pSession->nWapiRspIeLength);
12446 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012447 }
12448 }
12449 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012450 return (status);
12451}
12452#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012453eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12454{
12455 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12456 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012457
12458 if(!pSession)
12459 {
12460 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12461 return (retStatus);
12462 }
12463
Jeff Johnson295189b2012-06-20 16:38:30 -070012464 if(CSR_IS_ROAMING(pSession))
12465 {
12466 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12467 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12468 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012469 return (retStatus);
12470}
12471
Jeff Johnson295189b2012-06-20 16:38:30 -070012472//This function remove the connected BSS from te cached scan result
12473eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12474 tCsrRoamConnectedProfile *pConnProfile)
12475{
12476 eHalStatus status = eHAL_STATUS_FAILURE;
12477 tCsrScanResultFilter *pScanFilter = NULL;
12478 tListElem *pEntry;
12479 tCsrScanResult *pResult;
12480 tDot11fBeaconIEs *pIes;
12481 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012482 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12483 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12484 {
12485 do
12486 {
12487 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012488 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12489 if ( NULL == pScanFilter )
12490 status = eHAL_STATUS_FAILURE;
12491 else
12492 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012493 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012494 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12495 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12496 if ( NULL == pScanFilter->BSSIDs.bssid )
12497 status = eHAL_STATUS_FAILURE;
12498 else
12499 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012500 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012501 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12502 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012503 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12504 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12505 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012506 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12507 if ( NULL == pScanFilter->SSIDs.SSIDList )
12508 status = eHAL_STATUS_FAILURE;
12509 else
12510 status = eHAL_STATUS_SUCCESS;
12511 if (!HAL_STATUS_SUCCESS(status)) break;
12512 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12513 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012514 }
12515 pScanFilter->authType.numEntries = 1;
12516 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12517 pScanFilter->BSSType = pConnProfile->BSSType;
12518 pScanFilter->EncryptionType.numEntries = 1;
12519 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12520 pScanFilter->mcEncryptionType.numEntries = 1;
12521 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12522 //We ignore the channel for now, BSSID should be enough
12523 pScanFilter->ChannelInfo.numOfChannels = 0;
12524 //Also ignore the following fields
12525 pScanFilter->uapsd_mask = 0;
12526 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012527 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012528 pScanFilter->countryCode[0] = 0;
12529 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012530 csrLLLock(&pMac->scan.scanResultList);
12531 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12532 while( pEntry )
12533 {
12534 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12535 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12536 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12537 pScanFilter, NULL, NULL, NULL, &pIes);
12538 //Release the IEs allocated by csrMatchBSS is needed
12539 if( !pResult->Result.pvIes )
12540 {
12541 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012542 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012543 }
12544 if(fMatch)
12545 {
12546 //We found the one
12547 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12548 {
12549 //Free the memory
12550 csrFreeScanResultEntry( pMac, pResult );
12551 }
12552 break;
12553 }
12554 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12555 }//while
12556 csrLLUnlock(&pMac->scan.scanResultList);
12557 }while(0);
12558 if(pScanFilter)
12559 {
12560 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012561 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012562 }
12563 }
12564 return (status);
12565}
12566
Jeff Johnson295189b2012-06-20 16:38:30 -070012567//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012568eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12569{
12570 eHalStatus status = eHAL_STATUS_SUCCESS;
12571 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012572 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12573 {
12574 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12575 {
12576 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12577 {
12578 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012579 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012580 status = eHAL_STATUS_CSR_WRONG_STATE;
12581 break;
12582 }
12583 if( csrIsConnStateInfra( pMac, sessionId ) )
12584 {
12585 if( chnId &&
12586 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12587 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012588 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012589 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12590 status = eHAL_STATUS_CSR_WRONG_STATE;
12591 break;
12592 }
12593 }
12594 }
12595 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012596 return ( status );
12597}
12598
Jeff Johnson295189b2012-06-20 16:38:30 -070012599static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12600{
12601 eHalStatus status = eHAL_STATUS_SUCCESS;
12602 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12603 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012604
12605 if(!pSession)
12606 {
12607 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12608 return eHAL_STATUS_FAILURE;
12609 }
12610
Jeff Johnson295189b2012-06-20 16:38:30 -070012611 if ( csrIsConnStateIbss( pMac, sessionId ) )
12612 {
12613 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12614 }
12615 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12616 {
12617 // Disassociate from the connected Infrastructure network...
12618 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12619 }
12620 else
12621 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012622 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12623 //Otherwise we need to add code to handle the
12624 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12625 //send stop_bss to PE, before we can continue.
12626 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012627 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012628 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012629 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12630 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012631 // there is no Bss description before we start an WDS so we need
12632 // to adopt all Bss configuration parameters from the Profile.
12633 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12634 if(HAL_STATUS_SUCCESS(status))
12635 {
12636 //Save profile for late use
12637 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012638 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12639 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012640 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012641 vos_mem_set(pSession->pCurRoamProfile,
12642 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012643 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12644 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012645 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012646 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012647 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12648 NULL, &bssConfig,
12649 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012650 }
12651 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012652
Jeff Johnson295189b2012-06-20 16:38:30 -070012653 return( status );
12654}
12655
Jeff Johnson295189b2012-06-20 16:38:30 -070012656////////////////////Mail box
12657
Jeff Johnson295189b2012-06-20 16:38:30 -070012658//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12659//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012660static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12661 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012662 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12663{
12664 tCsrChannelSet channelGroup;
12665 tSirMacCapabilityInfo *pAP_capabilityInfo;
12666 tAniBool fTmp;
12667 tANI_BOOLEAN found = FALSE;
12668 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012669 tANI_S8 pwrLimit = 0;
12670 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012671 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12672 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12673 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12674 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012675 // 802.11h
12676 //We can do this because it is in HOST CPU order for now.
12677 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012678 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12679 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12680 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012681 fTmp = (tAniBool)pal_cpu_to_be32(1);
12682 }
12683 else
12684 fTmp = (tAniBool)0;
12685
12686 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012687 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012688 pBuf += sizeof(tAniBool);
12689 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012690 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012691 // This is required for 11k test VoWiFi Ent: Test 2.
12692 // We need the power capabilities for Assoc Req.
12693 // This macro is provided by the halPhyCfg.h. We pick our
12694 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012695 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12696 if (0 != pwrLimit)
12697 {
12698 *pBuf++ = pwrLimit;
12699 }
12700 else
12701 {
12702 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12703 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012704 size = sizeof(pMac->roam.validChannelList);
12705 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12706 {
12707 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12708 for ( i = 0; i < size; i++)
12709 {
12710 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12711
12712 }
12713 }
12714 else
12715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012716 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012717 *pBuf++ = 0; //tSirSupChnl->numChnl
12718 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012719 //Check whether it is ok to enter UAPSD
12720#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12721 if( btcIsReadyForUapsd(pMac) )
12722#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12723 {
12724 *pBuf++ = uapsdMask;
12725 }
12726#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12727 else
12728 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012729 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012730 *pBuf++ = 0;
12731 }
12732#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12733
Jeff Johnson295189b2012-06-20 16:38:30 -070012734 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012735 vos_mem_copy(pBuf, pBssDescription,
12736 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012737 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12738}
12739
Jeff Johnson295189b2012-06-20 16:38:30 -070012740/*
12741 * The communication between HDD and LIM is thru mailbox (MB).
12742 * Both sides will access the data structure "tSirSmeJoinReq".
12743 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12744 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12745 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12746 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12747 */
12748eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012749 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012750{
12751 eHalStatus status = eHAL_STATUS_SUCCESS;
12752 tSirSmeJoinReq *pMsg;
12753 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012754 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012755 tANI_U16 msgLen, wTmp, ieLen;
12756 tSirMacRateSet OpRateSet;
12757 tSirMacRateSet ExRateSet;
12758 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12759 tANI_U32 dwTmp;
12760 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012761 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053012762 tANI_U8 txBFCsnValue = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012763
12764 if(!pSession)
12765 {
12766 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12767 return eHAL_STATUS_FAILURE;
12768 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012769 /* To satisfy klockworks */
12770 if (NULL == pBssDescription)
12771 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012772 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012773 return eHAL_STATUS_FAILURE;
12774 }
12775
Jeff Johnson295189b2012-06-20 16:38:30 -070012776 do {
12777 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12778 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053012779 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012780 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12781 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12782 // IE fields, but the length field in the bssDescription needs to be interpreted to
12783 // determine length of the IE fields.
12784 //
12785 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12786 // add in the length from the bssDescription (then add the size of the 'length' field
12787 // itself because that is NOT included in the length field).
12788 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12789 pBssDescription->length + sizeof( pBssDescription->length ) +
12790 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 +053012791 pMsg = vos_mem_malloc(msgLen);
12792 if (NULL == pMsg)
12793 status = eHAL_STATUS_FAILURE;
12794 else
12795 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012796 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012797 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012798 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012799 pMsg->length = pal_cpu_to_be16(msgLen);
12800 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012801 // sessionId
12802 *pBuf = (tANI_U8)sessionId;
12803 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012804 // transactionId
12805 *pBuf = 0;
12806 *( pBuf + 1 ) = 0;
12807 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012808 // ssId
12809 if( pIes->SSID.present && pIes->SSID.num_ssid )
12810 {
12811 // ssId len
12812 *pBuf = pIes->SSID.num_ssid;
12813 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012814 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012815 pBuf += pIes->SSID.num_ssid;
12816 }
12817 else
12818 {
12819 *pBuf = 0;
12820 pBuf++;
12821 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012822 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012823 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12824 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012825 pBuf += sizeof(tSirMacAddr);
12826 // bsstype
12827 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12828 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012829 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012830 pBuf += sizeof(tSirBssType);
12831 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012832 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12833 if (pBssDescription->channelId <= 14 &&
12834 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12835 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12836 {
12837 //Need to disable VHT operation in 2.4 GHz band
12838 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12839 }
12840 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012841 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012842 //Persona
12843 *pBuf = (tANI_U8)pProfile->csrPersona;
12844 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012845 //CBMode
12846 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12847 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012848
12849 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012850 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12851
Jeff Johnson295189b2012-06-20 16:38:30 -070012852 // uapsdPerAcBitmask
12853 *pBuf = pProfile->uapsd_mask;
12854 pBuf++;
12855
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012856
12857
Jeff Johnson295189b2012-06-20 16:38:30 -070012858 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012859 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012860 {
12861 // OperationalRateSet
12862 if (OpRateSet.numRates) {
12863 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012864 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012865 pBuf += OpRateSet.numRates;
12866 } else *pBuf++ = 0;
12867 // ExtendedRateSet
12868 if (ExRateSet.numRates) {
12869 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012870 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012871 pBuf += ExRateSet.numRates;
12872 } else *pBuf++ = 0;
12873 }
12874 else
12875 {
12876 *pBuf++ = 0;
12877 *pBuf++ = 0;
12878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012879 // rsnIE
12880 if ( csrIsProfileWpa( pProfile ) )
12881 {
12882 // Insert the Wpa IE into the join request
12883 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12884 (tCsrWpaIe *)( wpaRsnIE ) );
12885 }
12886 else if( csrIsProfileRSN( pProfile ) )
12887 {
12888 // Insert the RSN IE into the join request
12889 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12890 (tCsrRSNIe *)( wpaRsnIE ) );
12891 }
12892#ifdef FEATURE_WLAN_WAPI
12893 else if( csrIsProfileWapi( pProfile ) )
12894 {
12895 // Insert the WAPI IE into the join request
12896 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12897 (tCsrWapiIe *)( wpaRsnIE ) );
12898 }
12899#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012900 else
12901 {
12902 ieLen = 0;
12903 }
12904 //remember the IE for future use
12905 if( ieLen )
12906 {
12907 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012909 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 -070012910 ieLen = DOT11F_IE_RSN_MAX_LEN;
12911 }
12912#ifdef FEATURE_WLAN_WAPI
12913 if( csrIsProfileWapi( pProfile ) )
12914 {
12915 //Check whether we need to allocate more memory
12916 if(ieLen > pSession->nWapiReqIeLength)
12917 {
12918 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12919 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012920 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012921 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012922 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12923 if (NULL == pSession->pWapiReqIE)
12924 status = eHAL_STATUS_FAILURE;
12925 else
12926 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012927 if(!HAL_STATUS_SUCCESS(status)) break;
12928 }
12929 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012930 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012931 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012932 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012933 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012934 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012935 pBuf += ieLen;
12936 }
12937 else//should be WPA/WPA2 otherwise
12938#endif /* FEATURE_WLAN_WAPI */
12939 {
12940 //Check whether we need to allocate more memory
12941 if(ieLen > pSession->nWpaRsnReqIeLength)
12942 {
12943 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12944 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012945 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012946 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012947 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12948 if (NULL == pSession->pWpaRsnReqIE)
12949 status = eHAL_STATUS_FAILURE;
12950 else
12951 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012952 if(!HAL_STATUS_SUCCESS(status)) break;
12953 }
12954 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012955 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012956 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012957 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012958 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012959 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012960 pBuf += ieLen;
12961 }
12962 }
12963 else
12964 {
12965 //free whatever old info
12966 pSession->nWpaRsnReqIeLength = 0;
12967 if(pSession->pWpaRsnReqIE)
12968 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012969 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012970 pSession->pWpaRsnReqIE = NULL;
12971 }
12972#ifdef FEATURE_WLAN_WAPI
12973 pSession->nWapiReqIeLength = 0;
12974 if(pSession->pWapiReqIE)
12975 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012976 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012977 pSession->pWapiReqIE = NULL;
12978 }
12979#endif /* FEATURE_WLAN_WAPI */
12980 //length is two bytes
12981 *pBuf = 0;
12982 *(pBuf + 1) = 0;
12983 pBuf += 2;
12984 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012985#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012986 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012988 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012989 //length is two bytes
12990 *pBuf = 0;
12991 *(pBuf + 1) = 0;
12992 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012993 }
12994 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012995 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012996 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012997 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012998 {
12999 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013000#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013001 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013002 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013003 pSession->suppCckmIeInfo.cckmIe, ieLen);
13004#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013005 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013006 pSession,
13007 pProfile,
13008 pBssDescription,
13009 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013010 pSession->nWpaRsnReqIeLength,
13011 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013012#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013013 }
13014 else
13015 {
13016 ieLen = 0;
13017 }
13018 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13019 if( ieLen )
13020 {
13021 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13022 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013023 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013024 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013025 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013026 pBuf += ieLen;
13027 }
13028 else
13029 {
13030 //Indicate you have no CCKM IE
13031 //length is two bytes
13032 *pBuf = 0;
13033 *(pBuf + 1) = 0;
13034 pBuf += 2;
13035 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013036 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013037#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013038 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013039 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013040 {
13041 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013042 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013043 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013044 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013045 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013046 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013047 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013048 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013049 pBuf += ieLen;
13050 }
13051 else
13052 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013053 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013054 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013055 *pBuf = 0;
13056 *(pBuf + 1) = 0;
13057 pBuf += 2;
13058 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013059 // addIEAssoc
13060 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13061 {
13062 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013063 if(ieLen > pSession->nAddIEAssocLength)
13064 {
13065 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013066 {
13067 vos_mem_free(pSession->pAddIEAssoc);
13068 }
13069 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13070 if (NULL == pSession->pAddIEAssoc)
13071 status = eHAL_STATUS_FAILURE;
13072 else
13073 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013074 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013075 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013076 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013077 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013078 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013079 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013080 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013081 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013082 pBuf += ieLen;
13083 }
13084 else
13085 {
13086 pSession->nAddIEAssocLength = 0;
13087 if(pSession->pAddIEAssoc)
13088 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013089 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013090 pSession->pAddIEAssoc = NULL;
13091 }
13092 *pBuf = 0;
13093 *(pBuf + 1) = 0;
13094 pBuf += 2;
13095 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013096
13097 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013098 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013099 //Unmask any AC in reassoc that is ACM-set
13100 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13101 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013102 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013103 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13104 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013105#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013106 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013107#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013108 }
13109 else
13110 {
13111 uapsd_mask = 0;
13112 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013113 }
13114 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013115
Jeff Johnson295189b2012-06-20 16:38:30 -070013116 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013117 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013118 pBuf += sizeof(tANI_U32);
13119
Jeff Johnson295189b2012-06-20 16:38:30 -070013120 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013121 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013122 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013123#ifdef WLAN_FEATURE_11W
13124 //MgmtEncryption
13125 if (pProfile->MFPEnabled)
13126 {
13127 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13128 }
13129 else
13130 {
13131 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13132 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013133 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013134 pBuf += sizeof(tANI_U32);
13135#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013136#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013137 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013138 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013139#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013140 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013141 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013142#endif
13143 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013144 {
13145 // is11Rconnection;
13146 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013147 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013148 pBuf += sizeof(tAniBool);
13149 }
13150 else
13151 {
13152 // is11Rconnection;
13153 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013154 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013155 pBuf += sizeof(tAniBool);
13156 }
13157#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013158#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013159
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013160 // isESEFeatureIniEnabled
13161 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013162 {
13163 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013164 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013165 pBuf += sizeof(tAniBool);
13166 }
13167 else
13168 {
13169 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013170 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013171 pBuf += sizeof(tAniBool);
13172 }
13173
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013174 /* A profile can not be both ESE and 11R. But an 802.11R AP
13175 * may be advertising support for ESE as well. So if we are
13176 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013177 * If we are associating explictly 11R only then we will get
13178 * 11R.
13179 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013180 if ((csrIsProfileESE(pProfile) ||
13181 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013182 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13183 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13184 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13185 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13186#ifdef WLAN_FEATURE_11W
13187 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
13188#endif
13189 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013190 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013191 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013192 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013193 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013194 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013195 pBuf += sizeof(tAniBool);
13196 }
13197 else
13198 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013199 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013200 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013201 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013202 pBuf += sizeof(tAniBool);
13203 }
13204
13205 if (eWNI_SME_JOIN_REQ == messageType)
13206 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013207 tESETspecInfo eseTspec;
13208 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013209 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013210 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13211 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13212 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013213 }
13214 else if (eWNI_SME_REASSOC_REQ == messageType)
13215 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013216 if ((csrIsProfileESE(pProfile) ||
13217 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013218 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13219 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13220 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13221 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13222#ifdef WLAN_FEATURE_11W
13223 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
13224#endif
13225 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013226 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013227 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013228 tESETspecInfo eseTspec;
13229 // ESE Tspec information
13230 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13231 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13232 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013233 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013234 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013235 if (eseTspec.numTspecs) {
13236 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13237 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013238 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013239 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013240 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013241 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013242 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013243 tESETspecInfo eseTspec;
13244 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013246 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13247 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13248 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013249 }
13250 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013251#endif // FEATURE_WLAN_ESE
13252#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013253 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013254 if (pMac->roam.configParam.isFastTransitionEnabled
13255#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013256 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013257#endif
13258 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013259 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013260 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013261 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013262 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013263 }
13264 else
13265 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013266 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013267 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013268 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013269 }
13270#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013271#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013272 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013273 {
13274 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013275 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013276 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013277 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013278 }
13279 else
13280 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013281 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013282 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013283 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013284 }
13285#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013286
13287 // txLdpcIniFeatureEnabled
13288 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13289 pBuf++;
13290
Kiran4a17ebe2013-01-31 10:43:43 -080013291 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13292 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13293 {
13294 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13295 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13296 csrApplyPower2Current(pMac);
13297 }
13298
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013299#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013300 // txBFIniFeatureEnabled
13301 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13302 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013303
13304 // txBFCsnValue
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013305 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13306 if (pIes->VHTCaps.present)
13307 {
13308 txBFCsnValue = CSR_ROAM_MIN(txBFCsnValue, pIes->VHTCaps.numSoundingDim);
13309 }
13310 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013311 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053013312
13313 /* Only enable MuBf if no other MuBF session exist
13314 * and FW and HOST is MuBF capable.
13315 */
13316 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
13317 {
13318 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
13319 pBuf++;
13320 }
13321 else
13322 {
13323 *pBuf = 0;
13324 pBuf++;
13325 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013326#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013327 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13328 pBuf++;
13329
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013330 // WME
13331 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13332 {
13333 //WME enabled
13334 dwTmp = pal_cpu_to_be32(TRUE);
13335 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13336 pBuf += sizeof(tAniBool);
13337 }
13338 else
13339 {
13340 dwTmp = pal_cpu_to_be32(FALSE);
13341 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13342 pBuf += sizeof(tAniBool);
13343 }
13344
13345 // QOS
13346 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13347 {
13348 //QOS enabled
13349 dwTmp = pal_cpu_to_be32(TRUE);
13350 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13351 pBuf += sizeof(tAniBool);
13352 }
13353 else
13354 {
13355 dwTmp = pal_cpu_to_be32(FALSE);
13356 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13357 pBuf += sizeof(tAniBool);
13358 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013359 //BssDesc
13360 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13361 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013362
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013363 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053013364 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
13365 pMsg = NULL;
13366
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013367 if(!HAL_STATUS_SUCCESS(status))
13368 {
13369 break;
13370 }
13371 else
13372 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013373#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013374 if (eWNI_SME_JOIN_REQ == messageType)
13375 {
13376 //Tush-QoS: notify QoS module that join happening
13377 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13378 }
13379 else if (eWNI_SME_REASSOC_REQ == messageType)
13380 {
13381 //Tush-QoS: notify QoS module that reassoc happening
13382 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13383 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013384#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013385 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013386 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053013387
13388 if (pMsg != NULL)
13389 {
13390 vos_mem_free( pMsg );
13391 }
13392
Jeff Johnson295189b2012-06-20 16:38:30 -070013393 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013394}
13395
Jeff Johnson295189b2012-06-20 16:38:30 -070013396//
13397eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13398{
13399 eHalStatus status = eHAL_STATUS_SUCCESS;
13400 tSirSmeDisassocReq *pMsg;
13401 tANI_U8 *pBuf;
13402 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013403 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13404 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13405 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013406 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013407 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13408 if (NULL == pMsg)
13409 status = eHAL_STATUS_FAILURE;
13410 else
13411 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013412 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013413 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013414 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13415 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013416 pBuf = &pMsg->sessionId;
13417 // sessionId
13418 *pBuf++ = (tANI_U8)sessionId;
13419 // transactionId
13420 *pBuf = 0;
13421 *( pBuf + 1 ) = 0;
13422 pBuf += sizeof(tANI_U16);
13423
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013424 if ( (pSession->pCurRoamProfile != NULL) &&
13425 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13426 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013427 {
13428 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013429 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13430 sizeof( tSirMacAddr ));
13431 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013432 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013433 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013434 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13435 //perMacAddr is passed as bssId for softAP
13436 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013437 pBuf = pBuf + sizeof ( tSirMacAddr );
13438 }
13439 else
13440 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013441 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013442 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13443 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013444 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013445 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13446 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013447 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013448 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013449 if(!HAL_STATUS_SUCCESS(status))
13450 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013451 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013452 break;
13453 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013454 // reasonCode
13455 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013456 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13457 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013458 if(!HAL_STATUS_SUCCESS(status))
13459 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013460 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013461 break;
13462 }
13463 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013464 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13465 Here we should not send the disassoc over the air to the AP */
13466 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13467#ifdef WLAN_FEATURE_VOWIFI_11R
13468 && csrRoamIs11rAssoc(pMac)
13469#endif
13470 )
13471 {
13472 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13473 }
13474 pBuf += sizeof(tANI_U8);
13475 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013476 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013477 return( status );
13478}
Jeff Johnson295189b2012-06-20 16:38:30 -070013479eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13480{
13481 eHalStatus status = eHAL_STATUS_SUCCESS;
13482 tSirSmeTkipCntrMeasReq *pMsg;
13483 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013484 do
13485 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013486 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13487 if ( NULL == pMsg )
13488 status = eHAL_STATUS_FAILURE;
13489 else
13490 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013491 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013492 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013493 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13494 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 pBuf = &pMsg->sessionId;
13496 // sessionId
13497 *pBuf++ = (tANI_U8)sessionId;
13498 // transactionId
13499 *pBuf = 0;
13500 *( pBuf + 1 ) = 0;
13501 pBuf += sizeof(tANI_U16);
13502 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013503 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13504 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013505 pBuf = pBuf + sizeof ( tSirMacAddr );
13506 // bEnable
13507 *pBuf = (tANI_BOOLEAN)bEnable;
13508 if(!HAL_STATUS_SUCCESS(status))
13509 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013510 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013511 break;
13512 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013513 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013514 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 return( status );
13516}
Jeff Johnson295189b2012-06-20 16:38:30 -070013517eHalStatus
13518csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13519 VOS_MODULE_ID modId, tSirMacAddr bssId,
13520 void *pUsrContext, void *pfnSapEventCallback,
13521 tANI_U8 *pAssocStasBuf )
13522{
13523 eHalStatus status = eHAL_STATUS_SUCCESS;
13524 tSirSmeGetAssocSTAsReq *pMsg;
13525 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13526 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013527 do
13528 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013529 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13530 if ( NULL == pMsg )
13531 status = eHAL_STATUS_FAILURE;
13532 else
13533 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013534 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013535 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013536 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013537 pBuf = (tANI_U8 *)&pMsg->bssId;
13538 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013539 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013540 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013541 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013542 // modId
13543 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013544 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013545 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013547 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13548 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013549 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013550 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13551 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013552 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013553 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13554 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013555 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013556 status = palSendMBMessage( pMac->hHdd, pMsg );
13557 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013558 return( status );
13559 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013560eHalStatus
13561csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13562 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13563 {
13564 eHalStatus status = eHAL_STATUS_SUCCESS;
13565 tSirSmeGetWPSPBCSessionsReq *pMsg;
13566 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013567
Jeff Johnson295189b2012-06-20 16:38:30 -070013568 do
13569 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013570 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13571 if ( NULL == pMsg )
13572 status = eHAL_STATUS_FAILURE;
13573 else
13574 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013575 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013576 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013578 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013579 VOS_ASSERT(pBuf);
13580
Jeff Johnson295189b2012-06-20 16:38:30 -070013581 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013582 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013583 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13584 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013585 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013586 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13587 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013588 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013589 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013590 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013591 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013592 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013593 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013594 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013595 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013596 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013597 return( status );
13598}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013599
13600eHalStatus
13601csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13602{
13603 tpSirChangeBIParams pMsg;
13604 tANI_U16 len = 0;
13605 eHalStatus status = eHAL_STATUS_SUCCESS;
13606 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13607
13608 if(!pSession)
13609 {
13610 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13611 return eHAL_STATUS_FAILURE;
13612 }
13613
13614 //NO need to update the Beacon Params if update beacon parameter flag is not set
13615 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13616 return eHAL_STATUS_SUCCESS;
13617
13618 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13619
13620 /* Create the message and send to lim */
13621 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013622 pMsg = vos_mem_malloc(len);
13623 if ( NULL == pMsg )
13624 status = eHAL_STATUS_FAILURE;
13625 else
13626 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013627 if(HAL_STATUS_SUCCESS(status))
13628 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013629 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013630 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13631 pMsg->length = len;
13632
13633 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013634 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13635 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013636 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13637 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013638 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013639 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013640 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13641 status = palSendMBMessage(pMac->hHdd, pMsg);
13642 }
13643 return status;
13644}
13645
Jeff Johnson295189b2012-06-20 16:38:30 -070013646eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13647{
13648 eHalStatus status = eHAL_STATUS_SUCCESS;
13649 tSirSmeDeauthReq *pMsg;
13650 tANI_U8 *pBuf;
13651 tANI_U16 wTmp;
13652 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13653 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13654 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013655 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013656 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13657 if ( NULL == pMsg )
13658 status = eHAL_STATUS_FAILURE;
13659 else
13660 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013661 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013662 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013663 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13664 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13665 //sessionId
13666 pBuf = &pMsg->sessionId;
13667 *pBuf++ = (tANI_U8)sessionId;
13668
13669 //tansactionId
13670 *pBuf = 0;
13671 *(pBuf + 1 ) = 0;
13672 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013675 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13676 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013677 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13678 sizeof( pMsg->peerMacAddr ) );
13679 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013680 pBuf = pBuf + sizeof(tSirMacAddr);
13681 }
13682 else
13683 {
13684 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013685 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13686 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 }
13689 if(!HAL_STATUS_SUCCESS(status))
13690 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013691 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013692 break;
13693 }
13694 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013695 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13696 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013697 pBuf = pBuf + sizeof(tSirMacAddr);
13698 if(!HAL_STATUS_SUCCESS(status))
13699 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013700 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013701 break;
13702 }
13703 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013704 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13705 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 if(!HAL_STATUS_SUCCESS(status))
13707 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013708 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013709 break;
13710 }
13711 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013712 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013713 return( status );
13714}
13715
Jeff Johnson295189b2012-06-20 16:38:30 -070013716eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13717{
13718 eHalStatus status = eHAL_STATUS_SUCCESS;
13719 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013720 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013721 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13722 if ( NULL == pMsg )
13723 status = eHAL_STATUS_FAILURE;
13724 else
13725 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013726 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013727 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013728 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13729 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13730 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013731 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13732 sizeof(pMsg->peerMacAddr));
13733 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013734 if(!HAL_STATUS_SUCCESS(status))
13735 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013736 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013737 break;
13738 }
13739//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013740 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13741 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013742 if(!HAL_STATUS_SUCCESS(status))
13743 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013744 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013745 break;
13746 }
13747//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013748 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013749 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013750 return( status );
13751}
13752
Jeff Johnson295189b2012-06-20 16:38:30 -070013753eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13754{
13755 eHalStatus status = eHAL_STATUS_SUCCESS;
13756 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013757 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013758 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13759 if ( NULL == pMsg )
13760 status = eHAL_STATUS_FAILURE;
13761 else
13762 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013764 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013765 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13766 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13767 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013768 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13769 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013770 if(!HAL_STATUS_SUCCESS(status))
13771 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013772 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013773 break;
13774 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013775 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13776 sizeof(pMsg->peerMacAddr));
13777 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013778 if(!HAL_STATUS_SUCCESS(status))
13779 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013780 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013781 break;
13782 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013784 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013785 return( status );
13786}
Jeff Johnson295189b2012-06-20 16:38:30 -070013787eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13788{
13789 eHalStatus status = eHAL_STATUS_SUCCESS;
13790 tSirSmeAssocCnf *pMsg;
13791 tANI_U8 *pBuf;
13792 tSirResultCodes statusCode;
13793 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013794 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013795 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13796 if ( NULL == pMsg )
13797 status = eHAL_STATUS_FAILURE;
13798 else
13799 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013800 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013801 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013802 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13803 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 pBuf = (tANI_U8 *)&pMsg->statusCode;
13805 if(HAL_STATUS_SUCCESS(Halstatus))
13806 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13807 else
13808 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013809 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013810 pBuf += sizeof(tSirResultCodes);
13811 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013812 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13813 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013814 pBuf += sizeof (tSirMacAddr);
13815 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013816 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13817 sizeof(tSirMacAddr));
13818 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013819 pBuf += sizeof (tSirMacAddr);
13820 // aid
13821 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013822 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013823 pBuf += sizeof (tANI_U16);
13824 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013825 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13826 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013827 pBuf += sizeof (tSirMacAddr);
13828 // alternateChannelId
13829 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013830 status = palSendMBMessage( pMac->hHdd, pMsg );
13831 if(!HAL_STATUS_SUCCESS(status))
13832 {
13833 //pMsg is freed by palSendMBMessage
13834 break;
13835 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013837 return( status );
13838}
Jeff Johnson295189b2012-06-20 16:38:30 -070013839eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13840 tpSirSmeAssocInd pAssocInd,
13841 eHalStatus Halstatus,
13842 tANI_U8 sessionId)
13843{
13844 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013845 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13846 tANI_U8 *pBuf;
13847 tSirResultCodes statusCode;
13848 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013849 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013850 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13851 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13852 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013853
Jeff Johnson295189b2012-06-20 16:38:30 -070013854 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13855 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13856
13857 pMsg->sessionId = sessionId;
13858
13859 pBuf = (tANI_U8 *)&pMsg->statusCode;
13860 if(HAL_STATUS_SUCCESS(Halstatus))
13861 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13862 else
13863 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013864 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013865 pBuf += sizeof(tSirResultCodes);
13866 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013867 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013868 pBuf += sizeof (tSirMacAddr);
13869 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013870 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13871 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013872 pBuf += sizeof (tSirMacAddr);
13873 // StaId
13874 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013875 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013876 pBuf += sizeof (tANI_U16);
13877 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013878 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013879 pBuf += sizeof (tSirMacAddr);
13880 // alternateChannelId
13881 *pBuf = 11;
13882 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013883 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013884 //Wmm
13885 *pBuf = pAssocInd->wmmEnabledSta;
13886 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013887 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013888 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013889 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013890 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013891 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013892 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 //reassocReq
13894 *pBuf = pAssocInd->reassocReq;
13895 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013896 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13897 msgQ.bodyptr = pMsg;
13898 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013899 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013900 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013901 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013902}
Jeff Johnson295189b2012-06-20 16:38:30 -070013903
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013904eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013905 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13906 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13907 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13908 tANI_U8 *pKeyRsc )
13909{
13910 tSirSmeSetContextReq *pMsg;
13911 tANI_U16 msgLen;
13912 eHalStatus status = eHAL_STATUS_FAILURE;
13913 tAniEdType tmpEdType;
13914 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013915 tANI_U8 *pBuf = NULL;
13916 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013917 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Sushant Kaushike7de85f2014-06-16 17:13:30 +053013918 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
13919 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013920 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013921 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013922 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13923 // key set. Since we only support upto one key, we always allocate memory for 1 key
13924 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13925 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13926 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13927 ( sizeof( pMsg->keyMaterial.key ) );
13928
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_SETCONTEXT_REQ);
13933 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013934 //sessionId
13935 pBuf = &pMsg->sessionId;
13936 *pBuf = (tANI_U8)sessionId;
13937 pBuf++;
13938 // transactionId
13939 *pBuf = 0;
13940 *(pBuf + 1) = 0;
13941 pBuf += sizeof(tANI_U16);
13942 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013943 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013944
13945 pBuf += sizeof(tSirMacAddr);
13946
13947 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013948 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13949 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013950
13951 pBuf += sizeof(tSirMacAddr);
13952
13953 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013954 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13955 // in the tSirKeyMaterial keyMaterial; field).
13956 //
13957 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13958 // shorter than this max size. Is LIM interpreting this ok ?
13959 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 -070013960 // set pMsg->keyMaterial.edType
13961 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013962 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013963 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013964 // set the pMsg->keyMaterial.numKeys field
13965 *p = numKeys;
13966 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013967 // set pSirKey->keyId = keyId;
13968 *p = keyId;
13969 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 // set pSirKey->unicast = (tANI_U8)fUnicast;
13971 *p = (tANI_U8)fUnicast;
13972 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013973 // set pSirKey->keyDirection = aniKeyDirection;
13974 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013975 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013976 p += sizeof(tAniKeyDirection);
13977 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013978 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 // set pSirKey->paeRole
13981 *p = paeRole; // 0 is Supplicant
13982 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013983 // set pSirKey->keyLength = keyLength;
13984 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013985 if ( keyLength && pKey )
13986 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013987 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 if(keyLength == 16)
13989 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013990 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 -070013991 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13992 pKey[5], pKey[6], pKey[7], pKey[8],
13993 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13994 }
13995 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013996 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013997 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013998 return( status );
13999}
14000
Jeff Johnson295189b2012-06-20 16:38:30 -070014001eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
14002 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
14003{
14004 eHalStatus status;
14005 tSirSmeStartBssReq *pMsg;
14006 tANI_U8 *pBuf = NULL;
14007 tANI_U8 *wTmpBuf = NULL;
14008 tANI_U16 msgLen, wTmp;
14009 tANI_U32 dwTmp;
14010 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070014011 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014012 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014014
14015 if(!pSession)
14016 {
14017 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14018 return eHAL_STATUS_FAILURE;
14019 }
14020
Jeff Johnson295189b2012-06-20 16:38:30 -070014021 do {
14022 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
14023 pSession->joinFailStatusCode.reasonCode = 0;
14024 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014025 pMsg = vos_mem_malloc(msgLen);
14026 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14027 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014028 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014029 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014030 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014031 //sessionId
14032 *pBuf = (tANI_U8)sessionId;
14033 pBuf++;
14034 // transactionId
14035 *pBuf = 0;
14036 *(pBuf + 1) = 0;
14037 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014038 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014039 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014040 pBuf += sizeof(tSirMacAddr);
14041 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014042 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014043 pBuf += sizeof(tSirMacAddr);
14044 // beaconInterval
14045 if( pBssDesc && pBssDesc->beaconInterval )
14046 {
14047 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
14048 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014049 else if(pParam->beaconInterval)
14050 {
14051 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
14052 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014053 else
14054 {
14055 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
14056 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070014057 if(csrIsconcurrentsessionValid (pMac, sessionId,
14058 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070014059 == eHAL_STATUS_SUCCESS )
14060 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014061 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070014062 pParam->bssPersona);
14063 //Update the beacon Interval
14064 pParam->beaconInterval = wTmp;
14065 }
14066 else
14067 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014068 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014069 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053014070 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070014071 return status;
14072 }
14073
Kiet Lam64c1b492013-07-12 13:56:44 +053014074 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014075 pBuf += sizeof(tANI_U16);
14076 // dot11mode
14077 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
14078 pBuf += 1;
14079 // bssType
14080 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053014081 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014082 pBuf += sizeof(tSirBssType);
14083 // ssId
14084 if( pParam->ssId.length )
14085 {
14086 // ssId len
14087 *pBuf = pParam->ssId.length;
14088 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014089 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070014090 pBuf += pParam->ssId.length;
14091 }
14092 else
14093 {
14094 *pBuf = 0;
14095 pBuf++;
14096 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014097 // set the channel Id
14098 *pBuf = pParam->operationChn;
14099 pBuf++;
14100 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070014101 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014102 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070014103 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014104
Jeff Johnson295189b2012-06-20 16:38:30 -070014105 // Set privacy
14106 *pBuf = pParam->privacy;
14107 pBuf++;
14108
14109 //Set Uapsd
14110 *pBuf = pParam->ApUapsdEnable;
14111 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014112 //Set SSID hidden
14113 *pBuf = pParam->ssidHidden;
14114 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014115 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
14116 pBuf++;
14117
14118 //Ht protection Enable/Disable
14119 *pBuf = (tANI_U8)pParam->protEnabled;
14120 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014121 //Enable Beacons to Receive for OBSS protection Enable/Disable
14122 *pBuf = (tANI_U8)pParam->obssProtEnabled;
14123 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014124 //set cfg related to protection
14125 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053014126 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014127 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014128 // Set Auth type
14129 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014130 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014131 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014132 // Set DTIM
14133 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053014134 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014135 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014136 // Set wps_state
14137 *pBuf = pParam->wps_state;
14138 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080014139 // set isCoalesingInIBSSAllowed
14140 *pBuf = pMac->isCoalesingInIBSSAllowed;
14141 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014142 //Persona
14143 *pBuf = (tANI_U8)pParam->bssPersona;
14144 pBuf++;
14145
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080014146 //txLdpcIniFeatureEnabled
14147 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
14148 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070014149
Chet Lanctot8cecea22014-02-11 19:09:36 -080014150#ifdef WLAN_FEATURE_11W
14151 // Set MFP capable/required
14152 *pBuf = (tANI_U8)pParam->mfpCapable;
14153 pBuf++;
14154 *pBuf = (tANI_U8)pParam->mfpRequired;
14155 pBuf++;
14156#endif
14157
krunal soni4f087d22013-07-29 16:32:26 -070014158 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070014159 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
14160 {
14161 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053014162 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014163 break;
14164 }
14165 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053014166 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014167 pBuf += sizeof(tANI_U16);
14168 if( wTmp )
14169 {
14170 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053014171 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014172 pBuf += wTmp;
14173 }
14174 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014175 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014176 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014177 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
14178 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014179 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
14180 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070014181 pBuf += pParam->operationalRateSet.numRates ;
14182 *pBuf++ = pParam->extendedRateSet.numRates;
14183 if(0 != pParam->extendedRateSet.numRates)
14184 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014185 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
14186 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070014187 pBuf += pParam->extendedRateSet.numRates;
14188 }
krunal sonie9002db2013-11-25 14:24:17 -080014189
Jeff Johnson295189b2012-06-20 16:38:30 -070014190 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
14191 pMsg->length = pal_cpu_to_be16(msgLen);
14192
14193 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014194 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014195 return( status );
14196}
14197
Jeff Johnson295189b2012-06-20 16:38:30 -070014198eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
14199{
14200 eHalStatus status = eHAL_STATUS_FAILURE;
14201 tSirSmeStopBssReq *pMsg;
14202 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14203 tANI_U8 *pBuf;
14204 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070014205
14206 if(!pSession)
14207 {
14208 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14209 return eHAL_STATUS_FAILURE;
14210 }
14211
Jeff Johnson295189b2012-06-20 16:38:30 -070014212 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014213 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14214 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14215 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014216 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14217 pBuf = &pMsg->sessionId;
14218 //sessionId
14219 *pBuf = (tANI_U8)sessionId;
14220 pBuf++;
14221 // transactionId
14222 *pBuf = 0;
14223 pBuf += sizeof(tANI_U16);
14224 //reason code
14225 *pBuf = 0;
14226 pBuf += sizeof(tSirResultCodes);
14227 // bssid
14228 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14229 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14230 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014231 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
14232 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014233 }
14234 else
14235 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014236 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14237 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014238 }
14239 pBuf += sizeof(tSirMacAddr);
14240 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
14241 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014242 status = palSendMBMessage( pMac->hHdd, pMsg );
14243#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053014244 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14245 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14246 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014247 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14248 pMsg->reasonCode = 0;
14249 // bssid
14250 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14251 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14252 {
14253 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
14254 }
14255 else
14256 {
14257 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
14258 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014259 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014260 pMsg->transactionId = 0;
14261 pMsg->sessionId = (tANI_U8)sessionId;
14262 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
14263 status = palSendMBMessage( pMac->hHdd, pMsg );
14264#endif
14265 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014266 return( status );
14267}
14268
Jeff Johnson295189b2012-06-20 16:38:30 -070014269eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14270 tCsrRoamModifyProfileFields *pModProfileFields,
14271 tANI_U32 *pRoamId, v_BOOL_t fForce)
14272{
Jeff Johnson295189b2012-06-20 16:38:30 -070014273 eHalStatus status = eHAL_STATUS_FAILURE;
14274 tANI_U32 roamId = 0;
14275 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014276 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014277 (fForce || (!vos_mem_compare( &pModProfileFields,
14278 &pSession->connectedProfile.modifyProfileFields,
14279 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014280 {
14281 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14282 if(pRoamId)
14283 {
14284 *pRoamId = roamId;
14285 }
14286
Jeff Johnson295189b2012-06-20 16:38:30 -070014287 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14288 eCsrSmeIssuedReassocToSameAP, roamId,
14289 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014290 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014291 return status;
14292}
Jeff Johnson295189b2012-06-20 16:38:30 -070014293static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14294{
14295 eHalStatus status = eHAL_STATUS_SUCCESS;
14296 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014297 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014298 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14299 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14300 return (status);
14301}
Jeff Johnson295189b2012-06-20 16:38:30 -070014302eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14303{
14304 eHalStatus status = eHAL_STATUS_SUCCESS;
14305 tListElem *pEntry = NULL;
14306 tSmeCmd *pCommand = NULL;
14307 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014308 do
14309 {
14310 if(pMsg == NULL)
14311 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014312 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014313 status = eHAL_STATUS_FAILURE;
14314 break;
14315 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014316 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14317 if(pEntry)
14318 {
14319 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14320 if(eSmeCommandAddStaSession == pCommand->command)
14321 {
14322 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014323 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053014324 if (pRsp->status == eSIR_FAILURE) {
14325 VOS_ASSERT( 0 );
14326 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014327 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014328 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014329 //Remove this command out of the active list
14330 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14331 {
14332 //Now put this command back on the avilable command list
14333 csrReleaseCommand(pMac, pCommand);
14334 }
14335 smeProcessPendingQueue( pMac );
14336 }
14337 else
14338 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014339 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 -070014340 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014341 status = eHAL_STATUS_FAILURE;
14342 break;
14343 }
14344 }
14345 else
14346 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014347 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 -070014348 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014349 status = eHAL_STATUS_FAILURE;
14350 break;
14351 }
14352 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014353 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014354}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014355eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14356 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014357{
14358 tSirSmeAddStaSelfReq *pMsg;
14359 tANI_U16 msgLen;
14360 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014361 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014362 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014363 pMsg = vos_mem_malloc(msgLen);
14364 if ( NULL == pMsg ) break;
14365 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014366 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14367 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014368 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014369 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014370 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14371
14372 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14373
Arif Hussain24bafea2013-11-15 15:10:03 -080014374 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14375 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014376 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014377 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014378 return( status );
14379}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014380eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14381 tANI_U32 sessionId,
14382 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014383{
14384 eHalStatus status = eHAL_STATUS_SUCCESS;
14385 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014386 pCommand = csrGetCommandBuffer(pMac);
14387 if(NULL == pCommand)
14388 {
14389 status = eHAL_STATUS_RESOURCES;
14390 }
14391 else
14392 {
14393 pCommand->command = eSmeCommandAddStaSession;
14394 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014395 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14396 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014397 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014398 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14399 if( !HAL_STATUS_SUCCESS( status ) )
14400 {
14401 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014402 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014403 }
14404 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014405 return (status);
14406}
Jeff Johnson295189b2012-06-20 16:38:30 -070014407eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14408{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014409 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014410}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014411eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14412 csrRoamCompleteCallback callback,
14413 void *pContext, tANI_U8 *pSelfMacAddr,
14414 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014415{
14416 eHalStatus status = eHAL_STATUS_SUCCESS;
14417 tANI_U32 i;
14418 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014419 *pbSessionId = CSR_SESSION_ID_INVALID;
14420 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14421 {
14422 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14423 {
14424 pSession = CSR_GET_SESSION( pMac, i );
14425 status = eHAL_STATUS_SUCCESS;
14426 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14427 pSession->sessionId = (tANI_U8)i;
14428 pSession->callback = callback;
14429 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014430 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014431 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014432 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14433 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014434 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014435 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014436 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014437 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014438 break;
14439 }
14440#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014441 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14442 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014443 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014444 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014445 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014446 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014447 break;
14448 }
14449#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014450 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014451 break;
14452 }
14453 }
14454 if( CSR_ROAM_SESSION_MAX == i )
14455 {
14456 //No session is available
14457 status = eHAL_STATUS_RESOURCES;
14458 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014459 return ( status );
14460}
Jeff Johnson295189b2012-06-20 16:38:30 -070014461eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14462{
14463 eHalStatus status = eHAL_STATUS_SUCCESS;
14464 tListElem *pEntry = NULL;
14465 tSmeCmd *pCommand = NULL;
14466 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014467 do
14468 {
14469 if(pMsg == NULL)
14470 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014471 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014472 status = eHAL_STATUS_FAILURE;
14473 break;
14474 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014475 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14476 if(pEntry)
14477 {
14478 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14479 if(eSmeCommandDelStaSession == pCommand->command)
14480 {
14481 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014482 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014483 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014484 //This session is done.
14485 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014486 if(pCommand->u.delStaSessionCmd.callback)
14487 {
14488
14489 status = sme_ReleaseGlobalLock( &pMac->sme );
14490 if ( HAL_STATUS_SUCCESS( status ) )
14491 {
14492 pCommand->u.delStaSessionCmd.callback(
14493 pCommand->u.delStaSessionCmd.pContext);
14494 status = sme_AcquireGlobalLock( &pMac->sme );
14495 if (! HAL_STATUS_SUCCESS( status ) )
14496 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014497 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014498 return status;
14499 }
14500 }
14501 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014502 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014503 }
14504 }
14505
14506 //Remove this command out of the active list
14507 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14508 {
14509 //Now put this command back on the avilable command list
14510 csrReleaseCommand(pMac, pCommand);
14511 }
14512 smeProcessPendingQueue( pMac );
14513 }
14514 else
14515 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014516 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 -070014517 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014518 status = eHAL_STATUS_FAILURE;
14519 break;
14520 }
14521 }
14522 else
14523 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014524 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 -070014525 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014526 status = eHAL_STATUS_FAILURE;
14527 break;
14528 }
14529 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014530 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014531}
Jeff Johnson295189b2012-06-20 16:38:30 -070014532eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14533{
14534 tSirSmeDelStaSelfReq *pMsg;
14535 tANI_U16 msgLen;
14536 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014537 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014538 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14539 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014540 pMsg = vos_mem_malloc(msgLen);
14541 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14542 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014543 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14544 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014545 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014546 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14547 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014548 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014549 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014550 return( status );
14551}
Jeff Johnson295189b2012-06-20 16:38:30 -070014552eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14553 tSirMacAddr sessionMacAddr,
14554 csrRoamSessionCloseCallback callback,
14555 void *pContext)
14556{
14557 eHalStatus status = eHAL_STATUS_SUCCESS;
14558 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014559 pCommand = csrGetCommandBuffer(pMac);
14560 if(NULL == pCommand)
14561 {
14562 status = eHAL_STATUS_RESOURCES;
14563 }
14564 else
14565 {
14566 pCommand->command = eSmeCommandDelStaSession;
14567 pCommand->sessionId = (tANI_U8)sessionId;
14568 pCommand->u.delStaSessionCmd.callback = callback;
14569 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014570 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14571 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014572 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14573 if( !HAL_STATUS_SUCCESS( status ) )
14574 {
14575 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014576 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014577 }
14578 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014579 return (status);
14580}
Jeff Johnson295189b2012-06-20 16:38:30 -070014581eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14582{
14583 return csrSendMBDelSelfStaReqMsg( pMac,
14584 pCommand->u.delStaSessionCmd.selfMacAddr );
14585}
Jeff Johnson295189b2012-06-20 16:38:30 -070014586static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14587{
14588 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14589 tListElem *pEntry, *pNext;
14590 tSmeCmd *pCommand;
14591 tDblLinkList localList;
14592
14593 vos_mem_zero(&localList, sizeof(tDblLinkList));
14594 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14595 {
14596 smsLog(pMac, LOGE, FL(" failed to open list"));
14597 return;
14598 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014599 csrLLLock(pList);
14600 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14601 while(pEntry != NULL)
14602 {
14603 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14604 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14605 if(pCommand->sessionId == sessionId)
14606 {
14607 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14608 {
14609 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14610 }
14611 }
14612 pEntry = pNext;
14613 }
14614 csrLLUnlock(pList);
14615
14616 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14617 {
14618 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14619 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14620 }
14621 csrLLClose(&localList);
14622}
14623
Jeff Johnson295189b2012-06-20 16:38:30 -070014624void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14625{
14626 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14627 {
14628 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014629 csrRoamStop(pMac, sessionId);
14630 csrFreeConnectBssDesc(pMac, sessionId);
14631 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14632 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014633 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014634#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014635 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014636#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014637 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14638 if (pMac->fScanOffload)
14639 {
14640 purgeSmeSessionCmdList(pMac, sessionId,
14641 &pMac->sme.smeScanCmdPendingList);
14642 }
14643
Jeff Johnson295189b2012-06-20 16:38:30 -070014644 purgeCsrSessionCmdList(pMac, sessionId);
14645 csrInitSession(pMac, sessionId);
14646 }
14647}
14648
Jeff Johnson295189b2012-06-20 16:38:30 -070014649eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14650 tANI_BOOLEAN fSync,
14651 csrRoamSessionCloseCallback callback,
14652 void *pContext )
14653{
14654 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014655 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14656 {
14657 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14658 if(fSync)
14659 {
14660 csrCleanupSession(pMac, sessionId);
14661 }
14662 else
14663 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014664 purgeSmeSessionCmdList(pMac, sessionId,
14665 &pMac->sme.smeCmdPendingList);
14666 if (pMac->fScanOffload)
14667 {
14668 purgeSmeSessionCmdList(pMac, sessionId,
14669 &pMac->sme.smeScanCmdPendingList);
14670 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014671 purgeCsrSessionCmdList(pMac, sessionId);
14672 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14673 pSession->selfMacAddr, callback, pContext);
14674 }
14675 }
14676 else
14677 {
14678 status = eHAL_STATUS_INVALID_PARAMETER;
14679 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014680 return ( status );
14681}
14682
Jeff Johnson295189b2012-06-20 16:38:30 -070014683static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14684{
14685 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014686
14687 if(!pSession)
14688 {
14689 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14690 return;
14691 }
14692
Jeff Johnson295189b2012-06-20 16:38:30 -070014693 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14694 pSession->sessionId = CSR_SESSION_ID_INVALID;
14695 pSession->callback = NULL;
14696 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014697 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14698 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14699 csrFreeRoamProfile( pMac, sessionId );
14700 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14701 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14702 csrFreeConnectBssDesc(pMac, sessionId);
14703 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014704 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14705 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014706 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014707 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014708 pSession->pWpaRsnReqIE = NULL;
14709 }
14710 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014711 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014712 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014713 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014714 pSession->pWpaRsnRspIE = NULL;
14715 }
14716 pSession->nWpaRsnRspIeLength = 0;
14717#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014718 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014719 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014720 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014721 pSession->pWapiReqIE = NULL;
14722 }
14723 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014724 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014725 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014726 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014727 pSession->pWapiRspIE = NULL;
14728 }
14729 pSession->nWapiRspIeLength = 0;
14730#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014731 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014732 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014733 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014734 }
14735 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014736
Kiet Lam64c1b492013-07-12 13:56:44 +053014737 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014738 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014739 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014740 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014741 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014742 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014743}
14744
Jeff Johnson295189b2012-06-20 16:38:30 -070014745eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14746{
14747 eHalStatus status = eHAL_STATUS_FAILURE;
14748 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014749 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14750 {
14751 if( CSR_IS_SESSION_VALID( pMac, i ) )
14752 {
14753 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14754 {
14755 //Found it
14756 status = eHAL_STATUS_SUCCESS;
14757 *pSessionId = i;
14758 break;
14759 }
14760 }
14761 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014762 return( status );
14763}
14764
Jeff Johnson295189b2012-06-20 16:38:30 -070014765//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14766//session because for IBSS, the bssid changes.
14767static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14768{
14769 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14770 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014771 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14772 {
14773 if( CSR_IS_SESSION_VALID( pMac, i ) )
14774 {
14775 pSession = CSR_GET_SESSION( pMac, i );
14776 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14777 {
14778 //Found it
14779 nRet = i;
14780 break;
14781 }
14782 }
14783 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014784 return (nRet);
14785}
Jeff Johnson295189b2012-06-20 16:38:30 -070014786static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14787{
Mukul Sharma20aa6582014-08-07 21:36:12 +053014788 VOS_STATUS status = VOS_STATUS_SUCCESS;
14789
14790 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070014791 profile info from pmac global structure */
14792
Arif Hussain24bafea2013-11-15 15:10:03 -080014793 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14794 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014795 /* Check for user misconfig of RSSI trigger threshold */
14796 pMac->roam.configParam.vccRssiThreshold =
14797 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14798 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14799 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014800 /* Check for user misconfig of UL MAC Loss trigger threshold */
14801 pMac->roam.configParam.vccUlMacLossThreshold =
14802 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14803 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014804#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14805 {
14806 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014807 /* Indicate the neighbor roal algorithm about the connect indication */
14808 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14809 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053014810
14811 // Making sure we are roaming force fully to 5GHz AP only once and
14812 // only when we connected to 2.4GH AP only during initial association.
14813 if(pMac->roam.neighborRoamInfo.cfgParams.neighborInitialForcedRoamTo5GhEnable &&
14814 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel) == SIR_BAND_2_4_GHZ)
14815 {
14816 //Making ini value to false here only so we just roam to
14817 //only once for whole driver load to unload tenure
14818 pMac->roam.neighborRoamInfo.cfgParams.neighborInitialForcedRoamTo5GhEnable = VOS_FALSE;
14819
14820 status = vos_timer_start(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer,
14821 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
14822 //MUKUL TODO: change the neighborResultsRefreshPeriod to some ini value reuqired ??
14823 if ( status != VOS_STATUS_SUCCESS )
14824 {
14825 smsLog(pMac, LOGE, FL("%s Neighbor forcedInitialRoamTo5GHTimer start failed with status %d"), __func__, status);
14826 }
14827 smsLog(pMac, LOGE, FL("%s: Forced roam to 5G started Timer"), __func__);
14828 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014829 }
14830#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014831}
14832
Jeff Johnson295189b2012-06-20 16:38:30 -070014833static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14834{
14835 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014836
14837 if(!pSession)
14838 {
14839 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14840 return;
14841 }
14842
Jeff Johnson295189b2012-06-20 16:38:30 -070014843 //Only to handle the case for Handover on infra link
14844 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14845 {
14846 return;
14847 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014848 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14849 csrRoamDeregStatisticsReq(pMac);
14850 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14851#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14852 /* Indicate the neighbor roal algorithm about the disconnect indication */
14853 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14854#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014855
14856 //Remove this code once SLM_Sessionization is supported
14857 //BMPS_WORKAROUND_NOT_NEEDED
14858 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014859 csrIsInfraApStarted( pMac ) &&
14860 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014861 {
14862 pMac->roam.configParam.doBMPSWorkaround = 0;
14863 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014864}
14865
Jeff Johnson295189b2012-06-20 16:38:30 -070014866void csrRoamTlStatsTimerHandler(void *pv)
14867{
14868 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14869 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014870 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14871
Jeff Johnsone7245742012-09-05 17:12:55 -070014872 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14873
Jeff Johnson295189b2012-06-20 16:38:30 -070014874#if 0
14875 // TODO Persession .???
14876 //req TL for stats
14877 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14878 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014879 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014880 }
14881 else
14882 {
14883 //save in SME
14884 csrRoamSaveStatsFromTl(pMac, tlStats);
14885 }
14886#endif
14887 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14888 {
14889 if(pMac->roam.tlStatsReqInfo.periodicity)
14890 {
14891 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014892 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14893 pMac->roam.tlStatsReqInfo.periodicity);
14894 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014895 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014896 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014897 return;
14898 }
14899 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14900 }
14901 }
14902}
Jeff Johnson295189b2012-06-20 16:38:30 -070014903void csrRoamPeStatsTimerHandler(void *pv)
14904{
14905 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14906 eHalStatus status;
14907 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14908 VOS_STATUS vosStatus;
14909 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014910 pPeStatsReqListEntry->timerRunning = FALSE;
14911 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14912 {
14913 // If we entered here, meaning the timer could not be successfully
14914 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14915
14916 /* Destroy the timer */
14917 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14918 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14919 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014920 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014921 }
14922
14923 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014924 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014925 pPeStatsReqListEntry = NULL;
14926 }
14927 else
14928 {
14929 if(!pPeStatsReqListEntry->rspPending)
14930 {
14931 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14932 pPeStatsReqListEntry->staId);
14933 if(!HAL_STATUS_SUCCESS(status))
14934 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014935 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014936 }
14937 else
14938 {
14939 pPeStatsReqListEntry->rspPending = TRUE;
14940 }
14941 }
14942
14943 //send down a req
14944 if(pPeStatsReqListEntry->periodicity &&
14945 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14946 {
14947 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14948 if(ePMC_FULL_POWER == powerState)
14949 {
14950 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14951 {
14952 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14953 }
14954 }
14955 else
14956 {
14957 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14958 {
14959 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14960 }
14961 }
14962 //start timer
14963 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14964 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14965 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014966 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 return;
14968 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014969 pPeStatsReqListEntry->timerRunning = TRUE;
14970
14971 }
14972
14973 }
14974}
Jeff Johnson295189b2012-06-20 16:38:30 -070014975void csrRoamStatsClientTimerHandler(void *pv)
14976{
14977 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014978 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14979 {
14980#if 0
14981 // TODO Stats fix for multisession
14982 //start the timer
14983 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14984
14985 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14986 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014987 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014988 }
14989#endif
14990 }
14991#if 0
14992 //send up the stats report
14993 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14994 pStaEntry->staId, pStaEntry->pContext);
14995#endif
14996}
14997
14998
14999
Jeff Johnson295189b2012-06-20 16:38:30 -070015000eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
15001{
15002 tAniGetPEStatsReq *pMsg;
15003 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053015004 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
15005 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015006 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015007 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053015008 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015009 }
15010 // need to initiate a stats request to PE
15011 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
15012 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
15013 pMsg->staId = staId;
15014 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015015 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015016 if(!HAL_STATUS_SUCCESS(status))
15017 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015018 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070015019 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015020 return status;
15021}
Jeff Johnson295189b2012-06-20 16:38:30 -070015022void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
15023{
15024 tAniGetPEStatsRsp *pSmeStatsRsp;
15025 eHalStatus status = eHAL_STATUS_FAILURE;
15026 tListElem *pEntry = NULL;
15027 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15028 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15029 tANI_U32 tempMask = 0;
15030 tANI_U8 counter = 0;
15031 tANI_U8 *pStats = NULL;
15032 tANI_U32 length = 0;
15033 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015034 v_S7_t rssi = 0, snr = 0;
15035 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015036 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015037 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
15038 if(pSmeStatsRsp->rc)
15039 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015040 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015041 goto post_update;
15042 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015043 tempMask = pSmeStatsRsp->statsMask;
15044 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070015045 /* subtract all statistics from this length, and after processing the entire
15046 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
15047 * in this 'stats' message.
15048 */
15049 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015050 //new stats info from PE, fill up the stats strucutres in PMAC
15051 while(tempMask)
15052 {
15053 if(tempMask & 1)
15054 {
15055 switch(counter)
15056 {
15057 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015058 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015059 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
15060 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015061 pStats += sizeof(tCsrSummaryStatsInfo);
15062 length -= sizeof(tCsrSummaryStatsInfo);
15063 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015064 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015065 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015066 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
15067 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015068 pStats += sizeof(tCsrGlobalClassAStatsInfo);
15069 length -= sizeof(tCsrGlobalClassAStatsInfo);
15070 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015071 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015072 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015073 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
15074 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015075 pStats += sizeof(tCsrGlobalClassBStatsInfo);
15076 length -= sizeof(tCsrGlobalClassBStatsInfo);
15077 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015078 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015079 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015080 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
15081 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015082 pStats += sizeof(tCsrGlobalClassCStatsInfo);
15083 length -= sizeof(tCsrGlobalClassCStatsInfo);
15084 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015085 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015086 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015087 if( CSR_MAX_STA > pSmeStatsRsp->staId )
15088 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015089 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
15090 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015091 }
15092 else
15093 {
15094 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015095 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015096 VOS_ASSERT( 0 );
15097 }
15098 if(!HAL_STATUS_SUCCESS(status))
15099 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015100 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015101 }
15102 pStats += sizeof(tCsrPerStaStatsInfo);
15103 length -= sizeof(tCsrPerStaStatsInfo);
15104 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015105 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015106 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015107 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015108 }
15109 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015110 tempMask >>=1;
15111 counter++;
15112 }
15113 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
15114 if (length != 0)
15115 {
15116 pRssi = (tANI_U32*)pStats;
15117 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015118 pStats += sizeof(tANI_U32);
15119 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015120 }
15121 else
15122 {
15123 /* If riva is not sending rssi, continue to use the hack */
15124 rssi = RSSI_HACK_BMPS;
15125 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015126
Jeff Johnson295189b2012-06-20 16:38:30 -070015127 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015128
15129 if (length != 0)
15130 {
15131 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015132 pStats += sizeof(tANI_U32);
15133 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015134 }
15135 else
15136 {
15137 linkCapacity = 0;
15138 }
15139
15140 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015141
15142 if (length != 0)
15143 {
15144 pSnr = (tANI_U32*)pStats;
15145 snr = (v_S7_t)*pSnr;
15146 }
15147 else
15148 {
15149 snr = SNR_HACK_BMPS;
15150 }
15151
15152 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015153post_update:
15154 //make sure to update the pe stats req list
15155 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
15156 if(pEntry)
15157 {
15158 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
15159 pPeStaEntry->rspPending = FALSE;
15160
15161 }
15162 //check the one timer cases
15163 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
15164 if(pEntry)
15165 {
Jeff Johnson295189b2012-06-20 16:38:30 -070015166 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015167 if(pTempStaEntry->timerExpired)
15168 {
15169 //send up the stats report
15170 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15171 pTempStaEntry->staId, pTempStaEntry->pContext);
15172 //also remove from the client list
15173 csrRoamRemoveStatListEntry(pMac, pEntry);
15174 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015175 }
15176 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015177}
Jeff Johnson295189b2012-06-20 16:38:30 -070015178tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15179{
15180 tListElem *pEntry = NULL;
15181 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015182 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015183 if(!pEntry)
15184 {
15185 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015186 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015187 return NULL;
15188 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015189 while( pEntry )
15190 {
15191 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015192 if(pTempStaEntry->statsMask == statsMask)
15193 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015194 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015195 break;
15196 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015197 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15198 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015199 return pEntry;
15200}
15201
Jeff Johnson295189b2012-06-20 16:38:30 -070015202tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
15203 tANI_BOOLEAN update)
15204{
15205 tListElem *pEntry;
15206 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015207 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015208 if(!pEntry)
15209 {
15210 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015211 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015212 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015213 return NULL;
15214 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015215 while( pEntry )
15216 {
15217 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015218 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
15219 (pTempStaEntry->statsMask == pStaEntry->statsMask))
15220 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015221 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015222 if(update)
15223 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015224 pTempStaEntry->periodicity = pStaEntry->periodicity;
15225 pTempStaEntry->callback = pStaEntry->callback;
15226 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015227 }
15228 break;
15229 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015230 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15231 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015232 return pEntry;
15233}
Jeff Johnson295189b2012-06-20 16:38:30 -070015234tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15235{
15236 tListElem *pEntry;
15237 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015238 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015239 if(!pEntry)
15240 {
15241 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015242 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015243 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015244 return NULL;
15245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015246 while( pEntry )
15247 {
15248 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015249 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
15250 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015251 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015252 break;
15253 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015254 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15255 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015256 return pEntry;
15257}
Jeff Johnson295189b2012-06-20 16:38:30 -070015258eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
15259 csrRoamLinkQualityIndCallback callback,
15260 void *pContext)
15261{
15262 pMac->roam.linkQualityIndInfo.callback = callback;
15263 pMac->roam.linkQualityIndInfo.context = pContext;
15264 if( NULL == callback )
15265 {
15266 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
15267 }
15268 else
15269 {
15270 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070015271 /* do we need to invoke the callback to notify client of initial value ?? */
15272 }
15273 return eHAL_STATUS_SUCCESS;
15274}
Jeff Johnson295189b2012-06-20 16:38:30 -070015275void csrRoamVccTrigger(tpAniSirGlobal pMac)
15276{
15277 eCsrRoamLinkQualityInd newVccLinkQuality;
15278 tANI_U32 ul_mac_loss = 0;
15279 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015280 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15281 /*-------------------------------------------------------------------------
15282 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015283 Check for a change in link quality and notify client if necessary
15284 -------------------------------------------------------------------------*/
15285 ul_mac_loss_trigger_threshold =
15286 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015287 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015288 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015289 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015290 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15291 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015292 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015293 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15294 }
15295 else
15296 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015297 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015298 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15299 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015300 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15301 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015302 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015304 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015305 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15306 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015307 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015308 newVccLinkQuality );
15309
15310 /* we now invoke the callback once to notify client of initial value */
15311 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15312 pMac->roam.linkQualityIndInfo.context );
15313 //event: EVENT_WLAN_VCC
15314 }
15315 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015316 pMac->roam.vccLinkQuality = newVccLinkQuality;
15317
Jeff Johnson295189b2012-06-20 16:38:30 -070015318}
Jeff Johnson295189b2012-06-20 16:38:30 -070015319VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15320 v_U8_t rssiNotification,
15321 void * context)
15322{
15323 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15324 eCsrRoamLinkQualityInd newVccLinkQuality;
15325 // TODO : Session info unavailable
15326 tANI_U32 sessionId = 0;
15327 VOS_STATUS status = VOS_STATUS_SUCCESS;
15328 /*-------------------------------------------------------------------------
15329 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015330 Check for a change in link quality and notify client if necessary
15331 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015332 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015333 pMac->roam.configParam.vccRssiThreshold);
15334 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15335 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015336 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015337 return VOS_STATUS_SUCCESS;
15338 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015339 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15340 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015341 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015342 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15343 }
15344 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15345 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015346 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015347 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15348 }
15349 else
15350 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015351 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015352 //Set to this so the code below won't do anything
15353 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015354 VOS_ASSERT(0);
15355 }
15356
Jeff Johnson295189b2012-06-20 16:38:30 -070015357 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15358 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015359 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015360 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15361 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015362 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015363 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015364 /* we now invoke the callback once to notify client of initial value */
15365 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15366 pMac->roam.linkQualityIndInfo.context );
15367 //event: EVENT_WLAN_VCC
15368 }
15369 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015370 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015371 return status;
15372}
Jeff Johnson295189b2012-06-20 16:38:30 -070015373tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15374 tDblLinkList *pStaList,
15375 tCsrStatsClientReqInfo *pStaEntry)
15376{
15377 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015378 //if same entity requested for same set of stats with different periodicity &
15379 // callback update it
15380 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15381 {
15382
Kiet Lam64c1b492013-07-12 13:56:44 +053015383 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15384 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015385 {
15386 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015387 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015388 return NULL;
15389 }
15390
Jeff Johnson295189b2012-06-20 16:38:30 -070015391 pNewStaEntry->callback = pStaEntry->callback;
15392 pNewStaEntry->pContext = pStaEntry->pContext;
15393 pNewStaEntry->periodicity = pStaEntry->periodicity;
15394 pNewStaEntry->requesterId = pStaEntry->requesterId;
15395 pNewStaEntry->statsMask = pStaEntry->statsMask;
15396 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15397 pNewStaEntry->pMac = pStaEntry->pMac;
15398 pNewStaEntry->staId = pStaEntry->staId;
15399 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15400
15401 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15402 }
15403 return pNewStaEntry;
15404}
15405
Jeff Johnson295189b2012-06-20 16:38:30 -070015406tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15407 tDblLinkList *pStaList,
15408 tCsrPeStatsReqInfo *pStaEntry)
15409{
15410 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015411 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15412 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015413 {
15414 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015415 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015416 return NULL;
15417 }
15418
Jeff Johnson295189b2012-06-20 16:38:30 -070015419 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15420 pNewStaEntry->numClient = pStaEntry->numClient;
15421 pNewStaEntry->periodicity = pStaEntry->periodicity;
15422 pNewStaEntry->statsMask = pStaEntry->statsMask;
15423 pNewStaEntry->pMac = pStaEntry->pMac;
15424 pNewStaEntry->staId = pStaEntry->staId;
15425 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15426 pNewStaEntry->rspPending = pStaEntry->rspPending;
15427
15428 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015429 return pNewStaEntry;
15430}
Jeff Johnson295189b2012-06-20 16:38:30 -070015431eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15432 tCsrRssiCallback callback,
15433 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15434{
15435 eHalStatus status = eHAL_STATUS_SUCCESS;
15436 vos_msg_t msg;
15437 tANI_U32 sessionId;
15438
15439 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015440 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015441 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15442 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015443 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015444 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015445 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015446 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015447 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15448
15449 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15450 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15451 pMsg->sessionId = sessionId;
15452 pMsg->staId = staId;
15453 pMsg->rssiCallback = callback;
15454 pMsg->pDevContext = pContext;
15455 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015456 msg.type = eWNI_SME_GET_RSSI_REQ;
15457 msg.bodyptr = pMsg;
15458 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015459 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15460 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015461 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015462 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015463 status = eHAL_STATUS_FAILURE;
15464 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015465 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015466 return status;
15467}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015468
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015469eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15470 tCsrSnrCallback callback,
15471 tANI_U8 staId, tCsrBssid bssId,
15472 void *pContext)
15473{
15474 eHalStatus status = eHAL_STATUS_SUCCESS;
15475 vos_msg_t msg;
15476 tANI_U32 sessionId;
15477
15478 tAniGetSnrReq *pMsg;
15479
15480 smsLog(pMac, LOG2, FL("called"));
15481
15482 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15483 if (NULL == pMsg )
15484 {
15485 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15486 return status;
15487 }
15488
15489 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15490
15491 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15492 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15493 pMsg->sessionId = sessionId;
15494 pMsg->staId = staId;
15495 pMsg->snrCallback = callback;
15496 pMsg->pDevContext = pContext;
15497 msg.type = eWNI_SME_GET_SNR_REQ;
15498 msg.bodyptr = pMsg;
15499 msg.reserved = 0;
15500
15501 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15502 {
15503 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15504 vos_mem_free((v_VOID_t *)pMsg);
15505 status = eHAL_STATUS_FAILURE;
15506 }
15507
15508 smsLog(pMac, LOG2, FL("returned"));
15509 return status;
15510}
15511
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015512#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015513eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15514 tCsrRssiCallback callback,
15515 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15516{
15517 eHalStatus status = eHAL_STATUS_SUCCESS;
15518 tAniGetRssiReq *pMsg;
15519
Kiet Lam64c1b492013-07-12 13:56:44 +053015520 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15521 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015522 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015523 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015524 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015525 }
15526 // need to initiate a stats request to PE
15527 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15528 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15529 pMsg->staId = staId;
15530 pMsg->rssiCallback = callback;
15531 pMsg->pDevContext = pContext;
15532 pMsg->pVosContext = pVosContext;
15533 status = palSendMBMessage(pMac->hHdd, pMsg );
15534 if(!HAL_STATUS_SUCCESS(status))
15535 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015536 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015537 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015538 status = eHAL_STATUS_FAILURE;
15539 }
15540 return status;
15541}
15542#endif
15543
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015544
15545
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015546#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015547eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15548 tCsrTsmStatsCallback callback,
15549 tANI_U8 staId,
15550 tCsrBssid bssId,
15551 void *pContext,
15552 void* pVosContext,
15553 tANI_U8 tid)
15554{
15555 eHalStatus status = eHAL_STATUS_SUCCESS;
15556 tAniGetTsmStatsReq *pMsg = NULL;
15557
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015558 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15559 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015560 {
15561 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015562 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015563 }
15564 // need to initiate a stats request to PE
15565 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15566 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15567 pMsg->staId = staId;
15568 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015569 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015570 pMsg->tsmStatsCallback = callback;
15571 pMsg->pDevContext = pContext;
15572 pMsg->pVosContext = pVosContext;
15573 status = palSendMBMessage(pMac->hHdd, pMsg );
15574 if(!HAL_STATUS_SUCCESS(status))
15575 {
15576 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15577 //pMsg is freed by palSendMBMessage
15578 status = eHAL_STATUS_FAILURE;
15579 }
15580 return status;
15581}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015582#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015583
15584
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015585/* ---------------------------------------------------------------------------
15586 \fn csrGetTLSTAState
15587 \helper function to get teh TL STA State whenever the function is called.
15588
15589 \param staId - The staID to be passed to the TL
15590 to get the relevant TL STA State
15591 \return the state as tANI_U16
15592 ---------------------------------------------------------------------------*/
15593tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15594{
15595 WLANTL_STAStateType tlSTAState;
15596 tlSTAState = WLANTL_STA_INIT;
15597
15598 //request TL for STA State
15599 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15600 {
15601 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15602 }
15603
15604 return tlSTAState;
15605}
15606
Jeff Johnson295189b2012-06-20 16:38:30 -070015607eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15608 tANI_U32 statsMask,
15609 tCsrStatsCallback callback,
15610 tANI_U32 periodicity, tANI_BOOLEAN cache,
15611 tANI_U8 staId, void *pContext)
15612{
15613 tCsrStatsClientReqInfo staEntry;
15614 tCsrStatsClientReqInfo *pStaEntry = NULL;
15615 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15616 tListElem *pEntry = NULL;
15617 tANI_BOOLEAN found = FALSE;
15618 eHalStatus status = eHAL_STATUS_SUCCESS;
15619 tANI_BOOLEAN insertInClientList = FALSE;
15620 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015621 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015622
15623 if( csrIsAllSessionDisconnected(pMac) )
15624 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015625 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015626 return eHAL_STATUS_FAILURE;
15627 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015628
15629 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15630 {
15631 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15632 return eHAL_STATUS_FAILURE;
15633 }
15634
Jeff Johnson295189b2012-06-20 16:38:30 -070015635 if((!statsMask) && (!callback))
15636 {
15637 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015638 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015639 return eHAL_STATUS_FAILURE;
15640 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015641 //for the search list method for deregister
15642 staEntry.requesterId = requesterId;
15643 staEntry.statsMask = statsMask;
15644 //requester wants to deregister or just an error
15645 if((statsMask) && (!callback))
15646 {
15647 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15648 if(!pEntry)
15649 {
15650 //msg
15651 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015652 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015653 return eHAL_STATUS_FAILURE;
15654 }
15655 else
15656 {
15657 //clean up & return
15658 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015659 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015660 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015661 pStaEntry->pPeStaEntry->numClient--;
15662 //check if we need to delete the entry from peStatsReqList too
15663 if(!pStaEntry->pPeStaEntry->numClient)
15664 {
15665 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15666 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015667 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015668
Jeff Johnson295189b2012-06-20 16:38:30 -070015669 //check if we need to stop the tl stats timer too
15670 pMac->roam.tlStatsReqInfo.numClient--;
15671 if(!pMac->roam.tlStatsReqInfo.numClient)
15672 {
15673 if(pMac->roam.tlStatsReqInfo.timerRunning)
15674 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015675 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15676 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015677 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015678 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015679 return eHAL_STATUS_FAILURE;
15680 }
15681 }
15682 pMac->roam.tlStatsReqInfo.periodicity = 0;
15683 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15684 }
15685 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015686 // Destroy the vos timer...
15687 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15688 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15689 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015690 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015691 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015692 csrRoamRemoveStatListEntry(pMac, pEntry);
15693 pStaEntry = NULL;
15694 return eHAL_STATUS_SUCCESS;
15695 }
15696 }
15697
15698 if(cache && !periodicity)
15699 {
15700 //return the cached stats
15701 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15702 }
15703 else
15704 {
15705 //add the request in the client req list
15706 staEntry.callback = callback;
15707 staEntry.pContext = pContext;
15708 staEntry.periodicity = periodicity;
15709 staEntry.pPeStaEntry = NULL;
15710 staEntry.staId = staId;
15711 staEntry.pMac = pMac;
15712 staEntry.timerExpired = FALSE;
15713
15714
Jeff Johnson295189b2012-06-20 16:38:30 -070015715 //if periodic report requested with non cached result from PE/TL
15716 if(periodicity)
15717 {
15718
15719 //if looking for stats from PE
15720 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15721 {
15722
15723 //check if same request made already & waiting for rsp
15724 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15725 periodicity, &found, staId);
15726 if(!pPeStaEntry)
15727 {
15728 //bail out, maxed out on number of req for PE
15729 return eHAL_STATUS_FAILURE;
15730 }
15731 else
15732 {
15733 staEntry.pPeStaEntry = pPeStaEntry;
15734 }
15735
15736 }
15737 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15738 if(statsMask & (1 << eCsrGlobalClassDStats))
15739 {
15740 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15741 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015742 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015743 }
15744 else
15745 {
15746
15747 //update periodicity
15748 if(pMac->roam.tlStatsReqInfo.periodicity)
15749 {
15750 pMac->roam.tlStatsReqInfo.periodicity =
15751 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15752 }
15753 else
15754 {
15755 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15756 }
15757 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15758 {
15759 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15760 }
15761
15762 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15763 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015764 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015765 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015766 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015767 //req TL for class D stats
15768 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015770 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015771 }
15772 else
15773 {
15774 //save in SME
15775 csrRoamSaveStatsFromTl(pMac, pTlStats);
15776 }
15777 vos_mem_free(pTlStats);
15778 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015779 }
15780 else
15781 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015782 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015783 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015784
Jeff Johnson295189b2012-06-20 16:38:30 -070015785 if(pMac->roam.tlStatsReqInfo.periodicity)
15786 {
15787 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015788 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15789 pMac->roam.tlStatsReqInfo.periodicity);
15790 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015791 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015792 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015793 return eHAL_STATUS_FAILURE;
15794 }
15795 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15796 }
15797 }
15798 }
15799 pMac->roam.tlStatsReqInfo.numClient++;
15800 }
15801
15802 insertInClientList = TRUE;
15803 }
15804 //if one time report requested with non cached result from PE/TL
15805 else if(!cache && !periodicity)
15806 {
15807 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15808 {
15809 //send down a req
15810 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15811 if(!HAL_STATUS_SUCCESS(status))
15812 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015813 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015814 }
15815 //so that when the stats rsp comes back from PE we respond to upper layer
15816 //right away
15817 staEntry.timerExpired = TRUE;
15818 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015819 }
15820 if(statsMask & (1 << eCsrGlobalClassDStats))
15821 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015822 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015823 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015824 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015825 //req TL for class D stats
15826 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015828 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015829 }
15830 else
15831 {
15832 //save in SME
15833 csrRoamSaveStatsFromTl(pMac, pTlStats);
15834 }
15835 vos_mem_free(pTlStats);
15836 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015837 }
15838 else
15839 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015840 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015841 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015842
15843 }
15844 //if looking for stats from TL only
15845 if(!insertInClientList)
15846 {
15847 //return the stats
15848 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15849 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015850 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015851 if(insertInClientList)
15852 {
15853 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15854 if(!pStaEntry)
15855 {
15856 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015857 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015858 return eHAL_STATUS_FAILURE;
15859 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015860 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015861 //Init & start timer if needed
15862 if(periodicity)
15863 {
15864 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15865 csrRoamStatsClientTimerHandler, pStaEntry );
15866 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15867 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015868 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015869 return eHAL_STATUS_FAILURE;
15870 }
15871 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15872 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15873 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015874 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015875 return eHAL_STATUS_FAILURE;
15876 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015877 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015879 }
15880 return eHAL_STATUS_SUCCESS;
15881}
15882
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015883#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15884
15885static tSirRetStatus
15886csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15887 tANI_U8* pBD,
15888 tANI_U8 type,
15889 tANI_U8 subType,
15890 tSirMacAddr peerAddr,
15891 tSirMacAddr selfMacAddr)
15892{
15893 tSirRetStatus statusCode = eSIR_SUCCESS;
15894 tpSirMacMgmtHdr pMacHdr;
15895
15896 /* Prepare MAC management header */
15897 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15898
15899 /* Prepare FC */
15900 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15901 pMacHdr->fc.type = type;
15902 pMacHdr->fc.subType = subType;
15903
15904 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015905 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15906 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015907
15908 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15909
15910 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015911 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15912 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015913 return statusCode;
15914} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15915
15916static tSirRetStatus
15917csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15918 tANI_U8 nChannelNum,
15919 tANI_U32 dot11mode,
15920 tSirMacAddr selfMacAddr,
15921 tANI_U8 *pFrame,
15922 tANI_U16 *pusLen)
15923{
15924 tDot11fProbeRequest pr;
15925 tANI_U32 nStatus, nBytes, nPayload;
15926 tSirRetStatus nSirStatus;
15927 /*Bcast tx*/
15928 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15929 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15930
15931
Kiet Lam64c1b492013-07-12 13:56:44 +053015932 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015933
15934 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15935
15936 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15937 {
15938 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15939 }
15940
15941
15942 if (IS_DOT11_MODE_HT(dot11mode))
15943 {
15944 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15945 }
15946
15947
15948 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15949 if ( DOT11F_FAILED( nStatus ) )
15950 {
15951 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15952 "Failed to calculate the packed size f"
15953 "or a Probe Request (0x%08x).\n", nStatus );
15954
15955
15956 nPayload = sizeof( tDot11fProbeRequest );
15957 }
15958 else if ( DOT11F_WARNED( nStatus ) )
15959 {
15960 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15961 "There were warnings while calculating"
15962 "the packed size for a Probe Request ("
15963 "0x%08x).\n", nStatus );
15964 }
15965
15966 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15967
15968 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015969 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015970
15971
15972 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015973 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015974
15975 if ( eSIR_SUCCESS != nSirStatus )
15976 {
15977 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15978 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15979 nSirStatus );
15980 return nSirStatus;
15981 }
15982
15983
15984 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15985 sizeof( tSirMacMgmtHdr ),
15986 nPayload, &nPayload );
15987 if ( DOT11F_FAILED( nStatus ) )
15988 {
15989 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15990 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15991 return eSIR_FAILURE;
15992 }
15993 else if ( DOT11F_WARNED( nStatus ) )
15994 {
15995 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015996 "There were warnings while packing a Probe Request (0x%08x).\n",
15997 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015998 }
15999
16000 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
16001 return eSIR_SUCCESS;
16002}
16003
16004eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
16005{
16006 vos_msg_t msg;
16007 tSirRoamOffloadScanReq *pRequestBuf;
16008 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
16009 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016010 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016011 tANI_U8 *ChannelList = NULL;
16012 tANI_U32 sessionId;
16013 eHalStatus status = eHAL_STATUS_SUCCESS;
16014 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070016015 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016016 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016017 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016018 tSirBssDescription *pBssDesc = NULL;
16019 tDot11fBeaconIEs *pIes = NULL;
16020 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080016021 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016022
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016023 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
16024
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070016025 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016026 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016027 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016028 return eHAL_STATUS_FAILURE;
16029 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016030
16031 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
16032 {
16033 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
16034 return eHAL_STATUS_FAILURE;
16035 }
Abhishek Singh3e915632014-11-01 17:14:50 +053016036
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016037 /*The Dynamic Config Items Update may happen even if the state is in INIT.
16038 * It is important to ensure that the command is passed down to the FW only
16039 * if the Infra Station is in a connected state.A connected station could also be
16040 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
16041 * We also have to ensure that if there is a STOP command we always have to inform Riva,
16042 * irrespective of whichever state we are in.*/
16043 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
16044 (command != ROAM_SCAN_OFFLOAD_STOP))
16045 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053016046 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
16047 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
16048 macTraceGetNeighbourRoamState(
16049 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016050 return eHAL_STATUS_FAILURE;
16051 }
16052
Abhishek Singh3e915632014-11-01 17:14:50 +053016053 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
16054 * Also there are cases where pNeighborRoamInfo->currAPbssid
16055 * is set to 0 during disconnect and so we might return without stopping
16056 * the roam scan. So no need to find the session if command is
16057 * ROAM_SCAN_OFFLOAD_STOP.
16058 */
16059 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016060 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016061 status = csrRoamGetSessionIdFromBSSID(pMac,
16062 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
16063 &sessionId);
16064
16065 if ( !HAL_STATUS_SUCCESS( status ) )
16066 {
16067 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16068 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
16069 return eHAL_STATUS_FAILURE;
16070 }
16071 pSession = CSR_GET_SESSION( pMac, sessionId );
16072 if (NULL == pSession)
16073 {
16074 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
krunal soni587bf012014-02-04 12:35:11 -080016075 "%s:pSession is null", __func__);
Abhishek Singh3e915632014-11-01 17:14:50 +053016076 return eHAL_STATUS_FAILURE;
16077 }
16078 pBssDesc = pSession->pConnectBssDesc;
16079 if (pBssDesc == NULL)
16080 {
16081 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16082 "%s: pBssDesc not found for current session", __func__);
16083 return eHAL_STATUS_FAILURE;
16084 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016085 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016086 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
16087 if (NULL == pRequestBuf)
16088 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016089 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16090 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
16091 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016092 }
16093
Abhishek Singh3e915632014-11-01 17:14:50 +053016094 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
16095 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
16096 * host driver reloads, but Riva still up and running*/
16097 pRequestBuf->Command = command;
16098 if(command == ROAM_SCAN_OFFLOAD_STOP)
16099 {
16100 pRequestBuf->RoamScanOffloadEnabled = 0;
16101 /*For a STOP Command, there is no need to
16102 * go through filling up all the below parameters
16103 * since they are not required for the STOP command*/
16104 goto send_roam_scan_offload_cmd;
16105 }
16106 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016107 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053016108 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
16109 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016110 sizeof(tCsrBssid));
16111 pRequestBuf->ConnectedNetwork.ssId.length =
16112 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
16113 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
16114 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
16115 pRequestBuf->ConnectedNetwork.ssId.length);
16116 pRequestBuf->ConnectedNetwork.authentication =
16117 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
16118 pRequestBuf->ConnectedNetwork.encryption =
16119 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
16120 pRequestBuf->ConnectedNetwork.mcencryption =
16121 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016122 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
16123 {
16124 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016125 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016126 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16127 }
16128 else
16129 {
16130 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
16131 operationChannel = pSession->connectedProfile.operationChannel;
16132
16133 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
16134 {
16135 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16136 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
16137 vos_mem_free(pRequestBuf);
16138 return eHAL_STATUS_FAILURE;
16139 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016140 if(NULL == pIes)
16141 {
16142 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16143 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053016144 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016145 return eHAL_STATUS_FAILURE;
16146 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016147 if (pIes->SuppRates.present)
16148 {
16149 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
16150 /*Check for both basic rates and extended rates.*/
16151 for (i = 0; i < pIes->SuppRates.num_rates; i++)
16152 {
16153 /*Check if the Rate is Mandatory or Not*/
16154 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
16155 && (pIes->SuppRates.rates[i] & 0x80))
16156 {
16157 /*Retrieve the actual data rate*/
16158 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
16159 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16160 if (minRate == 0)
16161 minRate = dataRate;
16162 else
16163 minRate = (minRate < dataRate) ? minRate:dataRate;
16164 }
16165 }
16166
16167 if (pIes->ExtSuppRates.present)
16168 {
16169 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
16170 {
16171 /*Check if the Rate is Mandatory or Not*/
16172 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
16173 && (pIes->ExtSuppRates.rates[i] & 0x80))
16174 {
16175 /*Retrieve the actual data rate*/
16176 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
16177 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16178 if (minRate == 0)
16179 minRate = dataRate;
16180 else
16181 minRate = (minRate < dataRate) ? minRate:dataRate;
16182 }
16183 }
16184 }
16185 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
16186 }
16187 else
16188 {
16189 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16190 "%s: Supp Rates not present in pIes", __func__);
16191 vos_mem_free(pRequestBuf);
16192 return eHAL_STATUS_FAILURE;
16193 }
16194 if (NULL != pIes)
16195 {
16196 vos_mem_free(pIes);
16197 pIes = NULL;
16198 }
16199 switch (minRate)
16200 {
16201 case 1:
16202 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
16203 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
16204 break;
16205 case 2:
16206 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
16207 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
16208 break;
16209 case 5:
16210 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
16211 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
16212 break;
16213 case 6:
16214 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16215 {
16216 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
16217 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
16218 }
16219 else
16220 {
16221 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
16222 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
16223 }
16224 break;
16225 case 11:
16226 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
16227 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
16228 break;
16229 case 12:
16230 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16231 {
16232 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
16233 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
16234 }
16235 else
16236 {
16237 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
16238 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
16239 }
16240 break;
16241 case 24:
16242 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16243 {
16244 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
16245 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
16246 }
16247 else
16248 {
16249 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
16250 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
16251 }
16252 break;
16253 default:
16254 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
16255 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16256 break;
16257 }
16258 }
16259 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16260 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
16261 operationChannel, minRate,
16262 pRequestBuf->RxSensitivityThreshold,
16263 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016264 pRequestBuf->RoamRssiDiff =
16265 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016266 pRequestBuf->StartScanReason = reason;
16267 pRequestBuf->NeighborScanTimerPeriod =
16268 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
16269 pRequestBuf->NeighborRoamScanRefreshPeriod =
16270 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
16271 pRequestBuf->NeighborScanChannelMinTime =
16272 pNeighborRoamInfo->cfgParams.minChannelScanTime;
16273 pRequestBuf->NeighborScanChannelMaxTime =
16274 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
16275 pRequestBuf->EmptyRefreshScanPeriod =
16276 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080016277 /* MAWC feature */
16278 pRequestBuf->MAWCEnabled =
16279 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016280#ifdef FEATURE_WLAN_ESE
16281 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016282#endif
16283 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016284#ifdef FEATURE_WLAN_ESE
16285 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016286 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
16287 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016288 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
16289#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016290 currChannelListInfo->numOfChannels == 0)
16291 {
16292
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016293 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
16294 * Give Preference to INI Channels.*/
16295 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
16296 {
16297 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16298 /*The INI channels need to be filtered with respect to the current
16299 * band that is supported.*/
16300 eBand = pMac->roam.configParam.bandCapability;
16301 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016302 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016303 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16304 "Invalid band, No operation carried out (Band %d)", eBand);
16305 vos_mem_free(pRequestBuf);
16306 return eHAL_STATUS_FAILURE;
16307 }
16308 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16309 {
16310 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16311 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16312 (eCSR_BAND_ALL == eBand))
16313 {
16314 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
16315 csrRoamIsChannelValid(pMac, *ChannelList) &&
16316 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16317 {
16318 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16319 }
16320 }
16321 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016322 }
16323 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16324 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016325 }
16326 else
16327 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016328 ChannelList = pMac->scan.occupiedChannels.channelList;
16329 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16330 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016331 /*Allow DFS channels only if the DFS channel roam flag is enabled */
16332 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16333 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016334 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16335 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016336 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016337 }
16338 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016339 }
16340 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16341 /* If the profile changes as to what it was earlier, inform the FW through
16342 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16343 * for the earlier profile and try to learn them afresh.*/
16344 if (reason == REASON_FLUSH_CHANNEL_LIST)
16345 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16346 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016347 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16348 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16349 else
16350 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016351 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016352 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016353 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016354#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016355 else
16356 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016357 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016358 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016359 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016360 if (currChannelListInfo->numOfChannels != 0)
16361 {
16362 ChannelList = currChannelListInfo->ChannelList;
16363 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016364 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016365 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16366 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016367 {
16368 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16369 }
16370 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016371 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016372 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16373 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16374 }
16375 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016376#endif
Kaushik, Sushant5ed8ab62014-03-05 11:21:11 +053016377 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0])) && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016378 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016379 if (j < sizeof(ChannelCacheStr))
16380 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016381 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16382 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016383 }
16384 else
16385 {
16386 break;
16387 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016388 }
16389 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16390 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16391 pRequestBuf->ChannelCacheType,
16392 pRequestBuf->ConnectedNetwork.ChannelCount,
16393 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016394 num_channels = 0;
16395 ChannelList = NULL;
16396
16397 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016398 host_channels = sizeof(pMac->roam.validChannelList);
16399 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016400 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016401 ChannelList = pMac->roam.validChannelList;
16402 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016403 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016404 else
16405 {
16406 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16407 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016408 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016409 return eHAL_STATUS_FAILURE;
16410 }
16411 for(i=0; i<pMac->roam.numValidChannels; i++)
16412 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016413 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16414 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Srinivas Girigowda56076852013-08-20 14:00:50 -070016415 {
16416 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16417 }
16418 ChannelList++;
16419 }
16420 pRequestBuf->ValidChannelCount = num_channels;
16421
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016422 pRequestBuf->MDID.mdiePresent =
16423 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16424 pRequestBuf->MDID.mobilityDomain =
16425 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016426 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16427
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016428 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016429 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16430 * where RFS is the RF Switching time. It is twice RFS to consider the
16431 * time to go off channel and return to the home channel. */
16432 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16433 {
16434 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16435 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16436 " Hence enforcing home away time to disable (0)",
16437 __func__, pRequestBuf->HomeAwayTime,
16438 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16439 pRequestBuf->HomeAwayTime = 0;
16440 }
16441 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016442
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016443 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16444 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16445 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16446 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16447 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16448
16449 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16450 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016451send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016452 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016453 msg.reserved = 0;
16454 msg.bodyptr = pRequestBuf;
16455 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16456 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016457 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16458 vos_mem_free(pRequestBuf);
16459 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016460 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016461 else
16462 {
16463 if (ROAM_SCAN_OFFLOAD_START == command)
16464 bRoamScanOffloadStarted = VOS_TRUE;
16465 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16466 bRoamScanOffloadStarted = VOS_FALSE;
16467 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016468
16469 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16470 return status;
16471}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016472
16473eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16474{
16475 switch(reason)
16476 {
16477 case 0:
16478 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16479 break;
16480 case REASON_OS_REQUESTED_ROAMING_NOW:
16481 csrNeighborRoamProceedWithHandoffReq(pMac);
16482 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016483 case REASON_INITIAL_FORCED_ROAM_TO_5G:
16484 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
16485 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016486 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016487 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 -070016488 }
16489 return eHAL_STATUS_SUCCESS;
16490}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016491#endif
16492
Jeff Johnson295189b2012-06-20 16:38:30 -070016493tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16494 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16495{
16496 tANI_BOOLEAN found = FALSE;
16497 eHalStatus status = eHAL_STATUS_SUCCESS;
16498 tCsrPeStatsReqInfo staEntry;
16499 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16500 tListElem *pStaEntry = NULL;
16501 VOS_STATUS vosStatus;
16502 tPmcPowerState powerState;
16503 *pFound = FALSE;
16504
16505 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16506 if(pStaEntry)
16507 {
16508 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16509 if(pTempStaEntry->periodicity)
16510 {
16511 pTempStaEntry->periodicity =
16512 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16513 }
16514 else
16515 {
16516 pTempStaEntry->periodicity = periodicity;
16517 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016518 pTempStaEntry->numClient++;
16519 found = TRUE;
16520 }
16521 else
16522 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016523 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016524 staEntry.numClient = 1;
16525 staEntry.periodicity = periodicity;
16526 staEntry.pMac = pMac;
16527 staEntry.rspPending = FALSE;
16528 staEntry.staId = staId;
16529 staEntry.statsMask = statsMask;
16530 staEntry.timerRunning = FALSE;
16531 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16532 if(!pTempStaEntry)
16533 {
16534 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016535 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016536 return NULL;
16537 }
16538 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016539 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16540 if(ePMC_FULL_POWER == powerState)
16541 {
16542 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16543 {
16544 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16545 }
16546 }
16547 else
16548 {
16549 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16550 {
16551 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16552 }
16553 }
16554 if(!pTempStaEntry->timerRunning)
16555 {
16556 //send down a req in case of one time req, for periodic ones wait for timer to expire
16557 if(!pTempStaEntry->rspPending &&
16558 !pTempStaEntry->periodicity)
16559 {
16560 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16561 if(!HAL_STATUS_SUCCESS(status))
16562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016563 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016564 }
16565 else
16566 {
16567 pTempStaEntry->rspPending = TRUE;
16568 }
16569 }
16570 if(pTempStaEntry->periodicity)
16571 {
16572 if(!found)
16573 {
16574
16575 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16576 csrRoamPeStatsTimerHandler, pTempStaEntry );
16577 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16578 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016579 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016580 return NULL;
16581 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016582 }
16583 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016584 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016585 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16586 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16587 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016588 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016589 return NULL;
16590 }
16591 pTempStaEntry->timerRunning = TRUE;
16592 }
16593 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016594 *pFound = found;
16595 return pTempStaEntry;
16596}
16597
Jeff Johnson295189b2012-06-20 16:38:30 -070016598/*
16599 pStaEntry is no longer invalid upon the return of this function.
16600*/
16601static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16602{
16603 if(pEntry)
16604 {
16605 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16606 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016607 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016608 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016609 }
16610 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016611
16612void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16613{
16614 tListElem *pEntry;
16615 tCsrPeStatsReqInfo *pTempStaEntry;
16616 VOS_STATUS vosStatus;
16617 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016618 if(!pEntry)
16619 {
16620 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016621 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016622 return;
16623 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016624 while( pEntry )
16625 {
16626 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016627 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16628 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016629 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016630 if(pTempStaEntry->timerRunning)
16631 {
16632 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16633 /* If we are not able to stop the timer here, just remove
16634 * the entry from the linked list. Destroy the timer object
16635 * and free the memory in the timer CB
16636 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016637 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016638 {
16639 /* the timer is successfully stopped */
16640 pTempStaEntry->timerRunning = FALSE;
16641
16642 /* Destroy the timer */
16643 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16644 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16645 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016646 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016647 }
16648 }
16649 else
16650 {
16651 // the timer could not be stopped. Hence destroy and free the
16652 // memory for the PE stat entry in the timer CB.
16653 pTempStaEntry->timerStopFailed = TRUE;
16654 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016655 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016656
16657 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16658 {
16659 // Only free the memory if we could stop the timer successfully
16660 if(!pTempStaEntry->timerStopFailed)
16661 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016662 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016663 pTempStaEntry = NULL;
16664 }
16665 break;
16666 }
16667
16668 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16669 }
16670 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016671 return;
16672}
16673
16674
Jeff Johnsone7245742012-09-05 17:12:55 -070016675void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016676{
16677
Jeff Johnsone7245742012-09-05 17:12:55 -070016678 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16679 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16680 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16681 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16682 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16683 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16684 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016685 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016686 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16687 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16688 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16689 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16690 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16691 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016692 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016693 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16694 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016695
16696}
16697
Jeff Johnson295189b2012-06-20 16:38:30 -070016698void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16699 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16700{
16701 tANI_U8 stats[500];
16702 tANI_U8 *pStats = NULL;
16703 tANI_U32 tempMask = 0;
16704 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016705 if(!callback)
16706 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016707 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016708 return;
16709 }
16710 if(!statsMask)
16711 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016712 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016713 return;
16714 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016715 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016716 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016717 while(tempMask)
16718 {
16719 if(tempMask & 1)
16720 {
16721 //new stats info from PE, fill up the stats strucutres in PMAC
16722 switch(counter)
16723 {
16724 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016725 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016726 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16727 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016728 pStats += sizeof(tCsrSummaryStatsInfo);
16729 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016730 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016731 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016732 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16733 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016734 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016735 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016736 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016737 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016738 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16739 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016740 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016741 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016742 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016743 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016744 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16745 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016746 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016747 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016748 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016749 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016750 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16751 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016752 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016753 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016754 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016755 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016756 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16757 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016758 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016759 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016760 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016761 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016762 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016763 }
16764 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016765 tempMask >>=1;
16766 counter++;
16767 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016768 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016769}
16770
Jeff Johnson295189b2012-06-20 16:38:30 -070016771eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16772{
16773 tListElem *pEntry = NULL;
16774 tListElem *pPrevEntry = NULL;
16775 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16776 eHalStatus status = eHAL_STATUS_SUCCESS;
16777 VOS_STATUS vosStatus;
16778 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016779 if(!pEntry)
16780 {
16781 //list empty
16782 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016783 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016784 return status;
16785 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016786 while( pEntry )
16787 {
16788 if(pPrevEntry)
16789 {
16790 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16791 //send up the stats report
16792 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16793 pTempStaEntry->staId, pTempStaEntry->pContext);
16794 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16795 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016796 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016797 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16798 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016799 pTempStaEntry->pPeStaEntry->numClient--;
16800 //check if we need to delete the entry from peStatsReqList too
16801 if(!pTempStaEntry->pPeStaEntry->numClient)
16802 {
16803 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16804 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016805 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016806 //check if we need to stop the tl stats timer too
16807 pMac->roam.tlStatsReqInfo.numClient--;
16808 if(!pMac->roam.tlStatsReqInfo.numClient)
16809 {
16810 if(pMac->roam.tlStatsReqInfo.timerRunning)
16811 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016812 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16813 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016814 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016815 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016816 //we will continue
16817 }
16818 }
16819 pMac->roam.tlStatsReqInfo.periodicity = 0;
16820 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16821 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016822 if (pTempStaEntry->periodicity)
16823 {
16824 //While creating StaEntry in csrGetStatistics,
16825 //Initializing and starting timer only when periodicity is set.
16826 //So Stop and Destroy timer only when periodicity is set.
16827
Jeff Johnsone7245742012-09-05 17:12:55 -070016828 vos_timer_stop( &pTempStaEntry->timer );
16829 // Destroy the vos timer...
16830 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16831 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016833 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016834 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016835 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016836
Jeff Johnson295189b2012-06-20 16:38:30 -070016837
16838 pPrevEntry = pEntry;
16839 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16840 }
16841 //the last one
16842 if(pPrevEntry)
16843 {
16844 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16845 //send up the stats report
16846 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16847 pTempStaEntry->staId, pTempStaEntry->pContext);
16848 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16849 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016850 return status;
16851
16852}
16853
Jeff Johnson295189b2012-06-20 16:38:30 -070016854eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16855 tRequestFullPowerReason *pReason,
16856 tANI_BOOLEAN *pfNeedPower )
16857{
16858 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16859 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16860 tPmcState pmcState;
16861 eHalStatus status = eHAL_STATUS_SUCCESS;
16862 // TODO : Session info unavailable
16863 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016864 if( pfNeedPower )
16865 {
16866 *pfNeedPower = eANI_BOOLEAN_FALSE;
16867 }
16868 //We only handle CSR commands
16869 if( !(eSmeCsrCommandMask & pCommand->command) )
16870 {
16871 return eHAL_STATUS_SUCCESS;
16872 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016873 //Check PMC state first
16874 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016875 switch( pmcState )
16876 {
16877 case REQUEST_IMPS:
16878 case IMPS:
16879 if( eSmeCommandScan == pCommand->command )
16880 {
16881 switch( pCommand->u.scanCmd.reason )
16882 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016883#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16884 case eCsrScanGetLfrResult:
16885#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016886 case eCsrScanGetResult:
16887 case eCsrScanBGScanAbort:
16888 case eCsrScanBGScanEnable:
16889 case eCsrScanGetScanChnInfo:
16890 //Internal process, no need for full power
16891 fNeedFullPower = eANI_BOOLEAN_FALSE;
16892 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016893 default:
16894 //Other scans are real scan, ask for power
16895 fNeedFullPower = eANI_BOOLEAN_TRUE;
16896 break;
16897 } //switch
16898 }
16899 else
16900 {
16901 //ask for power for roam and status change
16902 fNeedFullPower = eANI_BOOLEAN_TRUE;
16903 }
16904 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016905 case REQUEST_BMPS:
16906 case BMPS:
16907 case REQUEST_START_UAPSD:
16908 case UAPSD:
16909 //We treat WOWL same as BMPS
16910 case REQUEST_ENTER_WOWL:
16911 case WOWL:
16912 if( eSmeCommandRoam == pCommand->command )
16913 {
16914 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16915 tCsrScanResult *pScanResult;
16916 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016917 switch ( pCommand->u.roamCmd.roamReason )
16918 {
16919 case eCsrForcedDisassoc:
16920 case eCsrForcedDisassocMICFailure:
16921 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16922 fNeedFullPower = eANI_BOOLEAN_TRUE;
16923 break;
16924 case eCsrSmeIssuedDisassocForHandoff:
16925 case eCsrForcedDeauth:
16926 case eCsrHddIssuedReassocToSameAP:
16927 case eCsrSmeIssuedReassocToSameAP:
16928 fNeedFullPower = eANI_BOOLEAN_TRUE;
16929 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016930 case eCsrCapsChange:
16931 fNeedFullPower = eANI_BOOLEAN_TRUE;
16932 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016933 default:
16934 //Check whether the profile is already connected. If so, no need for full power
16935 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16936 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16937 {
16938 //Only need to check the first one
16939 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16940 if( pEntry )
16941 {
16942 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16943#if 0
16944 // TODO : Session Specific info pConnectBssDesc
16945 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16946 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16947 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16948 {
16949 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16950 // with Authenticating first. To force this, stop the current association (Disassociate) and
16951 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16952 // a new Association.
16953 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16954 {
16955 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16956 {
16957 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16958 //No need for full power
16959 //Set the flag so the code later can avoid to do the above
16960 //check again.
16961 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16962 break;
16963 }
16964 }
16965 }
16966#endif
16967 }
16968 }
16969 //If we are here, full power is needed
16970 fNeedFullPower = eANI_BOOLEAN_TRUE;
16971 break;
16972 }
16973 }
16974 else if( eSmeCommandWmStatusChange == pCommand->command )
16975 {
16976 //need full power for all
16977 fNeedFullPower = eANI_BOOLEAN_TRUE;
16978 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16979 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016980#ifdef FEATURE_WLAN_TDLS
16981 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16982 {
16983 //TDLS link is getting established. need full power
16984 fNeedFullPower = eANI_BOOLEAN_TRUE;
16985 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16986 }
16987#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016988 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016989 case REQUEST_STOP_UAPSD:
16990 case REQUEST_EXIT_WOWL:
16991 if( eSmeCommandRoam == pCommand->command )
16992 {
16993 fNeedFullPower = eANI_BOOLEAN_TRUE;
16994 switch ( pCommand->u.roamCmd.roamReason )
16995 {
16996 case eCsrForcedDisassoc:
16997 case eCsrForcedDisassocMICFailure:
16998 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16999 break;
17000 default:
17001 break;
17002 }
17003 }
17004 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017005 case STOPPED:
17006 case REQUEST_STANDBY:
17007 case STANDBY:
17008 case LOW_POWER:
17009 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053017010 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
17011 " stopped/standby state %s (%d)" ),
17012 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070017013 status = eHAL_STATUS_FAILURE;
17014 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017015 case FULL_POWER:
17016 case REQUEST_FULL_POWER:
17017 default:
17018 //No need to ask for full power. This has to be FULL_POWER state
17019 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017020 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070017021 if( pReason )
17022 {
17023 *pReason = reason;
17024 }
17025 if( pfNeedPower )
17026 {
17027 *pfNeedPower = fNeedFullPower;
17028 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017029 return ( status );
17030}
17031
Jeff Johnson295189b2012-06-20 16:38:30 -070017032static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
17033{
17034 eHalStatus status = eHAL_STATUS_SUCCESS;
17035 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
17036 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070017037 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070017038 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
17039 {
17040 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
17041 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017042 return ( status );
17043}
17044
Jeff Johnson295189b2012-06-20 16:38:30 -070017045tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
17046{
17047 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070017048 if( pCmd )
17049 {
17050 pMac->roam.sPendingCommands++;
17051 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017052 return ( pCmd );
17053}
17054
Jeff Johnson295189b2012-06-20 16:38:30 -070017055void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
17056{
17057 if (pMac->roam.sPendingCommands > 0)
17058 {
17059 //All command allocated through csrGetCommandBuffer need to
17060 //decrement the pending count when releasing.
17061 pMac->roam.sPendingCommands--;
17062 smeReleaseCommand( pMac, pCommand );
17063 }
17064 else
17065 {
17066 smsLog(pMac, LOGE, FL( "no pending commands"));
17067 VOS_ASSERT(0);
17068 }
17069}
17070
Jeff Johnson295189b2012-06-20 16:38:30 -070017071//Return SUCCESS is the command is queued, failed
17072eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
17073{
17074 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017075 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
17076 {
17077 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
17078 pCommand->u.scanCmd.reason);
17079 return eHAL_STATUS_CSR_WRONG_STATE;
17080 }
17081
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017082 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
17083 {
17084 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
17085 &pCommand->Link, LL_ACCESS_LOCK);
17086 // process the command queue...
17087 smeProcessPendingQueue(pMac);
17088 status = eHAL_STATUS_SUCCESS;
17089 goto end;
17090 }
17091
Jeff Johnson295189b2012-06-20 16:38:30 -070017092 //We can call request full power first before putting the command into pending Q
17093 //because we are holding SME lock at this point.
17094 status = csrRequestFullPower( pMac, pCommand );
17095 if( HAL_STATUS_SUCCESS( status ) )
17096 {
17097 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070017098 //make sure roamCmdPendingList is not empty first
17099 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
17100 if( fNoCmdPending )
17101 {
17102 smePushCommand( pMac, pCommand, fHighPriority );
17103 }
17104 else
17105 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017106 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070017107 //no list lock is needed since SME lock is held
17108 if( !fHighPriority )
17109 {
17110 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17111 }
17112 else {
17113 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17114 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017115 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017116 }
17117 else if( eHAL_STATUS_PMC_PENDING == status )
17118 {
17119 //no list lock is needed since SME lock is held
17120 if( !fHighPriority )
17121 {
17122 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17123 }
17124 else {
17125 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17126 }
17127 //Let caller know the command is queue
17128 status = eHAL_STATUS_SUCCESS;
17129 }
17130 else
17131 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017132 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070017133 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017134 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070017135 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017136end:
Jeff Johnson295189b2012-06-20 16:38:30 -070017137 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070017138}
Jeff Johnson295189b2012-06-20 16:38:30 -070017139eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
17140{
17141 eHalStatus status = eHAL_STATUS_SUCCESS;
17142 tSirUpdateAPWPSIEsReq *pMsg;
17143 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
17144
17145 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17146 if (NULL == pSession)
17147 {
17148 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17149 return eHAL_STATUS_FAILURE;
17150 }
17151
Jeff Johnson295189b2012-06-20 16:38:30 -070017152 do
17153 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017154 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
17155 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17156 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017157 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
17158
17159 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070017160 VOS_ASSERT(pBuf);
17161
Jeff Johnson295189b2012-06-20 16:38:30 -070017162 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017163 // transactionId
17164 *pBuf = 0;
17165 *( pBuf + 1 ) = 0;
17166 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070017167 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017168 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17169 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017170 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017171 //sessionId
17172 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017173 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017174 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070017175 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070017176 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017177 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017178 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017179 return ( status );
17180}
Jeff Johnson295189b2012-06-20 16:38:30 -070017181eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
17182{
17183 eHalStatus status = eHAL_STATUS_SUCCESS;
17184 tSirUpdateAPWPARSNIEsReq *pMsg;
17185 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017186 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17187 if (NULL == pSession)
17188 {
17189 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17190 return eHAL_STATUS_FAILURE;
17191 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017192 do
17193 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017194 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
17195 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17196 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017197 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070017198 pBuf = (tANI_U8 *)&pMsg->transactionId;
17199 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017200 // transactionId
17201 *pBuf = 0;
17202 *( pBuf + 1 ) = 0;
17203 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070017204 VOS_ASSERT(pBuf);
17205
Jeff Johnson295189b2012-06-20 16:38:30 -070017206 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017207 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17208 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017209 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017210 // sessionId
17211 *pBuf++ = (tANI_U8)sessionId;
17212
17213 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017214 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070017215 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070017216 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017217 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017218 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017219 return ( status );
17220}
Jeff Johnson295189b2012-06-20 16:38:30 -070017221
17222#ifdef WLAN_FEATURE_VOWIFI_11R
17223//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
17224eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
17225{
17226 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17227 tpSirFTPreAuthReq pftPreAuthReq;
17228 tANI_U16 auth_req_len = 0;
17229 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017230 auth_req_len = sizeof(tSirFTPreAuthReq);
17231 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053017232 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070017233 {
17234 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
17235 return eHAL_STATUS_RESOURCES;
17236 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017237 // Save the SME Session ID here. We need it while processing the preauth response
17238 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017239 vos_mem_zero(pftPreAuthReq, auth_req_len);
17240
17241 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
17242 sizeof(pBssDescription->length) + pBssDescription->length);
17243
17244 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
17245
17246 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
17247
Kiet Lam64c1b492013-07-12 13:56:44 +053017248 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
17249 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
17250 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
17251 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017252
Jeff Johnson295189b2012-06-20 16:38:30 -070017253#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080017254 if (csrRoamIs11rAssoc(pMac) &&
17255 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070017256 {
17257 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053017258 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
17259 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070017260 }
17261 else
17262#endif
17263 {
17264 pftPreAuthReq->ft_ies_length = 0;
17265 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070017266 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
17267 sizeof(pBssDescription->length) + pBssDescription->length);
17268 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070017269 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
17270}
Jeff Johnson295189b2012-06-20 16:38:30 -070017271/*--------------------------------------------------------------------------
17272 * This will receive and process the FT Pre Auth Rsp from the current
17273 * associated ap.
17274 *
17275 * This will invoke the hdd call back. This is so that hdd can now
17276 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
17277 ------------------------------------------------------------------------*/
17278void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
17279{
17280 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17281 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017282#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017283 tCsrRoamInfo roamInfo;
17284#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017285 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070017286
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017287#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080017288 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017289 if (status != eHAL_STATUS_SUCCESS) {
17290 /*
17291 * Bail out if pre-auth was not even processed.
17292 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017293 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
17294 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017295 return;
17296 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017297#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017298 /* The below function calls/timers should be invoked only if the pre-auth is successful */
17299 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
17300 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070017301 // Implies a success
17302 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017303 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
17304 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053017305 /* No need to notify qos module if this is a non 11r & ESE roam*/
17306 if (csrRoamIs11rAssoc(pMac)
17307#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
17308 || csrRoamIsESEAssoc(pMac)
17309#endif
17310 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070017311 {
17312 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17313 }
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017314#ifdef DEBUG_ROAM_DELAY
17315 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
17316#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017317 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17318 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017319 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
17320 60);
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017321#ifdef DEBUG_ROAM_DELAY
17322 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
17323#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017324 if (eHAL_STATUS_SUCCESS != status)
17325 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017326 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017327 return;
17328 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017329 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017330 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
17331 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070017332 if (csrRoamIs11rAssoc(pMac))
17333 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17334 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
17335
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017336#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17337 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017338 {
17339 /* read TSF */
17340 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
17341
17342 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017343 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017344 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
17345 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017346#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017347#ifdef FEATURE_WLAN_LFR
17348 // If Legacy Fast Roaming is enabled, signal the supplicant
17349 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053017350 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017351 {
17352 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017353 vos_mem_copy((void *)&roamInfo.bssid,
17354 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017355 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17356 }
17357
17358#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017359
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017360 // If its an Open Auth, FT IEs are not provided by supplicant
17361 // Hence populate them here
17362 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
17363 pMac->ft.ftSmeContext.addMDIE = FALSE;
17364 if( csrRoamIs11rAssoc(pMac) &&
17365 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
17366 {
17367 tANI_U16 ft_ies_length;
17368 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
17369
17370 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
17371 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
17372 {
17373 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
17374 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
17375 }
17376
17377 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
17378 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
17379 {
17380 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
17381 }
17382 else
17383 {
17384 // Copy the RIC IEs to reassoc IEs
17385 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
17386 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
17387 pFTPreAuthRsp->ric_ies_length);
17388 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
17389 pMac->ft.ftSmeContext.addMDIE = TRUE;
17390 }
17391 }
17392
Jeff Johnson295189b2012-06-20 16:38:30 -070017393 // Done with it, init it.
17394 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
17395}
17396#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017397
Jeff Johnson295189b2012-06-20 16:38:30 -070017398#ifdef FEATURE_WLAN_BTAMP_UT_RF
17399void csrRoamJoinRetryTimerHandler(void *pv)
17400{
17401 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
17402 tpAniSirGlobal pMac = pInfo->pMac;
17403 tANI_U32 sessionId = pInfo->sessionId;
17404 tCsrRoamSession *pSession;
17405
17406 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17407 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017408 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017409 pSession = CSR_GET_SESSION( pMac, sessionId );
17410 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17411 {
17412 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17413 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017414 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017415 }
17416 }
17417 }
17418}
Jeff Johnson295189b2012-06-20 16:38:30 -070017419eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17420{
17421 eHalStatus status = eHAL_STATUS_FAILURE;
17422 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17423
17424 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17425 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017426 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017427 pSession->maxRetryCount--;
17428 pSession->joinRetryTimerInfo.pMac = pMac;
17429 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017430 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17431 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017433 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017434 }
17435 }
17436 else
17437 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017438 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017439 pSession->maxRetryCount);
17440 }
17441
17442 return (status);
17443}
Jeff Johnson295189b2012-06-20 16:38:30 -070017444eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17445{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017446 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017447 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17448 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017449 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017450 }
17451
17452 return eHAL_STATUS_SUCCESS;
17453}
17454#endif
17455
17456
17457/*
17458 pBuf points to the beginning of the message
17459 LIM packs disassoc rsp as below,
17460 messageType - 2 bytes
17461 messageLength - 2 bytes
17462 sessionId - 1 byte
17463 transactionId - 2 bytes (tANI_U16)
17464 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17465 peerMacAddr - 6 bytes
17466 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17467*/
17468static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17469{
17470 if(pBuf && pRsp)
17471 {
17472 pBuf += 4; //skip type and length
17473 pRsp->sessionId = *pBuf++;
17474 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17475 pBuf += 2;
17476 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17477 pBuf += 4;
17478 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17479 }
17480}
17481
Jeff Johnsond13512a2012-07-17 11:42:19 -070017482eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17483{
17484 static uNvTables nvTables;
17485 eHalStatus status = eHAL_STATUS_SUCCESS;
17486 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17487
17488 /* read the country code from NV and use it */
17489 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17490 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017491 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17492 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017493 return status;
17494 }
17495 else
17496 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017497 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017498 status = eHAL_STATUS_FAILURE;
17499 return status;
17500 }
17501}
17502
17503eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17504{
Kiet Lam64c1b492013-07-12 13:56:44 +053017505 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017506 return eHAL_STATUS_SUCCESS;
17507}
schang86c22c42013-03-13 18:41:24 -070017508
17509eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17510{
17511 tSirSetTxPowerReq *pMsg = NULL;
17512 eHalStatus status = eHAL_STATUS_SUCCESS;
17513 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17514
17515 if (!pSession)
17516 {
17517 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17518 return eHAL_STATUS_FAILURE;
17519 }
17520
Kiet Lam64c1b492013-07-12 13:56:44 +053017521 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17522 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17523 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17524 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17525 pMsg->length = sizeof(tSirSetTxPowerReq);
17526 pMsg->mwPower = mW;
17527 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17528 sizeof(tSirMacAddr));
17529 status = palSendMBMessage(pMac->hHdd, pMsg);
17530 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017531 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017532 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17533 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017534 }
17535 return status;
17536}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017537
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017538eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17539{
17540 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17541 eHalStatus status = eHAL_STATUS_SUCCESS;
17542 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17543
17544 if (!pSession)
17545 {
17546 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17547 return eHAL_STATUS_FAILURE;
17548 }
17549 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17550 {
17551 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053017552
17553 if( NULL == pMsg )
17554 {
17555 smsLog(pMac, LOGE, FL("PMsg is NULL "));
17556 return eHAL_STATUS_FAILURE;
17557 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017558 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17559 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17560 pMsg->length = sizeof(tANI_U8);
17561 pMsg->seesionId = sessionId;
17562 status = palSendMBMessage(pMac->hHdd, pMsg);
17563 if (!HAL_STATUS_SUCCESS(status))
17564 {
17565 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17566 //pMsg is freed by palSendMBMessage
17567 }
17568 }
17569 else
17570 {
17571 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17572 status = eHAL_STATUS_FAILURE;
17573 }
17574 return status;
17575}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017576/* Returns whether a session is in VOS_STA_MODE...or not */
17577tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17578{
17579 tCsrRoamSession *pSession = NULL;
17580 pSession = CSR_GET_SESSION ( pMac, sessionId );
17581 if(!pSession)
17582 {
17583 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17584 return eANI_BOOLEAN_FALSE;
17585 }
17586 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17587 {
17588 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17589 return eANI_BOOLEAN_FALSE;
17590 }
17591 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17592 {
17593 return eANI_BOOLEAN_FALSE;
17594 }
17595 /* There is a possibility that the above check may fail,because
17596 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17597 * when it is connected.So,we may sneak through the above check even
17598 * if we are not a STA mode INFRA station. So, if we sneak through
17599 * the above condition, we can use the following check if we are
17600 * really in STA Mode.*/
17601
17602 if ( NULL != pSession->pCurRoamProfile )
17603 {
17604 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17605 {
17606 return eANI_BOOLEAN_TRUE;
17607 } else {
17608 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17609 return eANI_BOOLEAN_FALSE;
17610 }
17611 }
17612
17613 return eANI_BOOLEAN_FALSE;
17614}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017615
17616#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17617eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17618 tCsrHandoffRequest *pHandoffInfo)
17619{
17620 eHalStatus status = eHAL_STATUS_SUCCESS;
17621 vos_msg_t msg;
17622
17623 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017624 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17625 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017626 {
17627 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017628 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017629 }
17630 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17631 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17632 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17633 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017634 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017635 pHandoffInfo->bssid,
17636 6);
17637 msg.type = eWNI_SME_HANDOFF_REQ;
17638 msg.bodyptr = pMsg;
17639 msg.reserved = 0;
17640 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17641 {
17642 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017643 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017644 status = eHAL_STATUS_FAILURE;
17645 }
17646 return status;
17647}
17648#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017649
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017650
17651#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017652/* ---------------------------------------------------------------------------
17653 \fn csrSetCCKMIe
17654 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17655 data structure and this IE will be packed inside reassociation request
17656 \param pMac - pMac global structure
17657 \param sessionId - Current session id
17658 \param pCckmIe - pointer to CCKM IE data
17659 \param ccKmIeLen - length of the CCKM IE
17660 \- return Success or failure
17661 -------------------------------------------------------------------------*/
17662VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17663 const tANI_U8 *pCckmIe,
17664 const tANI_U8 ccKmIeLen)
17665{
17666 eHalStatus status = eHAL_STATUS_SUCCESS;
17667 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17668
17669 if (!pSession)
17670 {
17671 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17672 return eHAL_STATUS_FAILURE;
17673 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017674 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017675 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17676 return status;
17677}
17678
17679/* ---------------------------------------------------------------------------
17680 \fn csrRoamReadTSF
17681 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17682 probe response reception from the hand off AP to arrive at the latest TSF value.
17683 \param pMac - pMac global structure
17684 \param pTimestamp - output TSF timestamp
17685 \- return Success or failure
17686 -------------------------------------------------------------------------*/
17687VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17688{
17689 eHalStatus status = eHAL_STATUS_SUCCESS;
17690 tCsrNeighborRoamBSSInfo handoffNode;
17691 tANI_U32 timer_diff = 0;
17692 tANI_U32 timeStamp[2];
17693 tpSirBssDescription pBssDescription = NULL;
17694
17695 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17696 pBssDescription = handoffNode.pBssDescription;
17697
17698 // Get the time diff in milli seconds
17699 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17700 // Convert msec to micro sec timer
17701 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17702
17703 timeStamp[0] = pBssDescription->timeStamp[0];
17704 timeStamp[1] = pBssDescription->timeStamp[1];
17705
17706 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17707
Kiet Lamf2f201e2013-11-16 21:24:16 +053017708 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017709 sizeof (tANI_U32) * 2);
17710 return status;
17711}
17712
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017713#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017714
Agarwal Ashish738843c2014-09-25 12:27:56 +053017715/* ---------------------------------------------------------------------------
17716 \fn csrDisableDfsChannel
17717 \brief This function will call csrApplyChannelPowerCountryInfo to
17718 \ to trim the list on basis of NO_DFS flag.
17719 \param pMac - pMac global structure
17720 \- return void
17721 -------------------------------------------------------------------------*/
17722void csrDisableDfsChannel(tpAniSirGlobal pMac)
17723{
17724 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
17725 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
17726}