blob: 8e580e414e00596ebc7b727efe2ced8995775bd6 [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
Mihir Shete04206452014-11-20 17:50:58 +0530408#ifdef CONFIG_ENABLE_LINUX_REG
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530409eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac, driver_load_type init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530410{
411 eHalStatus status = eHAL_STATUS_SUCCESS;
412 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530413 tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN];
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530414
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530415 /* In case of driver load ; driver need to get channel
416 * list with default Countrycode.
417 * In case of SSR; driver need to get channel list
418 * with old country code. 0 is for init and
419 * 1 is for reinit
420 */
421 switch (init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530422 {
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530423 case INIT:
424 vos_mem_copy(cc, pMac->scan.countryCodeDefault,
425 WNI_CFG_COUNTRY_CODE_LEN);
426 if (!('0' == cc[0] &&
427 '0' == cc[1]))
428 {
429 csrGetRegulatoryDomainForCountry(pMac, cc,
430 &regId, COUNTRY_NV);
431 }
432 else
433 {
434 return status;
435 }
436 pMac->scan.domainIdDefault = regId;
437 break;
438 case REINIT:
439 vos_getCurrentCountryCode(&cc[0]);
440 status = csrGetRegulatoryDomainForCountry(pMac,
441 cc, &regId, COUNTRY_QUERY);
442 break;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530443 }
444 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530445 pMac->scan.domainIdCurrent = regId;
446 vos_mem_copy(pMac->scan.countryCodeCurrent, cc,
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530447 WNI_CFG_COUNTRY_CODE_LEN);
448 status = csrInitGetChannels( pMac );
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530449
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530450 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
451 FL("Current Country is %c%c "), pMac->scan.countryCodeCurrent[0],
452 pMac->scan.countryCodeCurrent[1]);
453
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530454 /* reset info based on new cc, and we are done */
455 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
456 csrScanFilterResults(pMac);
457
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530458 return status;
459}
Mihir Shete04206452014-11-20 17:50:58 +0530460#endif
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530461
Jeff Johnson295189b2012-06-20 16:38:30 -0700462eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
463{
464 eHalStatus status = eHAL_STATUS_SUCCESS;
465 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
466 v_REGDOMAIN_t regId;
467 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 if(NULL == apCntryCode)
469 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530470 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 return eHAL_STATUS_FAILURE;
472 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530473 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700474 /* To get correct Regulatory domain from NV table
475 * 2 character Country code should be used
476 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700477 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
478/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700479 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700480
481 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
482 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800483 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700484 return eHAL_STATUS_FAILURE;
485 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700486*/
Kiet Lam6c583332013-10-14 05:37:09 +0530487 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
488 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 if (status != eHAL_STATUS_SUCCESS)
490 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700491 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 return status;
493 }
Abhishek Singha306a442013-11-07 18:39:01 +0530494 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700495 if (status != eHAL_STATUS_SUCCESS)
496 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700497 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 return status;
499 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700500 pMac->scan.domainIdDefault = regId;
501 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530503 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
504
Jeff Johnson295189b2012-06-20 16:38:30 -0700505 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530506 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
507
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 /* If 2 bytes country code, 3rd byte must be filled with space */
509 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
510 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530511 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530513 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
514 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 return status;
517}
Jeff Johnson295189b2012-06-20 16:38:30 -0700518eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
519{
520 eHalStatus status = eHAL_STATUS_SUCCESS;
521 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
522 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530523 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
524 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
526 {
527 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
528 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
529 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
530 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
531 }
532 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
533
534 return status;
535}
Jeff Johnson295189b2012-06-20 16:38:30 -0700536eHalStatus csrClose(tpAniSirGlobal pMac)
537{
538 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800539
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 csrRoamClose(pMac);
541 csrScanClose(pMac);
542 csrLLClose(&pMac->roam.statsClientReqList);
543 csrLLClose(&pMac->roam.peStatsReqList);
544 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 /* DeInit Globals */
546 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 return (status);
548}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530549
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800550eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530551{
552 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800553 tCsrScanStruct *pScan = &pMac->scan;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530554 tANI_U32 numChan = 0;
555 tANI_U32 bufLen ;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530556 vos_msg_t msg;
557 tANI_U8 i;
558
Atul Mittalb849d5a2014-07-29 12:08:39 +0530559 limInitOperatingClasses((tHalHandle)pMac);
Agarwal Ashish738843c2014-09-25 12:27:56 +0530560 numChan = sizeof(pMac->roam.validChannelList);
561
562 if ( !HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
563 (tANI_U8 *)pMac->roam.validChannelList, &numChan)))
564 {
565 smsLog( pMac, LOGE, "Failed to get Channel list from CFG");
566 return eHAL_STATUS_FAILED_ALLOC;
567 }
568
569 bufLen = sizeof(tSirUpdateChanList) +
570 (sizeof(tSirUpdateChanParam) * (numChan - 1));
571
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530572 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
573 if (!pChanList)
574 {
575 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
576 "Failed to allocate memory for tSirUpdateChanList");
577 return eHAL_STATUS_FAILED_ALLOC;
578 }
579
580 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
581 msg.reserved = 0;
582 msg.bodyptr = pChanList;
583 pChanList->numChan = numChan;
584 for (i = 0; i < pChanList->numChan; i++)
585 {
Agarwal Ashish738843c2014-09-25 12:27:56 +0530586 pChanList->chanParam[i].chanId = pMac->roam.validChannelList[i];
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800587 pChanList->chanParam[i].pwr = cfgGetRegulatoryMaxTransmitPower(pMac,
588 pScan->defaultPowerTable[i].chanId);
589 if (vos_nv_getChannelEnabledState(pChanList->chanParam[i].chanId) ==
590 NV_CHANNEL_DFS)
591 pChanList->chanParam[i].dfsSet = VOS_TRUE;
592 else
593 pChanList->chanParam[i].dfsSet = VOS_FALSE;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530594 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
595 "%s Supported Channel: %d\n", __func__, pChanList->chanParam[i].chanId);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530596 }
597
598 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
599 {
600 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
601 "%s: Failed to post msg to WDA", __func__);
602 vos_mem_free(pChanList);
603 return eHAL_STATUS_FAILURE;
604 }
605
606 return eHAL_STATUS_SUCCESS;
607}
608
Jeff Johnson295189b2012-06-20 16:38:30 -0700609eHalStatus csrStart(tpAniSirGlobal pMac)
610{
611 eHalStatus status = eHAL_STATUS_SUCCESS;
612 tANI_U32 i;
613
614 do
615 {
616 //save the global vos context
617 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
618 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
619 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
620
621 status = csrRoamStart(pMac);
622 if(!HAL_STATUS_SUCCESS(status)) break;
623 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
624 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
625 if(!HAL_STATUS_SUCCESS(status)) break;
626 pMac->roam.sPendingCommands = 0;
627 csrScanEnable(pMac);
628#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
629 status = csrNeighborRoamInit(pMac);
630#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
631 pMac->roam.tlStatsReqInfo.numClient = 0;
632 pMac->roam.tlStatsReqInfo.periodicity = 0;
633 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
634 //init the link quality indication also
635 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
636 if(!HAL_STATUS_SUCCESS(status))
637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800638 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 break;
640 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530641
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700643#if defined(ANI_LOGDUMP)
644 csrDumpInit(pMac);
645#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700646 return (status);
647}
648
Kiet Lama72a2322013-11-15 11:18:11 +0530649eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700650{
651 tANI_U32 sessionId;
652 tANI_U32 i;
653
654 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
655 {
656 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
657 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 csrScanDisable(pMac);
659 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
660 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
662
663#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
664 csrNeighborRoamClose(pMac);
665#endif
666 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 // deregister from PMC since we register during csrStart()
668 // (ignore status since there is nothing we can do if it fails)
669 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700670 //Reset the domain back to the deault
671 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800672 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700673
674 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
675 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530676 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
678 }
679
Kiet Lama72a2322013-11-15 11:18:11 +0530680#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
681 /* When HAL resets all the context information
682 * in HAL is lost, so we might need to send the
683 * scan offload request again when it comes
684 * out of reset for scan offload to be functional
685 */
686 if (HAL_STOP_TYPE_SYS_RESET == stopType)
687 {
688 bRoamScanOffloadStarted = VOS_FALSE;
689 }
690#endif
691
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 return (eHAL_STATUS_SUCCESS);
693}
694
Jeff Johnson295189b2012-06-20 16:38:30 -0700695eHalStatus csrReady(tpAniSirGlobal pMac)
696{
697 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 csrScanGetSupportedChannels( pMac );
699 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
700 //use it to init the background scan list
701 csrInitBGScanChannelList(pMac);
702 /* HDD issues the init scan */
703 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800704 /* If the gScanAgingTime is set to '0' then scan results aging timeout
705 based on timer feature is not enabled*/
706 if(0 != pMac->scan.scanResultCfgAgingTime )
707 {
708 csrScanStartResultCfgAgingTimer(pMac);
709 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 //Store the AC weights in TL for later use
711 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700712 status = csrInitChannelList( pMac );
713 if ( ! HAL_STATUS_SUCCESS( status ) )
714 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800715 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 status );
717 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 return (status);
719}
Jeff Johnson295189b2012-06-20 16:38:30 -0700720void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
721{
722 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
724 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
725}
Jeff Johnson295189b2012-06-20 16:38:30 -0700726void csrSetGlobalCfgs( tpAniSirGlobal pMac )
727{
Jeff Johnsone7245742012-09-05 17:12:55 -0700728
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
730 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
731 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
732 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
733 NULL, eANI_BOOLEAN_FALSE);
734 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700735 /* 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
736 * Once session is established we will use the session related params stored in PE session for CB mode
737 */
738 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
740
741 //Update the operating mode to configured value during initialization,
742 //So that client can advertise full capabilities in Probe request frame.
743 csrSetDefaultDot11Mode( pMac );
744}
745
Jeff Johnson295189b2012-06-20 16:38:30 -0700746eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
747{
748 eHalStatus status = eHAL_STATUS_SUCCESS;
749 tANI_U32 i;
750 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 do
752 {
753 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
754 {
755 pSession = CSR_GET_SESSION( pMac, i );
756 pSession->roamingTimerInfo.pMac = pMac;
757 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
758 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
760 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530761 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
762 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530764 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800766 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 break;
768 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530769 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
770 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
771 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800773 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 return eHAL_STATUS_FAILURE;
775 }
776 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700777 return (status);
778}
779
Jeff Johnson295189b2012-06-20 16:38:30 -0700780eHalStatus csrRoamClose(tpAniSirGlobal pMac)
781{
782 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
784 {
785 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
786 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530787 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
788 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
789 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
790 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700791 return (eHAL_STATUS_SUCCESS);
792}
793
Jeff Johnson295189b2012-06-20 16:38:30 -0700794eHalStatus csrRoamStart(tpAniSirGlobal pMac)
795{
796 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 return (eHAL_STATUS_SUCCESS);
798}
799
Jeff Johnson295189b2012-06-20 16:38:30 -0700800void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
801{
802 csrRoamStopRoamingTimer(pMac, sessionId);
803 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
804 csrRoamDeregStatisticsReq(pMac);
805}
Jeff Johnson295189b2012-06-20 16:38:30 -0700806eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
807{
808 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800809 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 {
811 status = eHAL_STATUS_SUCCESS;
812 *pState = pMac->roam.roamSession[sessionId].connectState;
813 }
814 return (status);
815}
816
Jeff Johnson295189b2012-06-20 16:38:30 -0700817eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
818{
819 eHalStatus status = eHAL_STATUS_FAILURE;
820 tANI_U32 size = 0;
821 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700822
823 if(!pSession)
824 {
825 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
826 return eHAL_STATUS_FAILURE;
827 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700828
829 if(pProfile)
830 {
831 if(pSession->pConnectBssDesc)
832 {
833 do
834 {
835 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
836 if(size)
837 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530838 pProfile->pBssDesc = vos_mem_malloc(size);
839 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530841 vos_mem_copy(pProfile->pBssDesc,
842 pSession->pConnectBssDesc, size);
843 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 }
845 else
846 break;
847 }
848 else
849 {
850 pProfile->pBssDesc = NULL;
851 }
852 pProfile->AuthType = pSession->connectedProfile.AuthType;
853 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
854 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
855 pProfile->BSSType = pSession->connectedProfile.BSSType;
856 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
857 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530858 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
859 sizeof(tCsrBssid));
860 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
861 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700862#ifdef WLAN_FEATURE_VOWIFI_11R
863 if (pSession->connectedProfile.MDID.mdiePresent)
864 {
865 pProfile->MDID.mdiePresent = 1;
866 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
867 }
868 else
869 {
870 pProfile->MDID.mdiePresent = 0;
871 pProfile->MDID.mobilityDomain = 0;
872 }
873#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800874#ifdef FEATURE_WLAN_ESE
875 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
876 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800878 vos_mem_copy (pProfile->eseCckmInfo.krk,
879 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530880 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800881 pProfile->eseCckmInfo.reassoc_req_num=
882 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
883 pProfile->eseCckmInfo.krk_plumbed =
884 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 }
886#endif
887 }while(0);
888 }
889 }
890
891 return (status);
892}
893
Jeff Johnson295189b2012-06-20 16:38:30 -0700894eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
895{
896 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700897
898 if((csrIsConnStateConnected(pMac, sessionId)) ||
899 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 {
901 if(pProfile)
902 {
903 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
904 }
905 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700906 return (status);
907}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700908
Jeff Johnson295189b2012-06-20 16:38:30 -0700909eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
910{
911 eHalStatus status = eHAL_STATUS_SUCCESS;
912
Kiet Lam64c1b492013-07-12 13:56:44 +0530913 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530915 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530917 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700918 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530919 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700920 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530921 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
922
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
924 return (status);
925}
926
Jeff Johnson295189b2012-06-20 16:38:30 -0700927static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
928{
929 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 if( pConnectedInfo->pbFrames )
931 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530932 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700933 pConnectedInfo->pbFrames = NULL;
934 }
935 pConnectedInfo->nBeaconLength = 0;
936 pConnectedInfo->nAssocReqLength = 0;
937 pConnectedInfo->nAssocRspLength = 0;
938 pConnectedInfo->staId = 0;
939#ifdef WLAN_FEATURE_VOWIFI_11R
940 pConnectedInfo->nRICRspLength = 0;
941#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800942#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 pConnectedInfo->nTspecIeLength = 0;
944#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 return ( status );
946}
947
Jeff Johnson295189b2012-06-20 16:38:30 -0700948
949
Jeff Johnsone7245742012-09-05 17:12:55 -0700950
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700951void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
952{
953 csrReinitPreauthCmd(pMac, pCommand);
954 csrReleaseCommand( pMac, pCommand );
955}
956
Jeff Johnson295189b2012-06-20 16:38:30 -0700957void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
958{
959 csrReinitRoamCmd(pMac, pCommand);
960 csrReleaseCommand( pMac, pCommand );
961}
962
Jeff Johnson295189b2012-06-20 16:38:30 -0700963void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
964{
965 csrReinitScanCmd(pMac, pCommand);
966 csrReleaseCommand( pMac, pCommand );
967}
968
Jeff Johnson295189b2012-06-20 16:38:30 -0700969void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
970{
971 csrReinitWmStatusChangeCmd(pMac, pCommand);
972 csrReleaseCommand( pMac, pCommand );
973}
974
Jeff Johnson295189b2012-06-20 16:38:30 -0700975void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
976{
Kiet Lam64c1b492013-07-12 13:56:44 +0530977 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700978}
979
Jeff Johnson295189b2012-06-20 16:38:30 -0700980void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
981{
Kiet Lam64c1b492013-07-12 13:56:44 +0530982 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700983}
984
Jeff Johnson295189b2012-06-20 16:38:30 -0700985void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
986{
987 csrReinitSetKeyCmd(pMac, pCommand);
988 csrReleaseCommand( pMac, pCommand );
989}
Jeff Johnson295189b2012-06-20 16:38:30 -0700990void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
991{
992 csrReinitRemoveKeyCmd(pMac, pCommand);
993 csrReleaseCommand( pMac, pCommand );
994}
Jeff Johnson295189b2012-06-20 16:38:30 -0700995void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
996{
997
998 if( eSmeCsrCommandMask & pCommand->command )
999 {
1000 switch (pCommand->command)
1001 {
1002 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -08001003 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -08001004 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
1005 __func__, pCommand->u.scanCmd.reason,
1006 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 if (NULL != pCommand->u.scanCmd.callback)
1008 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001009 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
1011 }
1012 csrReleaseCommandScan( pMac, pCommand );
1013 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 case eSmeCommandRoam:
1015 csrReleaseCommandRoam( pMac, pCommand );
1016 break;
1017
1018 case eSmeCommandWmStatusChange:
1019 csrReleaseCommandWmStatusChange( pMac, pCommand );
1020 break;
1021
1022 case eSmeCommandSetKey:
1023 csrReleaseCommandSetKey( pMac, pCommand );
1024 break;
1025
1026 case eSmeCommandRemoveKey:
1027 csrReleaseCommandRemoveKey( pMac, pCommand );
1028 break;
1029
1030 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001031 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 csrReleaseCommand( pMac, pCommand );
1033 break;
1034 }
1035 }
1036}
1037
Jeff Johnson295189b2012-06-20 16:38:30 -07001038void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
1039{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301040 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1041 macTraceGetcsrRoamSubState(NewSubstate),
1042 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001043
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1045 {
1046 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 pMac->roam.curSubState[sessionId] = NewSubstate;
1049}
1050
Jeff Johnson295189b2012-06-20 16:38:30 -07001051eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1052{
1053 eCsrRoamState PreviousState;
1054
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301055 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1056 macTraceGetcsrRoamState(NewRoamState),
1057 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001058
1059 PreviousState = pMac->roam.curState[sessionId];
1060
1061 if ( NewRoamState != pMac->roam.curState[sessionId] )
1062 {
1063 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1064 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1065 {
1066 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1067 }
1068
1069 pMac->roam.curState[sessionId] = NewRoamState;
1070 }
1071 return( PreviousState );
1072}
1073
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001074void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001075{
1076 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 if(catOffset)
1078 {
1079 pMac->roam.configParam.bCatRssiOffset = catOffset;
1080 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1081 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001082 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 -07001083 }
1084 }
1085}
1086
Jeff Johnson295189b2012-06-20 16:38:30 -07001087static void initConfigParam(tpAniSirGlobal pMac)
1088{
1089 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001090 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301091 pMac->roam.configParam.channelBondingMode24GHz =
1092 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1093 pMac->roam.configParam.channelBondingMode5GHz =
1094 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1096 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1097 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1098 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1099 pMac->roam.configParam.HeartbeatThresh24 = 40;
1100 pMac->roam.configParam.HeartbeatThresh50 = 40;
1101 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1102 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1103 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001104 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 pMac->roam.configParam.RTSThreshold = 2346;
1106 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1107 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1108 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1109 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1110 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1111 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1112 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1113 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1114 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1115 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1116 {
1117 pMac->roam.configParam.BssPreferValue[i] = i;
1118 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001119 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001120 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1121 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1122 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1124 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05301125 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1127 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1128 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1129 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001130 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1131 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001132 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001133#ifdef WLAN_AP_STA_CONCURRENCY
1134 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1135 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1136 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1137 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1138 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001139 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1140 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001141#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001142 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1143 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1144 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1145 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001146#ifdef WLAN_FEATURE_VOWIFI_11R
1147 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1148#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001149#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1150 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1151 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1152 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1153 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1154 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1155 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1156 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1157 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1158 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1159 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1160 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001161 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05301162 pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001163#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001164#ifdef WLAN_FEATURE_11AC
1165 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1166#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001167
1168 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1169 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001170
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001171 //Remove this code once SLM_Sessionization is supported
1172 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001173 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001174
Jeff Johnsone7245742012-09-05 17:12:55 -07001175}
Jeff Johnson295189b2012-06-20 16:38:30 -07001176eCsrBand csrGetCurrentBand(tHalHandle hHal)
1177{
1178 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1179 return pMac->roam.configParam.bandCapability;
1180}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001181
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001182
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001183#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001184/*
1185 This function flushes the roam scan cache
1186*/
1187eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1188{
1189 eHalStatus status = eHAL_STATUS_SUCCESS;
1190 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1191
1192 /* Free up the memory first (if required) */
1193 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1194 {
1195 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1196 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1197 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1198 }
1199 return status;
1200}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001201#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001202
1203
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001204#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001205/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001206 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001207*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001208eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001209{
1210 eHalStatus status = eHAL_STATUS_SUCCESS;
1211 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1212
1213 /* Free up the memory first (if required) */
1214 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1215 {
1216 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1217 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001218 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001219 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001220 return status;
1221}
1222
1223
1224
1225/*
1226 This function flushes the roam scan cache and creates fresh cache
1227 based on the input channel list
1228*/
1229eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1230 const tANI_U8 *pChannelList,
1231 const tANI_U8 numChannels)
1232{
1233 eHalStatus status = eHAL_STATUS_SUCCESS;
1234 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1235
Srinivas Girigowdade697412013-02-14 16:31:48 -08001236 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1237
1238 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1239 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1240
1241 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1242 {
1243 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1244 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1245 return eHAL_STATUS_RESOURCES;
1246 }
1247
1248 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301249 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1250 pChannelList,
1251 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001252 return status;
1253}
1254
1255/* This function modifies the bgscan channel list set via config ini or
1256 runtime, whenever the band changes.
1257 if the band is auto, then no operation is performed on the channel list
1258 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1259 if the band is 5G, then make sure channel list contains only 5G valid channels
1260*/
1261eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1262 eCsrBand eBand)
1263{
1264 eHalStatus status = eHAL_STATUS_SUCCESS;
1265 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1266 tANI_U8 outNumChannels = 0;
1267 tANI_U8 inNumChannels = 0;
1268 tANI_U8 *inPtr = NULL;
1269 tANI_U8 i = 0;
1270 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1271
1272 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1273
1274 {
1275 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1276 "No update required for channel list "
1277 "either cfg.ini channel list is not set up or "
1278 "auto band (Band %d)", eBand);
1279 return status;
1280 }
1281
1282 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1283 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1284 if (eCSR_BAND_24 == eBand)
1285 {
1286 for (i = 0; i < inNumChannels; i++)
1287 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001288 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001289 {
1290 ChannelList[outNumChannels++] = inPtr[i];
1291 }
1292 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001293 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001294 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001295 }
1296 else if (eCSR_BAND_5G == eBand)
1297 {
1298 for (i = 0; i < inNumChannels; i++)
1299 {
1300 /* Add 5G Non-DFS channel */
1301 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001302 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001303 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1304 {
1305 ChannelList[outNumChannels++] = inPtr[i];
1306 }
1307 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001308 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001309 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001310 }
1311 else if (eCSR_BAND_ALL == eBand)
1312 {
1313 for (i = 0; i < inNumChannels; i++)
1314 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001315 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001316 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1317 {
1318 ChannelList[outNumChannels++] = inPtr[i];
1319 }
1320 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001321 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001322 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001323 }
1324 else
1325 {
1326 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1327 "Invalid band, No operation carried out (Band %d)", eBand);
1328 status = eHAL_STATUS_INVALID_PARAMETER;
1329 }
1330
1331 return status;
1332}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001333#endif
1334
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001335#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001336/* This function modifies the roam scan channel list as per AP neighbor
1337 report; AP neighbor report may be empty or may include only other AP
1338 channels; in any case, we merge the channel list with the learned occupied
1339 channels list.
1340 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1341 if the band is 5G, then make sure channel list contains only 5G valid channels
1342*/
1343eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1344 tANI_U8 *pChannelList,
1345 tANI_U8 numChannels,
1346 const eCsrBand eBand)
1347{
1348 eHalStatus status = eHAL_STATUS_SUCCESS;
1349 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1350 tANI_U8 outNumChannels = 0;
1351 tANI_U8 inNumChannels = numChannels;
1352 tANI_U8 *inPtr = pChannelList;
1353 tANI_U8 i = 0;
1354 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1355 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1356 tANI_U8 mergedOutputNumOfChannels = 0;
1357 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1358
1359 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1360 * report Channels. This increases the chances of the DUT to get a candidate AP while
1361 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1362 if (pMac->scan.occupiedChannels.numChannels)
1363 {
1364 csrNeighborRoamMergeChannelLists(pMac,
1365 &pMac->scan.occupiedChannels.channelList[0],
1366 pMac->scan.occupiedChannels.numChannels,
1367 inPtr,
1368 inNumChannels,
1369 &mergedOutputNumOfChannels);
1370 inNumChannels = mergedOutputNumOfChannels;
1371 }
1372
1373 if (eCSR_BAND_24 == eBand)
1374 {
1375 for (i = 0; i < inNumChannels; i++)
1376 {
1377 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1378 {
1379 ChannelList[outNumChannels++] = inPtr[i];
1380 }
1381 }
1382 }
1383 else if (eCSR_BAND_5G == eBand)
1384 {
1385 for (i = 0; i < inNumChannels; i++)
1386 {
1387 /* Add 5G Non-DFS channel */
1388 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1389 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1390 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1391 {
1392 ChannelList[outNumChannels++] = inPtr[i];
1393 }
1394 }
1395 }
1396 else if (eCSR_BAND_ALL == eBand)
1397 {
1398 for (i = 0; i < inNumChannels; i++)
1399 {
1400 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1401 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1402 {
1403 ChannelList[outNumChannels++] = inPtr[i];
1404 }
1405 }
1406 }
1407 else
1408 {
1409 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1410 "Invalid band, No operation carried out (Band %d)", eBand);
1411 return eHAL_STATUS_INVALID_PARAMETER;
1412 }
1413
1414 /* if roaming within band is enabled, then select only the
1415 in band channels .
1416 This is required only if the band capability is set to ALL,
1417 E.g., if band capability is only 2.4G then all the channels in the
1418 list are already filtered for 2.4G channels, hence ignore this check*/
1419
1420 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1421 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301422 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001423 pMac,
1424 ChannelList,
1425 outNumChannels,
1426 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301427 &outNumChannels,
1428 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301429 vos_mem_copy(ChannelList,
1430 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001431 }
1432
1433 /* Prepare final roam scan channel list */
1434 if(outNumChannels)
1435 {
1436 /* Clear the channel list first */
1437 if (NULL != currChannelListInfo->ChannelList)
1438 {
1439 vos_mem_free(currChannelListInfo->ChannelList);
1440 currChannelListInfo->ChannelList = NULL;
1441 currChannelListInfo->numOfChannels = 0;
1442 }
1443
1444 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1445 if (NULL == currChannelListInfo->ChannelList)
1446 {
1447 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1448 "Failed to allocate memory for roam scan channel list");
1449 currChannelListInfo->numOfChannels = 0;
1450 return VOS_STATUS_E_RESOURCES;
1451 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301452 vos_mem_copy(currChannelListInfo->ChannelList,
1453 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001454 }
1455 return status;
1456}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001457#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001458
Jeff Johnson295189b2012-06-20 16:38:30 -07001459eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1460{
1461 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1462 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1464 (eBand == eCSR_BAND_24))
1465 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001466 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001467 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001468 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001469 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 pMac->roam.configParam.uCfgDot11Mode, eBand);
1471 return eHAL_STATUS_INVALID_PARAMETER;
1472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1474 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1475 (eBand == eCSR_BAND_5G))
1476 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001477 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001479 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001480 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 pMac->roam.configParam.uCfgDot11Mode, eBand);
1482 return eHAL_STATUS_INVALID_PARAMETER;
1483 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001484 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001485 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001486 pMac->roam.configParam.eBand = eBand;
1487 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001489#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001490 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1491 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001492#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 status = csrInitGetChannels( pMac );
1494 if (eHAL_STATUS_SUCCESS == status)
1495 csrInitChannelList( hHal );
1496 return status;
1497}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001498
1499
Jeff Johnsone7245742012-09-05 17:12:55 -07001500/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1501 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1502 * Ideally we should have kept the ini value and enum value same and representing the same
1503 * cb values as in 11n standard i.e.
1504 * Set to 1 (SCA) if the secondary channel is above the primary channel
1505 * Set to 3 (SCB) if the secondary channel is below the primary channel
1506 * Set to 0 (SCN) if no secondary channel is present
1507 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1508 * 0 - secondary none
1509 * 1 - secondary LOW
1510 * 2 - secondary HIGH
1511 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1512 * The enum values are as follows:
1513 * PHY_SINGLE_CHANNEL_CENTERED = 0
1514 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1515 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1516 */
1517ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1518{
1519
1520 ePhyChanBondState phyCbState;
1521 switch (cbIniValue) {
1522 // secondary none
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301523 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001524 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1525 break;
1526 // secondary LOW
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301527 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001528 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1529 break;
1530 // secondary HIGH
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301531 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001532 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1533 break;
1534#ifdef WLAN_FEATURE_11AC
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301535 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1536 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001537 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301538 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001539 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1540 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301541 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1542 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1543 break;
1544 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001545 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1546 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301547 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001548 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301549 break;
1550 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001551 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1552 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301553 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001554 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301555 break;
1556#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001557 default:
1558 // If an invalid value is passed, disable CHANNEL BONDING
1559 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1560 break;
1561 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301562
Jeff Johnsone7245742012-09-05 17:12:55 -07001563 return phyCbState;
1564}
1565
1566v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1567{
1568
1569 v_U32_t cbIniValue;
1570 switch (phyCbState) {
1571 // secondary none
1572 case PHY_SINGLE_CHANNEL_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301573 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001574 break;
1575 // secondary LOW
1576 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301577 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001578 break;
1579 // secondary HIGH
1580 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301581 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001582 break;
1583#ifdef WLAN_FEATURE_11AC
1584 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301585 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001586 break;
1587 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301588 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001589 break;
1590 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301591 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001592 break;
1593 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301594 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001595 break;
1596 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301597 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001598 break;
1599 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301600 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001601 break;
1602 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301603 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001604 break;
1605#endif
1606 default:
1607 // return some invalid value
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301608 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
Jeff Johnsone7245742012-09-05 17:12:55 -07001609 break;
1610 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301611
Jeff Johnsone7245742012-09-05 17:12:55 -07001612 return cbIniValue;
1613}
Jeff Johnson295189b2012-06-20 16:38:30 -07001614
1615eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1616{
1617 eHalStatus status = eHAL_STATUS_SUCCESS;
1618
1619 if(pParam)
1620 {
1621 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1622 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1623 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1624 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1625 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1626 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1627
1628 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001629 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1630
Jeff Johnsone7245742012-09-05 17:12:55 -07001631 /* channelBondingMode5GHz plays a dual role right now
1632 * 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
1633 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1634 */
1635 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1636 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001637 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001638 }
1639 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1640 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1641 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001642 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001643 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301644#ifdef WLAN_FEATURE_AP_HT40_24G
1645 pMac->roam.configParam.channelBondingAPMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingAPMode24GHz);
1646#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001647 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1649 pMac->roam.configParam.phyMode = pParam->phyMode;
1650 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1651 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1652 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1653 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1654 pMac->roam.configParam.TxRate = pParam->TxRate;
1655 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1656 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1657 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1658 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1659 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001660 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 //if HDD passed down non zero values then only update,
1662 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301663 if (pParam->nInitialDwellTime)
1664 {
1665 pMac->roam.configParam.nInitialDwellTime =
1666 pParam->nInitialDwellTime;
1667 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001668 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 {
1670 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301671 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1672 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001674 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 {
1676 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301677 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1678 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001679 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001680 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 {
1682 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301683 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1684 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001686 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001687 {
1688 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301689 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1690 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 }
Sushant Kaushikc9682be2014-11-26 12:27:04 +05301692 if (pParam->nOBSSScanWidthTriggerInterval)
1693 {
1694 pMac->roam.configParam.nOBSSScanWidthTriggerInterval =
1695 pParam->nOBSSScanWidthTriggerInterval;
1696 cfgSetInt(pMac, WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
1697 pParam->nOBSSScanWidthTriggerInterval);
1698 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001699 if (pParam->nActiveMaxChnTimeBtc)
1700 {
1701 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1702 }
1703 if (pParam->nActiveMinChnTimeBtc)
1704 {
1705 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1706 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001707#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001708 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001709 {
1710 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1711 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001712 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001713 {
1714 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1715 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001716 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001717 {
1718 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1719 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001720 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001721 {
1722 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1723 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001724 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001725 {
1726 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1727 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001728 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001729 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001730 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1731 }
1732 if (pParam->nNumP2PChanCombinedConc)
1733 {
1734 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001735 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001736#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001738 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 {
1740 //Change the unit from second to microsecond
1741 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1743 {
1744 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1745 }
1746 else
1747 {
1748 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1749 }
1750 }
1751 else
1752 {
1753 pMac->roam.configParam.impsSleepTime = 0;
1754 }
1755 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1757 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 //if HDD passed down non zero values for age params, then only update,
1759 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001760 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 {
1762 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 if(pParam->scanAgeTimeNCNPS)
1765 {
1766 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 if(pParam->scanAgeTimeNCPS)
1769 {
1770 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 if(pParam->scanAgeTimeCNPS)
1773 {
1774 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1775 }
1776 if(pParam->scanAgeTimeCPS)
1777 {
1778 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1779 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301780 if (pParam->initialScanSkipDFSCh)
1781 {
1782 pMac->roam.configParam.initialScanSkipDFSCh =
1783 pParam->initialScanSkipDFSCh;
1784 }
1785
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001786 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1788 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1789 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1790 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1791 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1793 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1795 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1796 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1797 //Assign this before calling CsrInit11dInfo
1798 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001799 if( csrIs11dSupported( pMac ) )
1800 {
1801 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1802 }
1803 else
1804 {
1805 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1806 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001807
1808 /* Initialize the power + channel information if 11h is enabled.
1809 If 11d is enabled this information has already been initialized */
1810 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1811 {
1812 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1813 }
1814
1815
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301816#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301817 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1818 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001819 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001820#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001821#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001822 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001823 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001824 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001825 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001826 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001827 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001828 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001829 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001830 pMac->roam.configParam.nProbes = pParam->nProbes;
1831 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001832#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001833#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1834 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001835 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001836#endif
1837#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001838 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001839 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001840#endif
1841
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001842#ifdef FEATURE_WLAN_ESE
1843 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001844#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001845#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301846 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1847 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001848 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1849 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1850 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1851 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1852 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1853 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1854 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1855 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05301856 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 {
1858 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001859 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 -07001860 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1861 {
1862 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1863 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001864 }
1865#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1867 pMac->scan.fValidateList = pParam->fValidateList;
1868 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1869 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001870 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001872 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
Peng Xu2446a892014-09-05 17:21:18 +05301873 pMac->scan.scanBandPreference = pParam->scanBandPreference;
Jeff Johnsone7245742012-09-05 17:12:55 -07001874 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1875 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1876 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1877 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1878 * single session
1879 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001880 //Remove this code once SLM_Sessionization is supported
1881 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001882 pMac->roam.configParam.doBMPSWorkaround = 0;
1883
Jeff Johnsone7245742012-09-05 17:12:55 -07001884#ifdef WLAN_FEATURE_11AC
1885 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001886 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001887 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001888 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301889 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1890 if ( pParam->enableTxBF )
1891 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
1892 else
1893 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001894#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001895 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001896
1897 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001898 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001899 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1900 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301901 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05301902 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301903#ifdef WLAN_FEATURE_AP_HT40_24G
1904 pMac->roam.configParam.apHT40_24GEnabled = pParam->apHT40_24GEnabled;
1905#endif
1906
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 }
1908
1909 return status;
1910}
1911
Jeff Johnson295189b2012-06-20 16:38:30 -07001912eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1913{
1914 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 if(pParam)
1916 {
1917 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1918 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1919 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1920 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1921 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1922 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001923 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301924#ifdef WLAN_FEATURE_AP_HT40_24G
1925 pParam->channelBondingAPMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingAPMode24GHz);
1926#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001927 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1929 pParam->phyMode = pMac->roam.configParam.phyMode;
1930 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1931 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1932 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1933 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1934 pParam->TxRate = pMac->roam.configParam.TxRate;
1935 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1936 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1937 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1938 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1939 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1941 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1942 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1943 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001944 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1945 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1946 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001947#ifdef WLAN_AP_STA_CONCURRENCY
1948 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1949 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1950 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1951 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1952 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001953 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1954 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001955#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001956 //Change the unit from microsecond to second
1957 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1958 pParam->eBand = pMac->roam.configParam.eBand;
1959 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1960 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1961 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1962 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1963 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1964 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1965 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1966 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1967 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1968 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1969 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1970 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1971 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1973 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1974 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1975 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1977 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1978 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1979 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1980 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001981 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001982 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001983 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001984 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Peng Xu2446a892014-09-05 17:21:18 +05301985 pParam->scanBandPreference = pMac->scan.scanBandPreference;
Jeff Johnson295189b2012-06-20 16:38:30 -07001986#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301987 vos_mem_copy(&pParam->neighborRoamConfig,
1988 &pMac->roam.configParam.neighborRoamConfig,
1989 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001990#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001991#ifdef WLAN_FEATURE_11AC
1992 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001993 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001994 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001995 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301996 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1997 if ( pParam->enableTxBF )
1998 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
1999 else
2000 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002001#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002002#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05302003 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
2004 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002005#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002006#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002007 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
2008 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
2009 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
2010 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
2011 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07002012 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07002013 pParam->nProbes = pMac->roam.configParam.nProbes;
2014 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002015#endif
2016#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2017 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
2018 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
2019#endif
2020#ifdef FEATURE_WLAN_LFR
2021 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
2022#endif
2023
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002024#ifdef FEATURE_WLAN_ESE
2025 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002026#endif
2027#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302028 vos_mem_copy(&pParam->neighborRoamConfig,
2029 &pMac->roam.configParam.neighborRoamConfig,
2030 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002031 {
2032 int i;
2033 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
2034 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2035 {
2036 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2037 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002038 }
2039#endif
2040
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07002041 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07002042
krunal soni5afa96c2013-09-06 22:19:02 -07002043 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002044 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07002045
krunal sonie9002db2013-11-25 14:24:17 -08002046 pParam->isCoalesingInIBSSAllowed =
2047 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302048 pParam->allowDFSChannelRoam =
2049 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302050 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07002051 csrSetChannels(pMac, pParam);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302052#ifdef WLAN_FEATURE_AP_HT40_24G
2053 pParam->apHT40_24GEnabled = pMac->roam.configParam.apHT40_24GEnabled;
2054#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002055
2056 status = eHAL_STATUS_SUCCESS;
2057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 return (status);
2059}
2060
Jeff Johnson295189b2012-06-20 16:38:30 -07002061eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
2062{
2063 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2064 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2065 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2066 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 do
2068 {
2069 if(eCSR_BAND_24 == eBand)
2070 {
2071 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2072 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2073 }
2074 if(eCSR_BAND_5G == eBand)
2075 {
2076 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2077 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2078 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2079 )
2080 {
2081 break;
2082 }
2083 }
2084 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2085 {
2086 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2087 }
2088 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2089 {
2090 newPhyMode = eCSR_DOT11_MODE_AUTO;
2091 }
2092 else
2093 {
2094 //Check for dual band and higher capability first
2095 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2096 {
2097 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2098 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2099 }
2100 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2101 {
2102 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2103 if(eCSR_BAND_24 == eBand) break;
2104 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2105 eBand = eCSR_BAND_5G;
2106 }
2107 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2108 {
2109 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2110 if(eCSR_BAND_5G == eBand) break;
2111 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2112 eBand = eCSR_BAND_24;
2113 }
2114 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2115 {
2116 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2117 if(eCSR_BAND_5G == eBand) break;
2118 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2119 eBand = eCSR_BAND_24;
2120 }
2121 else if(eCSR_DOT11_MODE_11n & phyMode)
2122 {
2123 newPhyMode = eCSR_DOT11_MODE_11n;
2124 }
2125 else if(eCSR_DOT11_MODE_abg & phyMode)
2126 {
2127 newPhyMode = eCSR_DOT11_MODE_abg;
2128 }
2129 else if(eCSR_DOT11_MODE_11a & phyMode)
2130 {
2131 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2132 {
2133 if(eCSR_BAND_ALL == eBand)
2134 {
2135 newPhyMode = eCSR_DOT11_MODE_abg;
2136 }
2137 else
2138 {
2139 //bad setting
2140 break;
2141 }
2142 }
2143 else
2144 {
2145 newPhyMode = eCSR_DOT11_MODE_11a;
2146 eBand = eCSR_BAND_5G;
2147 }
2148 }
2149 else if(eCSR_DOT11_MODE_11g & phyMode)
2150 {
2151 newPhyMode = eCSR_DOT11_MODE_11g;
2152 eBand = eCSR_BAND_24;
2153 }
2154 else if(eCSR_DOT11_MODE_11b & phyMode)
2155 {
2156 newPhyMode = eCSR_DOT11_MODE_11b;
2157 eBand = eCSR_BAND_24;
2158 }
2159 else
2160 {
2161 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002162 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 newPhyMode = eCSR_DOT11_MODE_AUTO;
2164 }
2165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 //Done validating
2167 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 //Now we need to check whether a restart is needed.
2169 if(eBand != pMac->roam.configParam.eBand)
2170 {
2171 fRestartNeeded = eANI_BOOLEAN_TRUE;
2172 break;
2173 }
2174 if(newPhyMode != pMac->roam.configParam.phyMode)
2175 {
2176 fRestartNeeded = eANI_BOOLEAN_TRUE;
2177 break;
2178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002180 if(HAL_STATUS_SUCCESS(status))
2181 {
2182 pMac->roam.configParam.eBand = eBand;
2183 pMac->roam.configParam.phyMode = newPhyMode;
2184 if(pfRestartNeeded)
2185 {
2186 *pfRestartNeeded = fRestartNeeded;
2187 }
2188 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 return (status);
2190}
2191
Jeff Johnson295189b2012-06-20 16:38:30 -07002192void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2193{
2194 tANI_U8 Index;
2195 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 // for dual band NICs, don't need to trim the channel list....
2197 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2198 {
2199 // 2.4 GHz band operation requires the channel list to be trimmed to
2200 // the 2.4 GHz channels only...
2201 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2202 {
2203 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2204 Index++ )
2205 {
2206 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2207 {
2208 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2209 cChannels++;
2210 }
2211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2213 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2214 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2215 // only if we need to.
2216 //
2217 // The amount of memory to clear is the number of channesl that we trimmed
2218 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2219
2220 if ( pChannelList->numChannels > cChannels )
2221 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302222 vos_mem_set(&pChannelList->channelList[ cChannels ],
2223 sizeof( pChannelList->channelList[ 0 ] ) *
2224 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 }
2226
2227 pChannelList->numChannels = cChannels;
2228 }
2229 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2230 {
2231 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2232 {
2233 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2234 {
2235 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2236 cChannels++;
2237 }
2238 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002239 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2240 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2241 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2242 // only if we need to.
2243 //
2244 // The amount of memory to clear is the number of channesl that we trimmed
2245 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2246 if ( pChannelList->numChannels > cChannels )
2247 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302248 vos_mem_set(&pChannelList->channelList[ cChannels ],
2249 sizeof( pChannelList->channelList[ 0 ] ) *
2250 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 }
2252
2253 pChannelList->numChannels = cChannels;
2254 }
2255 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002256}
Jeff Johnson295189b2012-06-20 16:38:30 -07002257#define INFRA_AP_DEFAULT_CHANNEL 6
2258eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2259{
2260 tANI_U8 index= 0;
2261 eHalStatus status = eHAL_STATUS_FAILURE;
2262 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2263 {
2264 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2265 status = eHAL_STATUS_SUCCESS;
2266 break;
2267 }
2268 }
2269 return status;
2270}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002271
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002272
Jeff Johnson295189b2012-06-20 16:38:30 -07002273eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2274{
2275 eHalStatus status = eHAL_STATUS_SUCCESS;
2276 tANI_U8 num20MHzChannelsFound = 0;
2277 VOS_STATUS vosStatus;
2278 tANI_U8 Index = 0;
2279 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002280
Jeff Johnson295189b2012-06-20 16:38:30 -07002281
2282 //TODO: this interface changed to include the 40MHz channel list
2283 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2284 // Read the scan channel list (including the power limit) from EEPROM
2285 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2286 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2287 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2288 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002289 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 status = eHAL_STATUS_FAILURE;
2291 }
2292 else
2293 {
2294 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2295 {
2296 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2297 }
2298 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2299 // Move the channel list to the global data
2300 // structure -- this will be used as the scan list
2301 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2302 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 }
2305 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2306 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2307 {
2308 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2309 }
2310 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2311 {
2312 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2313 }
2314 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2315 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 return (status);
2317}
Jeff Johnson295189b2012-06-20 16:38:30 -07002318eHalStatus csrInitChannelList( tHalHandle hHal )
2319{
2320 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2321 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002322 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2323 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002324 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2325 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002327 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302328 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 return (status);
2330}
Jeff Johnson295189b2012-06-20 16:38:30 -07002331eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2332 tCsrUpdateConfigParam *pUpdateConfigParam)
2333{
2334 eHalStatus status = eHAL_STATUS_FAILURE;
2335 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002336 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2337 status = CsrInit11dInfo(pMac, ps11dinfo);
2338 return status;
2339}
2340
Jeff Johnson295189b2012-06-20 16:38:30 -07002341static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2342{
2343 eHalStatus status = eHAL_STATUS_FAILURE;
2344 tANI_U8 index;
2345 tANI_U32 count=0;
2346 tSirMacChanInfo *pChanInfo;
2347 tSirMacChanInfo *pChanInfoStart;
2348 tANI_BOOLEAN applyConfig = TRUE;
2349
Mihir Shetebc866f62014-02-13 16:08:53 +05302350 pMac->scan.currentCountryRSSI = -128;
2351
Jeff Johnson295189b2012-06-20 16:38:30 -07002352 if(!ps11dinfo)
2353 {
2354 return (status);
2355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002356 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2357 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302358 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2359 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2360 ps11dinfo->Channels.channelList,
2361 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002362 }
2363 else
2364 {
2365 //No change
2366 return (eHAL_STATUS_SUCCESS);
2367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302369
2370 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2371 WNI_CFG_COUNTRY_CODE_LEN);
2372
2373
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 //Tush: at csropen get this initialized with default, during csr reset if this
2375 // already set with some value no need initilaize with default again
2376 if(0 == pMac->scan.countryCodeCurrent[0])
2377 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302378 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2379 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302382 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2383 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302385 vos_mem_set(pChanInfo,
2386 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2387 0);
2388
Jeff Johnson295189b2012-06-20 16:38:30 -07002389 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002390 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2391 {
2392 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2393 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2394 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2395 pChanInfo++;
2396 count++;
2397 }
2398 if(count)
2399 {
2400 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2401 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302402 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002403 }
2404 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2405 if( HAL_STATUS_SUCCESS(status) )
2406 {
2407 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2408 {
2409 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2410 {
2411 applyConfig = FALSE;
2412 }
2413 }
2414
2415 if(TRUE == applyConfig)
2416 {
2417 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002418 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002419 }
2420
2421 }
2422 return (status);
2423}
2424/* Initialize the Channel + Power List in the local cache and in the CFG */
2425eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2426{
2427 tANI_U8 index;
2428 tANI_U32 count=0;
2429 tSirMacChanInfo *pChanInfo;
2430 tSirMacChanInfo *pChanInfoStart;
2431
2432 if(!ps11dinfo || !pMac)
2433 {
2434 return eHAL_STATUS_FAILURE;
2435 }
2436
Kiet Lam64c1b492013-07-12 13:56:44 +05302437 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2438 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002439 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302440 vos_mem_set(pChanInfo,
2441 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2442 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002443 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002444
2445 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2446 {
2447 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2448 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2449 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2450 pChanInfo++;
2451 count++;
2452 }
2453 if(count)
2454 {
2455 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2456 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302457 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 }
2459
Jeff Johnsone7245742012-09-05 17:12:55 -07002460 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002461}
2462
2463//pCommand may be NULL
2464//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2465void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2466{
2467 tListElem *pEntry, *pNextEntry;
2468 tSmeCmd *pDupCommand;
2469 tDblLinkList localList;
2470
2471 vos_mem_zero(&localList, sizeof(tDblLinkList));
2472 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2473 {
2474 smsLog(pMac, LOGE, FL(" failed to open list"));
2475 return;
2476 }
2477 csrLLLock( &pMac->sme.smeCmdPendingList );
2478 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2479 while( pEntry )
2480 {
2481 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2482 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 // Remove the previous command if..
2484 // - the new roam command is for the same RoamReason...
2485 // - the new roam command is a NewProfileList.
2486 // - the new roam command is a Forced Dissoc
2487 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2488 if (
2489 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2490 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002491 /* This peermac check is requried for Softap/GO scenarios
2492 * For STA scenario below OR check will suffice as pCommand will
2493 * always be NULL for STA scenarios
2494 */
2495 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2497 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2498 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2499 ||
2500 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002501 ( (sessionId == pDupCommand->sessionId) &&
2502 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 ((eCsrForcedDisassoc == eRoamReason) ||
2504 (eCsrHddIssued == eRoamReason))
2505 )
2506 )
2507 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002508 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 // Remove the 'stale' roam command from the pending list...
2510 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2511 {
2512 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2513 }
2514 }
2515 pEntry = pNextEntry;
2516 }
2517 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2518
2519 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2520 {
2521 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2522 //Tell caller that the command is cancelled
2523 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2524 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2525 csrReleaseCommandRoam(pMac, pDupCommand);
2526 }
2527 csrLLClose(&localList);
2528}
Jeff Johnson295189b2012-06-20 16:38:30 -07002529eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2530 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2531{
2532 eHalStatus status = eHAL_STATUS_SUCCESS;
2533#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2534 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2535#endif
2536 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2538 {
2539 pSession = CSR_GET_SESSION( pMac, sessionId );
2540 }
2541 else
2542 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002543 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 VOS_ASSERT(0);
2545 return eHAL_STATUS_FAILURE;
2546 }
krunal soni587bf012014-02-04 12:35:11 -08002547
2548 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2549 {
2550 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2551 return eHAL_STATUS_FAILURE;
2552 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002553
krunal soni587bf012014-02-04 12:35:11 -08002554 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2555
krunal soni7f7d2c92014-02-06 15:08:43 -08002556 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002558 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002560 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2561 /*
2562 * Decrement bRefAssocStartCnt for FT reassoc failure.
2563 * Reason: For FT reassoc failures, we first call
2564 * csrRoamCallCallback before notifying a failed roam
2565 * completion through csrRoamComplete. The latter in
2566 * turn calls csrRoamProcessResults which tries to
2567 * once again call csrRoamCallCallback if bRefAssocStartCnt
2568 * is non-zero. Since this is redundant for FT reassoc
2569 * failure, decrement bRefAssocStartCnt.
2570 */
2571 pSession->bRefAssocStartCnt--;
2572 }
2573
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 if(NULL != pSession->callback)
2575 {
2576 if( pRoamInfo )
2577 {
2578 pRoamInfo->sessionId = (tANI_U8)sessionId;
2579 }
2580
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302581 /* avoid holding the global lock when making the roaming callback, original change came
2582 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2583 is possible on other OS ports where the callback may need to take locks to protect
2584 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2586 that may actually depend on the lock being held */
2587 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2588 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2589 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2590 }
2591 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2592 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2593#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302594 vos_mem_set(&connectionStatus,
2595 sizeof(vos_event_wlan_status_payload_type), 0);
2596
krunal soni7f7d2c92014-02-06 15:08:43 -08002597 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 {
2599 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2600 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2601 if(NULL != pRoamInfo->pBssDesc)
2602 {
2603 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2604 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2607 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2608 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302609 vos_mem_copy(connectionStatus.ssid,
2610 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2611
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2613 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2614 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2616 {
2617 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2618 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2619 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 if(eCSR_ROAM_RESULT_FORCED == u2)
2622 {
2623 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2624 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2625 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2628 {
2629 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2630 connectionStatus.reason = eCSR_REASON_DISASSOC;
2631 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002633 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2634 {
2635 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2636 connectionStatus.reason = eCSR_REASON_DEAUTH;
2637 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002639#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2640
2641 return (status);
2642}
Jeff Johnson295189b2012-06-20 16:38:30 -07002643// Returns whether handoff is currently in progress or not
2644tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2645{
2646#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2647 return csrNeighborRoamIsHandoffInProgress(pMac);
2648#else
2649 return eANI_BOOLEAN_FALSE;
2650#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002651}
Jeff Johnson295189b2012-06-20 16:38:30 -07002652eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2653 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2654{
2655 eHalStatus status = eHAL_STATUS_SUCCESS;
2656 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2657 tANI_U16 reasonCode;
2658 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002659
2660 if(!pSession)
2661 {
2662 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2663 return eHAL_STATUS_FAILURE;
2664 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002665
2666 //Restore AC weight in case we change it
2667 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2668 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002669 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 -07002670 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2671 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2672 }
2673
2674 if ( fMICFailure )
2675 {
2676 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2677 }
2678 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2679 {
2680 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002681 }
2682 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 {
2684 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002686#ifdef WLAN_FEATURE_VOWIFI_11R
2687 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2688 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2689 {
2690 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302691 vos_mem_copy(&bssId,
2692 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2693 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002694 }
2695 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002696#endif
2697 if(pSession->pConnectBssDesc)
2698 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302699 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002700 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002701
Jeff Johnson295189b2012-06-20 16:38:30 -07002702
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302703 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2704 " subState = %s reason=%d"),
2705 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2706 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002707
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2709
2710 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2711
2712 if(HAL_STATUS_SUCCESS(status))
2713 {
2714 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002715#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2716 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2717 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2718 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002719 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002720 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2721 }
2722#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002723 }
2724 else
2725 {
2726 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2727 }
2728
Jeff Johnson295189b2012-06-20 16:38:30 -07002729 return (status);
2730}
Jeff Johnson295189b2012-06-20 16:38:30 -07002731
Jeff Johnson295189b2012-06-20 16:38:30 -07002732/* ---------------------------------------------------------------------------
2733 \fn csrRoamIssueDisassociateStaCmd
2734 \brief csr function that HDD calls to disassociate a associated station
2735 \param sessionId - session Id for Soft AP
2736 \param pPeerMacAddr - MAC of associated station to delete
2737 \param reason - reason code, be one of the tSirMacReasonCodes
2738 \return eHalStatus
2739 ---------------------------------------------------------------------------*/
2740eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2741 tANI_U32 sessionId,
2742 tANI_U8 *pPeerMacAddr,
2743 tANI_U32 reason)
2744{
2745 eHalStatus status = eHAL_STATUS_SUCCESS;
2746 tSmeCmd *pCommand;
2747
2748 do
2749 {
2750 pCommand = csrGetCommandBuffer( pMac );
2751 if ( !pCommand )
2752 {
2753 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2754 status = eHAL_STATUS_RESOURCES;
2755 break;
2756 }
2757 pCommand->command = eSmeCommandRoam;
2758 pCommand->sessionId = (tANI_U8)sessionId;
2759 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2760 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2761 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2762 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2763 if( !HAL_STATUS_SUCCESS( status ) )
2764 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002765 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 csrReleaseCommandRoam( pMac, pCommand );
2767 }
2768 }while(0);
2769
2770 return status;
2771}
2772
2773
Jeff Johnson295189b2012-06-20 16:38:30 -07002774/* ---------------------------------------------------------------------------
2775 \fn csrRoamIssueDeauthSta
2776 \brief csr function that HDD calls to delete a associated station
2777 \param sessionId - session Id for Soft AP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302778 \param pDelStaParams- Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07002779 \return eHalStatus
2780 ---------------------------------------------------------------------------*/
2781eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302782 tANI_U32 sessionId,
2783 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002784{
2785 eHalStatus status = eHAL_STATUS_SUCCESS;
2786 tSmeCmd *pCommand;
2787
2788 do
2789 {
2790 pCommand = csrGetCommandBuffer( pMac );
2791 if ( !pCommand )
2792 {
2793 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2794 status = eHAL_STATUS_RESOURCES;
2795 break;
2796 }
2797 pCommand->command = eSmeCommandRoam;
2798 pCommand->sessionId = (tANI_U8)sessionId;
2799 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302800 vos_mem_copy(pCommand->u.roamCmd.peerMac, pDelStaParams->peerMacAddr,
2801 sizeof(tSirMacAddr));
2802 pCommand->u.roamCmd.reason =
2803 (tSirMacReasonCodes)pDelStaParams->reason_code;
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2805 if( !HAL_STATUS_SUCCESS( status ) )
2806 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002807 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 csrReleaseCommandRoam( pMac, pCommand );
2809 }
2810 }while(0);
2811
2812 return status;
2813}
Jeff Johnson295189b2012-06-20 16:38:30 -07002814eHalStatus
2815csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2816 tANI_BOOLEAN bEnable )
2817{
2818 eHalStatus status = eHAL_STATUS_FAILURE;
2819 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2820 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002821 if (!pSession)
2822 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002823 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 return (status);
2825 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 if (pSession->pConnectBssDesc)
2827 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302828 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002829 }
2830 else
2831 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002832 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002833 return (status);
2834 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002835 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2836 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002837 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2838 return (status);
2839}
Jeff Johnson295189b2012-06-20 16:38:30 -07002840eHalStatus
2841csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2842 VOS_MODULE_ID modId, void *pUsrContext,
2843 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2844{
2845 eHalStatus status = eHAL_STATUS_SUCCESS;
2846 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2847 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002848 if (!pSession)
2849 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002850 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 return (status);
2852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 if(pSession->pConnectBssDesc)
2854 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302855 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 }
2857 else
2858 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002859 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 return (status);
2861 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002862 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2863 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002864 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2865 return (status);
2866}
Jeff Johnson295189b2012-06-20 16:38:30 -07002867eHalStatus
2868csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2869 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2870{
2871 eHalStatus status = eHAL_STATUS_SUCCESS;
2872 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2873 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2874
2875 if (!pSession)
2876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002877 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 return (status);
2879 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002880 if(pSession->pConnectBssDesc)
2881 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302882 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 }
2884 else
2885 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002886 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 return (status);
2888 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002889 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2890 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002891
2892 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2893
2894 return (status);
2895}
Jeff Johnson295189b2012-06-20 16:38:30 -07002896eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2897{
2898 eHalStatus status = eHAL_STATUS_SUCCESS;
2899 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2900 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002901
2902 if (!pSession)
2903 {
2904 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2905 return eHAL_STATUS_FAILURE;
2906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002907
2908 if(pSession->pConnectBssDesc)
2909 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302910 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002912 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2913 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2915
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302916 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05302917 if(HAL_STATUS_SUCCESS(status))
2918 {
2919 csrRoamLinkDown(pMac, sessionId);
2920 }
2921 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002922 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302923 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2924 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002925 }
2926
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 return (status);
2928}
2929
Jeff Johnson295189b2012-06-20 16:38:30 -07002930eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2931{
2932 eHalStatus status = eHAL_STATUS_SUCCESS;
2933 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2934 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002935
2936 if(!pSession)
2937 {
2938 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2939 return eHAL_STATUS_FAILURE;
2940 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002941
2942 // If no BSS description was found in this connection (happens with start IBSS), then
2943 // nix the BSS description that we keep around for the connected BSS) and get out...
2944 if(NULL == pBssDesc)
2945 {
2946 csrFreeConnectBssDesc(pMac, sessionId);
2947 }
2948 else
2949 {
2950 size = pBssDesc->length + sizeof( pBssDesc->length );
2951 if(NULL != pSession->pConnectBssDesc)
2952 {
2953 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2954 {
2955 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2956 csrFreeConnectBssDesc(pMac, sessionId);
2957 }
2958 }
2959 if(NULL == pSession->pConnectBssDesc)
2960 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302961 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002962 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302963 if (NULL == pSession->pConnectBssDesc)
2964 status = eHAL_STATUS_FAILURE;
2965 else
2966 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 return (status);
2969}
2970
Jeff Johnson295189b2012-06-20 16:38:30 -07002971eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2972 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2973 tDot11fBeaconIEs *pIes)
2974{
2975 eHalStatus status = eHAL_STATUS_SUCCESS;
2976 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002977 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302978 if (pIes == NULL)
2979 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002980
Jeff Johnson295189b2012-06-20 16:38:30 -07002981 do
2982 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302983 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2984 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 //get qos
2986 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2987 //get SSID
2988 if(pIes->SSID.present)
2989 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302990 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002991 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2992 }
2993 else
2994 pBssConfig->SSID.length = 0;
2995 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2996 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002997 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 //Return failed if profile doesn't have an SSID either.
2999 if(pProfile->SSIDs.numOfSSIDs == 0)
3000 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003001 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07003002 status = eHAL_STATUS_FAILURE;
3003 break;
3004 }
3005 }
3006 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
3007 {
3008 pBssConfig->eBand = eCSR_BAND_5G;
3009 }
3010 else
3011 {
3012 pBssConfig->eBand = eCSR_BAND_24;
3013 }
3014 //phymode
3015 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
3016 {
3017 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
3018 }
3019 else
3020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003021 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003022 //force it
3023 if(eCSR_BAND_24 == pBssConfig->eBand)
3024 {
3025 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3026 }
3027 else
3028 {
3029 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3030 }
3031 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 //Qos
3033 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3034 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
3035 {
3036 //Joining BSS is not 11n capable and WMM is disabled on client.
3037 //Disable QoS and WMM
3038 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3039 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303040
3041 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05303042 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303043 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
3044 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
3045 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
3046 {
3047 //Joining BSS is 11n capable and WMM is disabled on AP.
3048 //Assume all HT AP's are QOS AP's and enable WMM
3049 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3050 }
3051
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 //auth type
3053 switch( pProfile->negotiatedAuthType )
3054 {
3055 default:
3056 case eCSR_AUTH_TYPE_WPA:
3057 case eCSR_AUTH_TYPE_WPA_PSK:
3058 case eCSR_AUTH_TYPE_WPA_NONE:
3059 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3060 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3061 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003062 case eCSR_AUTH_TYPE_SHARED_KEY:
3063 pBssConfig->authType = eSIR_SHARED_KEY;
3064 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 case eCSR_AUTH_TYPE_AUTOSWITCH:
3066 pBssConfig->authType = eSIR_AUTO_SWITCH;
3067 break;
3068 }
3069 //short slot time
3070 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3071 {
3072 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3073 }
3074 else
3075 {
3076 pBssConfig->uShortSlotTime = 0;
3077 }
3078 if(pBssConfig->BssCap.ibss)
3079 {
3080 //We don't support 11h on IBSS
3081 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3082 }
3083 else
3084 {
3085 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3086 }
3087 //power constraint
3088 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3089 //heartbeat
3090 if ( CSR_IS_11A_BSS( pBssDesc ) )
3091 {
3092 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3093 }
3094 else
3095 {
3096 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3097 }
3098 //Join timeout
3099 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07003100 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 if ( pBssDesc->beaconInterval )
3102 {
3103 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07003104 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 }
3106 else
3107 {
3108 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3109 }
3110 //validate CB
3111 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sandeep Puligilla60342762014-01-30 21:05:37 +05303112
Jeff Johnson295189b2012-06-20 16:38:30 -07003113 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 return (status);
3115}
3116
Jeff Johnson295189b2012-06-20 16:38:30 -07003117static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3118 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3119{
3120 eHalStatus status = eHAL_STATUS_SUCCESS;
3121 tANI_U8 operationChannel = 0;
3122 tANI_U8 qAPisEnabled = FALSE;
3123 //SSID
3124 pBssConfig->SSID.length = 0;
3125 if(pProfile->SSIDs.numOfSSIDs)
3126 {
3127 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303128 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3129 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 }
3131 else
3132 {
3133 //SSID must present
3134 return eHAL_STATUS_FAILURE;
3135 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 //Settomg up the capabilities
3137 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3138 {
3139 pBssConfig->BssCap.ibss = 1;
3140 }
3141 else
3142 {
3143 pBssConfig->BssCap.ess = 1;
3144 }
3145 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3146 {
3147 pBssConfig->BssCap.privacy = 1;
3148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 pBssConfig->eBand = pMac->roam.configParam.eBand;
3150 //phymode
3151 if(pProfile->ChannelInfo.ChannelList)
3152 {
3153 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003155 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3156 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 //QOS
3158 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 if ( pBssConfig->BssCap.ess == 1 )
3160 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 /*For Softap case enable WMM*/
3162 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3163 qAPisEnabled = TRUE;
3164 }
3165 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003166 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3167 qAPisEnabled = TRUE;
3168 } else {
3169 qAPisEnabled = FALSE;
3170 }
3171 } else {
3172 qAPisEnabled = TRUE;
3173 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003174 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3175 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3176 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3177 )
3178 {
3179 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3180 } else {
3181 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3182 }
3183
3184 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003185 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 {
3187 default:
3188 case eCSR_AUTH_TYPE_WPA:
3189 case eCSR_AUTH_TYPE_WPA_PSK:
3190 case eCSR_AUTH_TYPE_WPA_NONE:
3191 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3192 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3193 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 case eCSR_AUTH_TYPE_SHARED_KEY:
3195 pBssConfig->authType = eSIR_SHARED_KEY;
3196 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 case eCSR_AUTH_TYPE_AUTOSWITCH:
3198 pBssConfig->authType = eSIR_AUTO_SWITCH;
3199 break;
3200 }
3201 //short slot time
3202 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3203 {
3204 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3205 }
3206 else
3207 {
3208 pBssConfig->uShortSlotTime = 0;
3209 }
3210 //power constraint. We don't support 11h on IBSS
3211 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3212 pBssConfig->uPowerLimit = 0;
3213 //heartbeat
3214 if ( eCSR_BAND_5G == pBssConfig->eBand )
3215 {
3216 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3217 }
3218 else
3219 {
3220 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3221 }
3222 //Join timeout
3223 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003224
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 return (status);
3226}
Jeff Johnson295189b2012-06-20 16:38:30 -07003227static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3228{
3229 eHalStatus status = eHAL_STATUS_FAILURE;
3230 tDot11fBeaconIEs *pIes = NULL;
3231
3232 do
3233 {
3234 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3235 {
3236 //err msg
3237 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003238 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 break;
3240 }
3241 //check if the AP is QAP & it supports APSD
3242 if( CSR_IS_QOS_BSS(pIes) )
3243 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303244 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003245 }
3246 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303247
3248 if (NULL != pIes)
3249 {
3250 vos_mem_free(pIes);
3251 }
3252
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 return status;
3254}
3255
Jeff Johnson295189b2012-06-20 16:38:30 -07003256void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3257{
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3259 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3260 // See !!Note: below in this function...
3261 tANI_U32 PrivacyEnabled = 0;
3262 tANI_U32 RsnEnabled = 0;
3263 tANI_U32 WepDefaultKeyId = 0;
3264 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3265 tANI_U32 Key0Length = 0;
3266 tANI_U32 Key1Length = 0;
3267 tANI_U32 Key2Length = 0;
3268 tANI_U32 Key3Length = 0;
3269
3270 // Reserve for the biggest key
3271 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3272 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3273 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3274 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3275
3276 switch ( pProfile->negotiatedUCEncryptionType )
3277 {
3278 case eCSR_ENCRYPT_TYPE_NONE:
3279
3280 // for NO encryption, turn off Privacy and Rsn.
3281 PrivacyEnabled = 0;
3282 RsnEnabled = 0;
3283
3284 // WEP key length and Wep Default Key ID don't matter in this case....
3285
3286 // clear out the WEP keys that may be hanging around.
3287 Key0Length = 0;
3288 Key1Length = 0;
3289 Key2Length = 0;
3290 Key3Length = 0;
3291
3292 break;
3293
3294 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303295 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003296
3297 // Privacy is ON. NO RSN for Wep40 static key.
3298 PrivacyEnabled = 1;
3299 RsnEnabled = 0;
3300
3301 // Set the Wep default key ID.
3302 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 // Wep key size if 5 bytes (40 bits).
3304 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3305
3306 // set encryption keys in the CFG database or clear those that are not present in this profile.
3307 if ( pProfile->Keys.KeyLength[0] )
3308 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303309 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3310 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3312 }
3313 else
3314 {
3315 Key0Length = 0;
3316 }
3317
3318 if ( pProfile->Keys.KeyLength[1] )
3319 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303320 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3321 WNI_CFG_WEP_KEY_LENGTH_5);
3322 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 }
3324 else
3325 {
3326 Key1Length = 0;
3327 }
3328
3329 if ( pProfile->Keys.KeyLength[2] )
3330 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303331 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3332 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3334 }
3335 else
3336 {
3337 Key2Length = 0;
3338 }
3339
3340 if ( pProfile->Keys.KeyLength[3] )
3341 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303342 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3343 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3345 }
3346 else
3347 {
3348 Key3Length = 0;
3349 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003350 break;
3351
3352 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303353 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003354
3355 // Privacy is ON. NO RSN for Wep40 static key.
3356 PrivacyEnabled = 1;
3357 RsnEnabled = 0;
3358
3359 // Set the Wep default key ID.
3360 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3361
3362 // Wep key size if 13 bytes (104 bits).
3363 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3364
3365 // set encryption keys in the CFG database or clear those that are not present in this profile.
3366 if ( pProfile->Keys.KeyLength[0] )
3367 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303368 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3369 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3371 }
3372 else
3373 {
3374 Key0Length = 0;
3375 }
3376
3377 if ( pProfile->Keys.KeyLength[1] )
3378 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303379 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3380 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3382 }
3383 else
3384 {
3385 Key1Length = 0;
3386 }
3387
3388 if ( pProfile->Keys.KeyLength[2] )
3389 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303390 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3391 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3393 }
3394 else
3395 {
3396 Key2Length = 0;
3397 }
3398
3399 if ( pProfile->Keys.KeyLength[3] )
3400 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303401 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3402 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003403 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3404 }
3405 else
3406 {
3407 Key3Length = 0;
3408 }
3409
3410 break;
3411
Jeff Johnson295189b2012-06-20 16:38:30 -07003412 case eCSR_ENCRYPT_TYPE_TKIP:
3413 case eCSR_ENCRYPT_TYPE_AES:
3414#ifdef FEATURE_WLAN_WAPI
3415 case eCSR_ENCRYPT_TYPE_WPI:
3416#endif /* FEATURE_WLAN_WAPI */
3417 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3418 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3419 PrivacyEnabled = (0 != fPrivacy);
3420
3421 // turn on RSN enabled for WPA associations
3422 RsnEnabled = 1;
3423
3424 // WEP key length and Wep Default Key ID don't matter in this case....
3425
3426 // clear out the static WEP keys that may be hanging around.
3427 Key0Length = 0;
3428 Key1Length = 0;
3429 Key2Length = 0;
3430 Key3Length = 0;
3431
3432 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 default:
3434 PrivacyEnabled = 0;
3435 RsnEnabled = 0;
3436 break;
3437 }
3438
3439 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3440 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3441 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3442 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3443 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3444 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3445 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3446 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3447}
3448
Jeff Johnson295189b2012-06-20 16:38:30 -07003449static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3450{
3451 tANI_U32 len = 0;
3452 if(pSSID->length <= WNI_CFG_SSID_LEN)
3453 {
3454 len = pSSID->length;
3455 }
3456 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3457}
3458
Jeff Johnson295189b2012-06-20 16:38:30 -07003459eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3460{
3461 eHalStatus status = eHAL_STATUS_SUCCESS;
3462 tANI_U32 QoSEnabled;
3463 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 // set the CFG enable/disable variables based on the qosType being configured...
3465 switch( qosType )
3466 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3468 QoSEnabled = FALSE;
3469 WmeEnabled = TRUE;
3470 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003471 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3472 QoSEnabled = FALSE;
3473 WmeEnabled = TRUE;
3474 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3476 QoSEnabled = FALSE;
3477 WmeEnabled = TRUE;
3478 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3480 QoSEnabled = TRUE;
3481 WmeEnabled = FALSE;
3482 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 case eCSR_MEDIUM_ACCESS_11e_HCF:
3484 QoSEnabled = TRUE;
3485 WmeEnabled = FALSE;
3486 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003487 default:
3488 case eCSR_MEDIUM_ACCESS_DCF:
3489 QoSEnabled = FALSE;
3490 WmeEnabled = FALSE;
3491 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003492 }
3493 //save the WMM setting for later use
3494 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303495 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003496 return (status);
3497}
Jeff Johnson295189b2012-06-20 16:38:30 -07003498static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3499 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3500{
3501 eHalStatus status = eHAL_STATUS_FAILURE;
3502 int i;
3503 eCsrCfgDot11Mode cfgDot11Mode;
3504 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303505 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3506 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003508
3509 if( NULL != pIes )
3510 {
3511 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 // Originally, we thought that for 11a networks, the 11a rates are always
3513 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3514 // appear in the Operational Rate set. Consequently, in either case, we
3515 // would blindly put the rates we support into our Operational Rate set
3516 // (including the basic rates, which we have already verified are
3517 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003518 // However, it turns out that this is not always the case. Some AP's
3519 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3520 // too. Now, we're a little more careful:
3521 pDstRate = pOpRateSet->rate;
3522 if(pIes->SuppRates.present)
3523 {
3524 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3525 {
3526 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3527 {
3528 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003529 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 }
3531 }
3532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003533 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3534 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3535 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3536 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3537 {
3538 // If there are Extended Rates in the beacon, we will reflect those
3539 // extended rates that we support in out Extended Operational Rate
3540 // set:
3541 pDstRate = pExRateSet->rate;
3542 if(pIes->ExtSuppRates.present)
3543 {
3544 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3545 {
3546 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3547 {
3548 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3549 pExRateSet->numRates++;
3550 }
3551 }
3552 }
3553 }
3554 }//Parsing BSSDesc
3555 else
3556 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003557 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 }
3559 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3560 return status;
3561}
3562
3563static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3564 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3565{
3566 int i;
3567 tANI_U8 *pDstRate;
3568 eCsrCfgDot11Mode cfgDot11Mode;
3569 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3570 tANI_U32 OperationalRatesLength = 0;
3571 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3572 tANI_U32 ExtendedOperationalRatesLength = 0;
3573 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3574 tANI_U32 ProprietaryOperationalRatesLength = 0;
3575 tANI_U32 PropRatesEnable = 0;
3576 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3577 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003579 if( NULL != pIes )
3580 {
3581 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 // Originally, we thought that for 11a networks, the 11a rates are always
3583 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3584 // appear in the Operational Rate set. Consequently, in either case, we
3585 // would blindly put the rates we support into our Operational Rate set
3586 // (including the basic rates, which we have already verified are
3587 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003588 // However, it turns out that this is not always the case. Some AP's
3589 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3590 // too. Now, we're a little more careful:
3591 pDstRate = OperationalRates;
3592 if(pIes->SuppRates.present)
3593 {
3594 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3595 {
3596 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3597 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3598 {
3599 *pDstRate++ = pIes->SuppRates.rates[ i ];
3600 OperationalRatesLength++;
3601 }
3602 }
3603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3605 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3606 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3607 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3608 {
3609 // If there are Extended Rates in the beacon, we will reflect those
3610 // extended rates that we support in out Extended Operational Rate
3611 // set:
3612 pDstRate = ExtendedOperationalRates;
3613 if(pIes->ExtSuppRates.present)
3614 {
3615 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3616 {
3617 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3618 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3619 {
3620 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3621 ExtendedOperationalRatesLength++;
3622 }
3623 }
3624 }
3625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 // Enable proprietary MAC features if peer node is Airgo node and STA
3627 // user wants to use them
3628 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3629 {
3630 PropRatesEnable = 1;
3631 }
3632 else
3633 {
3634 PropRatesEnable = 0;
3635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003636 // For ANI network companions, we need to populate the proprietary rate
3637 // set with any proprietary rates we found in the beacon, only if user
3638 // allows them...
3639 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3640 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3641 {
3642 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3643 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3644 {
3645 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3646 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303647 vos_mem_copy(ProprietaryOperationalRates,
3648 pIes->Airgo.PropSuppRates.rates,
3649 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 }
3651 else {
3652 // No proprietary modes...
3653 ProprietaryOperationalRatesLength = 0;
3654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 /* Get MCS Rate */
3656 pDstRate = MCSRateIdxSet;
3657 if ( pIes->HTCaps.present )
3658 {
3659 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3660 {
3661 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3662 {
3663 MCSRateLength++;
3664 *pDstRate++ = i;
3665 }
3666 }
3667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003668 // Set the operational rate set CFG variables...
3669 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3670 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3671 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3672 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3673 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3674 ProprietaryOperationalRates,
3675 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3676 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3677 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3678 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3679 }//Parsing BSSDesc
3680 else
3681 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003682 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 }
3684}
3685
Jeff Johnson295189b2012-06-20 16:38:30 -07003686static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3687 tCsrRoamProfile *pProfile )
3688{
3689 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3690 { 8,
3691 { SIR_MAC_RATE_6,
3692 SIR_MAC_RATE_9,
3693 SIR_MAC_RATE_12,
3694 SIR_MAC_RATE_18,
3695 SIR_MAC_RATE_24,
3696 SIR_MAC_RATE_36,
3697 SIR_MAC_RATE_48,
3698 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003699 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3700 { 4,
3701 { SIR_MAC_RATE_1,
3702 SIR_MAC_RATE_2,
3703 SIR_MAC_RATE_5_5,
3704 SIR_MAC_RATE_11 } } };
3705
3706
3707 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3708 { SIR_MAC_RATE_72,
3709 SIR_MAC_RATE_96,
3710 SIR_MAC_RATE_108 } };
3711 eCsrCfgDot11Mode cfgDot11Mode;
3712 eCsrBand eBand;
3713 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3714 tANI_U32 OperationalRatesLength = 0;
3715 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3716 tANI_U32 ExtendedOperationalRatesLength = 0;
3717 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3718 tANI_U32 ProprietaryOperationalRatesLength = 0;
3719 tANI_U32 PropRatesEnable = 0;
3720 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003721 if(pProfile->ChannelInfo.ChannelList)
3722 {
3723 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003725 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3727 // networks, the 11b rates appear in the Operational Rate set. In either case,
3728 // we can blindly put the rates we support into our Operational Rate set
3729 // (including the basic rates, which we have already verified are supported
3730 // earlier in the roaming decision).
3731 if ( eCSR_BAND_5G == eBand )
3732 {
3733 // 11a rates into the Operational Rate Set.
3734 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3735 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303736 vos_mem_copy(OperationalRates,
3737 DefaultSupportedRates11a.supportedRateSet.rate,
3738 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003739
3740 // Nothing in the Extended rate set.
3741 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 // populate proprietary rates if user allows them
3743 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3744 {
3745 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3746 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303747 vos_mem_copy(ProprietaryOperationalRates,
3748 DefaultSupportedPropRates.propRate,
3749 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 }
3751 else
3752 {
3753 // No proprietary modes
3754 ProprietaryOperationalRatesLength = 0;
3755 }
3756 }
3757 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3758 {
3759 // 11b rates into the Operational Rate Set.
3760 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3761 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303762 vos_mem_copy(OperationalRates,
3763 DefaultSupportedRates11b.supportedRateSet.rate,
3764 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 // Nothing in the Extended rate set.
3766 ExtendedOperationalRatesLength = 0;
3767 // No proprietary modes
3768 ProprietaryOperationalRatesLength = 0;
3769 }
3770 else
3771 {
3772 // 11G
3773
3774 // 11b rates into the Operational Rate Set.
3775 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3776 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303777 vos_mem_copy(OperationalRates,
3778 DefaultSupportedRates11b.supportedRateSet.rate,
3779 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003780
3781 // 11a rates go in the Extended rate set.
3782 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3783 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303784 vos_mem_copy(ExtendedOperationalRates,
3785 DefaultSupportedRates11a.supportedRateSet.rate,
3786 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003787
3788 // populate proprietary rates if user allows them
3789 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3790 {
3791 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3792 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303793 vos_mem_copy(ProprietaryOperationalRates,
3794 DefaultSupportedPropRates.propRate,
3795 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 }
3797 else
3798 {
3799 // No proprietary modes
3800 ProprietaryOperationalRatesLength = 0;
3801 }
3802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3804 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3805 {
3806 PropRatesEnable = 1;
3807 }
3808 else
3809 {
3810 PropRatesEnable = 0;
3811 }
3812
3813 // Set the operational rate set CFG variables...
3814 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3815 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3816 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3817 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3818 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3819 ProprietaryOperationalRates,
3820 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3821 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003822}
Jeff Johnson295189b2012-06-20 16:38:30 -07003823void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3824{
3825 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003826
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3828 tANI_U32 sessionId;
3829 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003830 if(NULL == pEntry)
3831 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003832 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003833 return;
3834 }
3835 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3836 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05303837 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
3838 " current state : %d sub state : %d "),
3839 result, pMac->roam.curState[sessionId],
3840 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3842 {
3843 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3844 }
3845}
3846
Jeff Johnson295189b2012-06-20 16:38:30 -07003847//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3848tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3849{
3850 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3851 {
3852 return (WNI_CFG_PHY_MODE_11B);
3853 }
3854 else
3855 {
3856 if(eCSR_BAND_24 == band)
3857 return (WNI_CFG_PHY_MODE_11G);
3858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003859 return (WNI_CFG_PHY_MODE_11A);
3860}
Jeff Johnson295189b2012-06-20 16:38:30 -07003861
Jeff Johnsone7245742012-09-05 17:12:55 -07003862
3863#ifdef WLAN_FEATURE_11AC
3864ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3865{
3866 switch ( aniCBMode )
3867 {
3868 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3869 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3870 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3871 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3872 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3873 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3874 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3875 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3876 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003877 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003878 return PHY_SINGLE_CHANNEL_CENTERED;
3879 }
3880}
3881#endif
3882
Jeff Johnson295189b2012-06-20 16:38:30 -07003883//pIes may be NULL
3884eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3885 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303886 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003887{
3888 eHalStatus status = eHAL_STATUS_SUCCESS;
3889 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3890 tANI_U8 channel = 0;
3891 //Make sure we have the domain info for the BSS we try to connect to.
3892 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303893 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05303895 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 {
3897 //Make sure the 11d info from this BSSDesc can be applied
3898 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303899 if (VOS_TRUE == resetCountry)
3900 {
3901 csrApplyCountryInformation(pMac, FALSE);
3902 }
3903 else
3904 {
3905 csrApplyCountryInformation(pMac, TRUE);
3906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 }
Kiran4a17ebe2013-01-31 10:43:43 -08003908 if ((csrIs11dSupported (pMac)) && pIes)
3909 {
3910 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003911 {
Kiran4a17ebe2013-01-31 10:43:43 -08003912 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003913 }
3914 else
3915 {
3916 //Let's also update the below to make sure we don't update CC while
3917 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303918 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003919 pBssDesc->bssId, sizeof(tSirMacAddr));
3920 }
Kiran4a17ebe2013-01-31 10:43:43 -08003921 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003922 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 //Qos
3924 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3925 //SSID
3926 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3927 //fragment threshold
3928 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3929 //RTS threshold
3930 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3931
3932 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 //Auth type
3934 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3935 //encryption type
3936 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3937 //short slot time
3938 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 //11d
3940 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3941 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3942 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003943 /*//11h
3944 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3945 */
3946 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3947 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003948
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003949 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 {
3951 channel = pProfile->operationChannel;
3952 }
3953 else
3954 {
3955 if(pBssDesc)
3956 {
3957 channel = pBssDesc->channelId;
3958 }
3959 }
3960 if(0 != channel)
3961 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05303962 if(CSR_IS_CHANNEL_24GHZ(channel) &&
3963 !pMac->roam.configParam.channelBondingMode24GHz &&
3964 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
3965 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05303967 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3968 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
3969 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 }
3971 else
3972 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003973 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 }
3975 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003976#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003977 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3978 // in function csrConvertCBIniValueToPhyCBState()
3979 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3980 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003981 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003982 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003983 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003984 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05303985 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003986 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003987 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003988 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003989 }
3990 else
3991#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3993 //Rate
3994 //Fixed Rate
3995 if(pBssDesc)
3996 {
3997 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3998 }
3999 else
4000 {
4001 csrSetCfgRateSetFromProfile(pMac, pProfile);
4002 }
4003 //Make this the last CFG to set. The callback will trigger a join_req
4004 //Join time out
4005 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
4006
4007 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 return (status);
4009}
4010
Jeff Johnson295189b2012-06-20 16:38:30 -07004011eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4012 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
4013{
4014 eHalStatus status;
4015 tBssConfigParam *pBssConfig;
4016 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004017
4018 if(!pSession)
4019 {
4020 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4021 return eHAL_STATUS_FAILURE;
4022 }
4023
Kiet Lam64c1b492013-07-12 13:56:44 +05304024 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4025 if ( NULL == pBssConfig )
4026 status = eHAL_STATUS_FAILURE;
4027 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304029 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4031 if(HAL_STATUS_SUCCESS(status))
4032 {
4033 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004034 /* This will allow to pass cbMode during join req */
4035 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004036 //For IBSS, we need to prepare some more information
4037 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004038 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 )
4040 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004041 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 }
4043 // If we are in an IBSS, then stop the IBSS...
4044 ////Not worry about WDS connection for now
4045 if ( csrIsConnStateIbss( pMac, sessionId ) )
4046 {
4047 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4048 }
4049 else
4050 {
4051 // if we are in an Infrastructure association....
4052 if ( csrIsConnStateInfra( pMac, sessionId ) )
4053 {
4054 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4055 // across SSIDs (roaming to a new SSID)... //
4056 //Not worry about WDS connection for now
4057 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304058 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 {
4060 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304061 status = csrRoamIssueDisassociate( pMac, sessionId,
4062 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304064 else
4065 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004066 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4067 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304068 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304070 // Set parameters for this Bss.
4071 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4072 pBssDesc, pBssConfig,
4073 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304077 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004078 {
4079 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4080 // Nothing to stop.
4081 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304083 )
4084 {
4085 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4086 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4087 // Set parameters for this Bss.
4088 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4089 pBssDesc, pBssConfig,
4090 pIes, is11rRoamingFlag);
4091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 }
4093 }
4094 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304095 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004096 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 return (status);
4098}
4099
Jeff Johnson295189b2012-06-20 16:38:30 -07004100eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4101 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4102{
4103 eCsrJoinState eRoamState = eCsrContinueRoaming;
4104 eHalStatus status;
4105 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4106 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4107 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004108
4109 if(!pSession)
4110 {
4111 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4112 return (eCsrStopRoaming);
4113 }
4114
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 if( CSR_IS_WDS_STA( pProfile ) )
4116 {
4117 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4118 if( !HAL_STATUS_SUCCESS( status ) )
4119 {
4120 eRoamState = eCsrStopRoaming;
4121 }
4122 }
4123 else
4124 {
4125 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4126 {
4127 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4128 return (eCsrStopRoaming);
4129 }
4130 if ( csrIsInfraBssDesc( pBssDesc ) )
4131 {
4132 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4133 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4134 // have changed and handle the changes (without disturbing the current association).
4135
4136 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4137 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4138 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4139 )
4140 {
4141 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4142 // with Authenticating first. To force this, stop the current association (Disassociate) and
4143 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4144 // a new Association.
4145 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4146 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004147 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004148 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4149 {
4150 eRoamState = eCsrReassocToSelfNoCapChange;
4151 }
4152 else
4153 {
4154 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304156 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4158 if(HAL_STATUS_SUCCESS(status))
4159 {
4160 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004161 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004162 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304163 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4164 pBssDesc, &bssConfig,
4165 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 if(!HAL_STATUS_SUCCESS(status))
4167 {
4168 eRoamState = eCsrStopRoaming;
4169 }
4170 }
4171 else
4172 {
4173 eRoamState = eCsrStopRoaming;
4174 }
4175 }//same profile
4176 }
4177 else
4178 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304179 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4181 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304182 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4183 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004184 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304187 }
4188 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004189 {
4190 // 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 -07004191 // stop the existing network before attempting to join the new network...
4192 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4193 {
4194 eRoamState = eCsrStopRoaming;
4195 }
4196 }
4197 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304198 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 {
4200 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4201 {
4202 eRoamState = eCsrStopRoaming;
4203 }
4204 }
4205 if( pIesLocal && !pScanResult->pvIes )
4206 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304207 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 }
4209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 return( eRoamState );
4211}
4212
Jeff Johnson295189b2012-06-20 16:38:30 -07004213eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4214 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4215{
4216 eHalStatus status = eHAL_STATUS_SUCCESS;
4217 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304218 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 roamInfo.pBssDesc = pBssDesc;
4220 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4221 return (status);
4222}
Jeff Johnson295189b2012-06-20 16:38:30 -07004223//In case no matching BSS is found, use whatever default we can find
4224static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4225{
4226 //Need to get all negotiated types in place first
4227 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004228 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 {
4230 default:
4231 case eCSR_AUTH_TYPE_WPA:
4232 case eCSR_AUTH_TYPE_WPA_PSK:
4233 case eCSR_AUTH_TYPE_WPA_NONE:
4234 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4235 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4236 break;
4237
4238 case eCSR_AUTH_TYPE_SHARED_KEY:
4239 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4240 break;
4241
4242 case eCSR_AUTH_TYPE_AUTOSWITCH:
4243 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4244 break;
4245 }
4246 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4247 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4248 //In this case, the multicast encryption needs to follow the uncast ones.
4249 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4250 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4251}
4252
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004253
4254static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4255{
4256 switch(pCommand->u.roamCmd.roamReason)
4257 {
4258 case eCsrLostLink1:
4259 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4260 break;
4261 case eCsrLostLink2:
4262 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4263 break;
4264 case eCsrLostLink3:
4265 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4266 break;
4267 default:
4268 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4269 pCommand->u.roamCmd.roamReason);
4270 break;
4271 }
4272}
4273
Jeff Johnson295189b2012-06-20 16:38:30 -07004274static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4275{
4276 eHalStatus status;
4277 tCsrScanResult *pScanResult = NULL;
4278 eCsrJoinState eRoamState = eCsrStopRoaming;
4279 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4280 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4281 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4282#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4283 v_U8_t acm_mask = 0;
4284#endif
4285 tANI_U32 sessionId = pCommand->sessionId;
4286 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4287 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4288 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004289
4290 if(!pSession)
4291 {
4292 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4293 return (eCsrStopRoaming);
4294 }
4295
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 do
4297 {
4298 // Check for Cardbus eject condition, before trying to Roam to any BSS
4299 //***if( !balIsCardPresent(pAdapter) ) break;
4300
Kiet Lam64c1b492013-07-12 13:56:44 +05304301 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304302 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004303 if(NULL != pBSSList)
4304 {
4305 // When handling AP's capability change, continue to associate to
4306 // same BSS and make sure pRoamBssEntry is not Null.
4307 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4308 {
4309 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4310 {
4311 //Try the first BSS
4312 pCommand->u.roamCmd.pLastRoamBss = NULL;
4313 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4314 }
4315 else
4316 {
4317 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4318 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4319 {
4320 //Done with all the BSSs
4321 //In this case, will tell HDD the completion
4322 break;
4323 }
4324 else
4325 {
4326 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304327 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004328 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4329 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4330 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4331 pRoamInfo = &roamInfo;
4332 }
4333 }
4334 while(pCommand->u.roamCmd.pRoamBssEntry)
4335 {
4336 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004337 /*If concurrency enabled take the concurrent connected channel first. */
4338 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304339 if (vos_concurrent_open_sessions_running() &&
4340 !csrIsValidMcConcurrentSession(pMac, sessionId,
4341 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 {
4343 concurrentChannel =
4344 csrGetConcurrentOperationChannel(pMac);
4345 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004346 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004347 if ((concurrentChannel) &&
4348 (concurrentChannel ==
4349 pScanResult->Result.BssDescriptor.channelId))
4350 {
4351 //make this 0 because we do not want the
4352 //below check to pass as we don't want to
4353 //connect on other channel
4354 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4355 FL("Concurrent channel match =%d"),
4356 concurrentChannel);
4357 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 }
4359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004360
4361 if (!concurrentChannel)
4362 {
4363
4364 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4365 sessionId, &pScanResult->Result.BssDescriptor,
4366 pCommand->u.roamCmd.roamId)))
4367 {
4368 //Ok to roam this
4369 break;
4370 }
4371 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004372 else
4373 {
4374 eRoamState = eCsrStopRoamingDueToConcurrency;
4375 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4377 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4378 {
4379 //Done with all the BSSs
4380 fDone = eANI_BOOLEAN_TRUE;
4381 break;
4382 }
4383 }
4384 if(fDone)
4385 {
4386 break;
4387 }
4388 }
4389 }
4390 //We have something to roam, tell HDD when it is infra.
4391 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4392 //For WDS, the indication is eCSR_ROAM_WDS_IND
4393 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4394 {
4395 if(pRoamInfo)
4396 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004397 if(pSession->bRefAssocStartCnt)
4398 {
4399 pSession->bRefAssocStartCnt--;
4400 //Complete the last association attemp because a new one is about to be tried
4401 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4402 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004404 }
4405 }
4406 /* If the roaming has stopped, not to continue the roaming command*/
4407 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4408 {
4409 //No need to complete roaming here as it already completes
4410 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4411 pCommand->u.roamCmd.roamReason);
4412 eRoamState = eCsrStopRoaming;
4413 csrSetAbortRoamingCommand(pMac, pCommand);
4414 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004415 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304416 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004417 if(pScanResult)
4418 {
4419 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4421 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004422 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004423 fDone = eANI_BOOLEAN_TRUE;
4424 eRoamState = eCsrStopRoaming;
4425 break;
4426 }
4427 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4428 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4429 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4430 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4431 CSR_IS_QOS_BSS(pIesLocal) &&
4432 CSR_IS_UAPSD_BSS(pIesLocal) )
4433 {
4434#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4436 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004437#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 }
4439 else
4440 {
4441 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4442 }
4443 if( pIesLocal && !pScanResult->Result.pvIes)
4444 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304445 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 }
4447 }
4448 else
4449 {
4450 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4451 }
4452 roamInfo.pProfile = pProfile;
4453 pSession->bRefAssocStartCnt++;
4454 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4455 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004457 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4458 {
4459 // If this is a start IBSS profile, then we need to start the IBSS.
4460 if ( CSR_IS_START_IBSS(pProfile) )
4461 {
4462 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 // Attempt to start this IBSS...
4464 csrRoamAssignDefaultParam( pMac, pCommand );
4465 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4466 if(HAL_STATUS_SUCCESS(status))
4467 {
4468 if ( fSameIbss )
4469 {
4470 eRoamState = eCsrStartIbssSameIbss;
4471 }
4472 else
4473 {
4474 eRoamState = eCsrContinueRoaming;
4475 }
4476 }
4477 else
4478 {
4479 //it somehow fail need to stop
4480 eRoamState = eCsrStopRoaming;
4481 }
4482 break;
4483 }
4484 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 )
4487 {
4488 // Attempt to start this WDS...
4489 csrRoamAssignDefaultParam( pMac, pCommand );
4490 /* For AP WDS, we dont have any BSSDescription */
4491 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4492 if(HAL_STATUS_SUCCESS(status))
4493 {
4494 eRoamState = eCsrContinueRoaming;
4495 }
4496 else
4497 {
4498 //it somehow fail need to stop
4499 eRoamState = eCsrStopRoaming;
4500 }
4501 }
4502 else
4503 {
4504 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004505 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 eRoamState = eCsrStopRoaming;
4507 break;
4508 }
4509 }
4510 else //We have BSS
4511 {
4512 //Need to assign these value because they are used in csrIsSameProfile
4513 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004514 /* The OSEN IE doesn't provide the cipher suite.
4515 * Therefore set to constant value of AES */
4516 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4517 {
4518 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4519 eCSR_ENCRYPT_TYPE_AES;
4520 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4521 eCSR_ENCRYPT_TYPE_AES;
4522 }
4523 else
4524 {
4525 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4526 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4527 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4528 pScanResult->mcEncryptionType;
4529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4531 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4532 {
4533 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4534 {
4535 eRoamState = eCsrStartIbssSameIbss;
4536 break;
4537 }
4538 }
4539 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4540 {
4541 //trying to connect to the one already connected
4542 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4543 eRoamState = eCsrReassocToSelfNoCapChange;
4544 break;
4545 }
4546 // Attempt to Join this Bss...
4547 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4548 break;
4549 }
4550
4551 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4553 {
4554 //Need to indicate association_completion if association_start has been done
4555 if(pSession->bRefAssocStartCnt > 0)
4556 {
4557 pSession->bRefAssocStartCnt--;
4558 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004559 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4561 eCSR_ROAM_ASSOCIATION_COMPLETION,
4562 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4563 }
4564 }
4565
4566 return( eRoamState );
4567}
4568
Jeff Johnson295189b2012-06-20 16:38:30 -07004569static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4570{
4571 eHalStatus status = eHAL_STATUS_SUCCESS;
4572 eCsrJoinState RoamState;
4573 tANI_U32 sessionId = pCommand->sessionId;
4574
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 //***if( hddIsRadioStateOn( pAdapter ) )
4576 {
4577 // Attept to join a Bss...
4578 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004579
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004581 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 {
4583 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 // and if connected in Infrastructure mode...
4585 if ( csrIsConnStateInfra(pMac, sessionId) )
4586 {
4587 //... then we need to issue a disassociation
4588 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4589 if(!HAL_STATUS_SUCCESS(status))
4590 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004591 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 //roam command is completed by caller in the failed case
4593 fComplete = eANI_BOOLEAN_TRUE;
4594 }
4595 }
4596 else if( csrIsConnStateIbss(pMac, sessionId) )
4597 {
4598 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4599 if(!HAL_STATUS_SUCCESS(status))
4600 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004601 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 //roam command is completed by caller in the failed case
4603 fComplete = eANI_BOOLEAN_TRUE;
4604 }
4605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4607 {
4608 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4609 if(!HAL_STATUS_SUCCESS(status))
4610 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004611 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 //roam command is completed by caller in the failed case
4613 fComplete = eANI_BOOLEAN_TRUE;
4614 }
4615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 else
4617 {
4618 fComplete = eANI_BOOLEAN_TRUE;
4619 }
4620 if(fComplete)
4621 {
4622 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004623 if(eCsrStopRoamingDueToConcurrency == RoamState)
4624 {
4625 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4626 }
4627 else
4628 {
4629 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 }
4632 }
4633 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4634 {
4635 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4636 }
4637 else if ( eCsrStartIbssSameIbss == RoamState )
4638 {
4639 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4640 }
4641 }//hddIsRadioStateOn
4642
4643 return status;
4644}
Jeff Johnson295189b2012-06-20 16:38:30 -07004645eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4646{
4647 tANI_U32 sessionId;
4648 tCsrRoamSession *pSession;
4649 tCsrScanResult *pScanResult = NULL;
4650 tSirBssDescription *pBssDesc = NULL;
4651 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 sessionId = pCommand->sessionId;
4653 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004654
4655 if(!pSession)
4656 {
4657 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4658 return eHAL_STATUS_FAILURE;
4659 }
4660
Jeff Johnson295189b2012-06-20 16:38:30 -07004661 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4662 {
4663 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004664 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004665 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4666 return eHAL_STATUS_FAILURE;
4667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 if (pCommand->u.roamCmd.pRoamBssEntry)
4669 {
4670 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4671 pBssDesc = &pScanResult->Result.BssDescriptor;
4672 }
4673 else
4674 {
4675 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004676 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4678 return eHAL_STATUS_FAILURE;
4679 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4681 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4682 return status;
4683}
4684
Jeff Johnson295189b2012-06-20 16:38:30 -07004685eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4686{
4687 eHalStatus status = eHAL_STATUS_SUCCESS;
4688 tCsrRoamInfo roamInfo;
4689 tANI_U32 sessionId = pCommand->sessionId;
4690 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004691
4692 if(!pSession)
4693 {
4694 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4695 return eHAL_STATUS_FAILURE;
4696 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05304697
Jeff Johnson295189b2012-06-20 16:38:30 -07004698 switch ( pCommand->u.roamCmd.roamReason )
4699 {
4700 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004702 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004703 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004704 case eCsrSmeIssuedDisassocForHandoff:
4705 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4706#if 0 // TODO : Confirm this change
4707 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4708#else
4709 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4710#endif
4711
4712 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004713 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004715 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004716 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004718 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004719 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004720 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 case eCsrHddIssuedReassocToSameAP:
4722 case eCsrSmeIssuedReassocToSameAP:
4723 {
4724 tDot11fBeaconIEs *pIes = NULL;
4725
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 if( pSession->pConnectBssDesc )
4727 {
4728 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4729 if(!HAL_STATUS_SUCCESS(status) )
4730 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004731 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004732 }
4733 else
4734 {
4735 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4736 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4737 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004738 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4739 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4740 pSession->bRefAssocStartCnt++;
4741 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4742 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4743
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004744 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004745 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4746 &pCommand->u.roamCmd.roamProfile );
4747 if(!HAL_STATUS_SUCCESS(status))
4748 {
4749 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004750 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004751 }
4752
Kiet Lam64c1b492013-07-12 13:56:44 +05304753 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 pIes = NULL;
4755 }
4756 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05304757 else
4758 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 break;
4760 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004762 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4764 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4765 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004767 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4769 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004770
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 case eCsrStopBss:
4772 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4773 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4774 break;
4775
4776 case eCsrForcedDisassocSta:
4777 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4778 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4779 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4780 pCommand->u.roamCmd.reason);
4781 break;
4782
4783 case eCsrForcedDeauthSta:
4784 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4785 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4786 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4787 pCommand->u.roamCmd.reason);
4788 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004789
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004790 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004791 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004792 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4793 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004794 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004795
4796 default:
4797 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4798
4799 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4800 {
4801 //Remember the roaming profile
4802 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304803 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4804 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304806 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004807 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4808 }
4809 }
4810
4811 //At this point, original uapsd_mask is saved in pCurRoamProfile
4812 //uapsd_mask in the pCommand may change from this point on.
4813
4814 // Attempt to roam with the new scan results (if we need to..)
4815 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004816 if(!HAL_STATUS_SUCCESS(status))
4817 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004818 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004820 break;
4821 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004822 return (status);
4823}
4824
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004825void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4826{
4827 pCommand->u.roamCmd.pLastRoamBss = NULL;
4828 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4829 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304830 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004831}
4832
Jeff Johnson295189b2012-06-20 16:38:30 -07004833void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4834{
4835 if(pCommand->u.roamCmd.fReleaseBssList)
4836 {
4837 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4838 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4839 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4840 }
4841 if(pCommand->u.roamCmd.fReleaseProfile)
4842 {
4843 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4844 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4845 }
4846 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4847 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304848 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004849}
4850
Jeff Johnson295189b2012-06-20 16:38:30 -07004851void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4852{
Kiet Lam64c1b492013-07-12 13:56:44 +05304853 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004854}
Jeff Johnson295189b2012-06-20 16:38:30 -07004855void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4856{
4857 tListElem *pEntry;
4858 tSmeCmd *pCommand;
4859 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004860 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004861 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4862 if ( pEntry )
4863 {
4864 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004865 // If the head of the queue is Active and it is a ROAM command, remove
4866 // and put this on the Free queue.
4867 if ( eSmeCommandRoam == pCommand->command )
4868 {
4869 //we need to process the result first before removing it from active list because state changes
4870 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4871 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4872 if( fReleaseCommand )
4873 {
4874 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4875 {
4876 csrReleaseCommandRoam( pMac, pCommand );
4877 }
4878 else
4879 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004880 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004881 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 }
4883 }
4884 else
4885 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004886 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004887 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004888 }
4889 }
4890 else
4891 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004892 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004893 }
4894 }
4895 else
4896 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004897 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 if( fReleaseCommand )
4900 {
4901 smeProcessPendingQueue( pMac );
4902 }
4903}
4904
Jeff Johnson295189b2012-06-20 16:38:30 -07004905void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4906{
4907 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004908 if(!pSession)
4909 {
4910 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4911 return;
4912 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304913 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4914 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 pSession->NumPmkidCandidate = 0;
4916}
Jeff Johnson295189b2012-06-20 16:38:30 -07004917#ifdef FEATURE_WLAN_WAPI
4918void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4919{
4920 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004921 if(!pSession)
4922 {
4923 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4924 return;
4925 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304926 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4927 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004928 pSession->NumBkidCandidate = 0;
4929}
4930#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004931extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4932
Jeff Johnson295189b2012-06-20 16:38:30 -07004933static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4934 tSirBssDescription *pSirBssDesc,
4935 tDot11fBeaconIEs *pIes)
4936{
4937 eHalStatus status = eHAL_STATUS_SUCCESS;
4938 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4939 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004940
4941 if(!pSession)
4942 {
4943 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4944 return eHAL_STATUS_FAILURE;
4945 }
4946
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 if((eCSR_AUTH_TYPE_WPA == authType) ||
4948 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4949 (eCSR_AUTH_TYPE_RSN == authType) ||
4950 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4951#if defined WLAN_FEATURE_VOWIFI_11R
4952 ||
4953 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4954 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4955#endif /* FEATURE_WLAN_WAPI */
4956#ifdef FEATURE_WLAN_WAPI
4957 ||
4958 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4959 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4960#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004961#ifdef WLAN_FEATURE_11W
4962 ||
Abhishek Singhae408032014-09-25 17:22:04 +05304963 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4964 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07004965#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004966 )
4967 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4969 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004970 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004971 }
4972 if( pIesLocal )
4973 {
4974 tANI_U32 nIeLen;
4975 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004976 if((eCSR_AUTH_TYPE_RSN == authType) ||
4977#if defined WLAN_FEATURE_VOWIFI_11R
4978 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4979 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4980#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004981#if defined WLAN_FEATURE_11W
4982 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05304983 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07004984#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4986 {
4987 if(pIesLocal->RSN.present)
4988 {
4989 //Calculate the actual length
4990 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4991 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4992 + 2 //akm_suite_count
4993 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4994 + 2; //reserved
4995 if( pIesLocal->RSN.pmkid_count )
4996 {
4997 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4998 }
4999 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305000 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5001 if (NULL == pSession->pWpaRsnRspIE)
5002 status = eHAL_STATUS_FAILURE;
5003 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305005 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
5007 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5008 //copy upto akm_suites
5009 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05305010 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
5011 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005012 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05305013 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
5014 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005015 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05305016 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
5017 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005018 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07005019 if( pIesLocal->RSN.pwise_cipher_suite_count )
5020 {
5021 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305022 vos_mem_copy(pIeBuf,
5023 pIesLocal->RSN.pwise_cipher_suites,
5024 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5026 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305027 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 pIeBuf += 2;
5029 if( pIesLocal->RSN.akm_suite_count )
5030 {
5031 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305032 vos_mem_copy(pIeBuf,
5033 pIesLocal->RSN.akm_suites,
5034 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005035 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
5036 }
5037 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305038 vos_mem_copy(pIeBuf,
5039 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
5040 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005041 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5042 }
5043 }
5044 }
5045 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5046 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5047 {
5048 if(pIesLocal->WPA.present)
5049 {
5050 //Calculate the actual length
5051 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5052 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5053 + 2 //auth_suite_count
5054 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5055 // The WPA capabilities follows the Auth Suite (two octects)--
5056 // this field is optional, and we always "send" zero, so just
5057 // remove it. This is consistent with our assumptions in the
5058 // frames compiler; c.f. bug 15234:
5059 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305060
5061 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5062 if ( NULL == pSession->pWpaRsnRspIE )
5063 status = eHAL_STATUS_FAILURE;
5064 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005065 {
5066 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5067 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5068 pIeBuf = pSession->pWpaRsnRspIE + 2;
5069 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305070 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005071 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305072 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5073 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005074 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305075 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5076 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005077 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5078 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5079 }
5080 }
5081 }
5082#ifdef FEATURE_WLAN_WAPI
5083 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5084 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5085 {
5086 if(pIesLocal->WAPI.present)
5087 {
5088 //Calculate the actual length
5089 nIeLen = 4 //version + akm_suite_count
5090 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5091 + 2 //pwise_cipher_suite_count
5092 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5093 + 6; //gp_cipher_suite + preauth + reserved
5094 if( pIesLocal->WAPI.bkid_count )
5095 {
5096 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5097 }
5098
5099 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305100 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5101 if ( NULL == pSession->pWapiRspIE )
5102 status = eHAL_STATUS_FAILURE;
5103 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005104 {
5105 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5106 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5107 pIeBuf = pSession->pWapiRspIE + 2;
5108 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305109 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005110 pIeBuf += 4;
5111 if( pIesLocal->WAPI.akm_suite_count )
5112 {
5113 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305114 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5115 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005116 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305117 }
5118 vos_mem_copy(pIeBuf,
5119 &pIesLocal->WAPI.unicast_cipher_suite_count,
5120 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005122 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5123 {
5124 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305125 vos_mem_copy( pIeBuf,
5126 pIesLocal->WAPI.unicast_cipher_suites,
5127 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5129 }
lukez3c809222013-05-03 10:23:02 -07005130 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305131 vos_mem_copy(pIeBuf,
5132 pIesLocal->WAPI.multicast_cipher_suite,
5133 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005134 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305135 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305136 vos_mem_copy(pIeBuf,
5137 pIesLocal->WAPI.multicast_cipher_suite + 4,
5138 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005139 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305140 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305141 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5142
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005143 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005144 if( pIesLocal->WAPI.bkid_count )
5145 {
5146 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305147 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5148 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005149 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5150 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305151 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005153 }
5154 }
5155#endif /* FEATURE_WLAN_WAPI */
5156 if( !pIes )
5157 {
5158 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305159 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005160 }
5161 }
5162 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005163 return (status);
5164}
5165
Jeff Johnson295189b2012-06-20 16:38:30 -07005166static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5167{
5168 v_U8_t bACWeights[WLANTL_MAX_AC];
5169 v_U8_t paramBk, paramBe, paramVi, paramVo;
5170 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5172 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5173 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5174 //This doesn't address the case where the lower AC needs a real higher weight
5175 if( pIEs->WMMParams.present )
5176 {
5177 //no change to the lowest ones
5178 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5179 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5180 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5181 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5182 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5183 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5184 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5185 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5186 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5187 {
5188 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5189 fWeightChange = VOS_TRUE;
5190 }
5191 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5192 {
5193 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5194 fWeightChange = VOS_TRUE;
5195 }
5196 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5197 {
5198 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5199 fWeightChange = VOS_TRUE;
5200 }
5201 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5202 {
5203 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5204 fWeightChange = VOS_TRUE;
5205 }
5206 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5207 {
5208 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5209 fWeightChange = VOS_TRUE;
5210 }
5211 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5212 {
5213 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5214 fWeightChange = VOS_TRUE;
5215 }
5216 if(fWeightChange)
5217 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005218 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005219 bACWeights[2], bACWeights[3]);
5220 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5221 }
5222 }
5223}
Jeff Johnson295189b2012-06-20 16:38:30 -07005224#ifdef WLAN_FEATURE_VOWIFI_11R
5225//Returns whether the current association is a 11r assoc or not
5226tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5227{
5228#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5229 return csrNeighborRoamIs11rAssoc(pMac);
5230#else
5231 return eANI_BOOLEAN_FALSE;
5232#endif
5233}
5234#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005235#ifdef FEATURE_WLAN_ESE
5236//Returns whether the current association is a ESE assoc or not
5237tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005238{
5239#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005240 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005241#else
5242 return eANI_BOOLEAN_FALSE;
5243#endif
5244}
5245#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005246#ifdef FEATURE_WLAN_LFR
5247//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305248tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005249{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305250 tCsrRoamSession *pSession = NULL;
5251
5252 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5253 {
5254 pSession = CSR_GET_SESSION( pMac, sessionId );
5255 if (NULL != pSession->pCurRoamProfile)
5256 {
5257 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5258 {
5259 return eANI_BOOLEAN_FALSE;
5260 }
5261 }
5262 }
5263
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005264#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5265 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5266 {
5267 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5268 }
5269 else
5270#endif
5271 {
5272 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005273 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005274 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005275}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005276
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005277#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005278/* ---------------------------------------------------------------------------
5279
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005280 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005281
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005282 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005283
5284 \param pMac - The handle returned by macOpen.
5285
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005286 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005287
5288---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005289tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005290{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005291 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005292}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005293#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005294
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005295#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5296//Returns whether "FW based BG scan" is currently enabled...or not
5297tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5298{
5299 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5300}
5301#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005302#endif
5303
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005304#if defined(FEATURE_WLAN_ESE)
5305tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005306{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005307 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005308}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005309#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005310
Jeff Johnson295189b2012-06-20 16:38:30 -07005311//Return true means the command can be release, else not
5312static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5313 eCsrRoamCompleteResult Result, void *Context )
5314{
5315 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5316 tSirBssDescription *pSirBssDesc = NULL;
5317 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5318 tCsrScanResult *pScanResult = NULL;
5319 tCsrRoamInfo roamInfo;
5320 sme_QosAssocInfo assocInfo;
5321 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5322 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5323 tDot11fBeaconIEs *pIes = NULL;
5324 tANI_U32 sessionId = pCommand->sessionId;
5325 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5326 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5327 eRoamCmdStatus roamStatus;
5328 eCsrRoamResult roamResult;
5329 eHalStatus status;
5330 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005331 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005332
Jeff Johnson32d95a32012-09-10 13:15:23 -07005333 if(!pSession)
5334 {
5335 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5336 return eANI_BOOLEAN_FALSE;
5337 }
5338
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005339 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005340 switch( Result )
5341 {
5342 case eCsrJoinSuccess:
5343 // reset the IDLE timer
5344 // !!
5345 // !! fall through to the next CASE statement here is intentional !!
5346 // !!
5347 case eCsrReassocSuccess:
5348 if(eCsrReassocSuccess == Result)
5349 {
5350 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5351 }
5352 else
5353 {
5354 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5355 }
5356 // Success Join Response from LIM. Tell NDIS we are connected and save the
5357 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005358 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305359 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 //always free the memory here
5361 if(pSession->pWpaRsnRspIE)
5362 {
5363 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305364 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005365 pSession->pWpaRsnRspIE = NULL;
5366 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005367#ifdef FEATURE_WLAN_WAPI
5368 if(pSession->pWapiRspIE)
5369 {
5370 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305371 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005372 pSession->pWapiRspIE = NULL;
5373 }
5374#endif /* FEATURE_WLAN_WAPI */
5375#ifdef FEATURE_WLAN_BTAMP_UT_RF
5376 //Reset counter so no join retry is needed.
5377 pSession->maxRetryCount = 0;
5378 csrRoamStopJoinRetryTimer(pMac, sessionId);
5379#endif
5380 /* This creates problem since we have not saved the connected profile.
5381 So moving this after saving the profile
5382 */
5383 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305384
5385 /* Reset remainInPowerActiveTillDHCP as it might have been set
5386 * by last failed secured connection.
5387 * It should be set only for secured connection.
5388 */
5389 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5391 {
5392 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5393 }
5394 else
5395 {
5396 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005398 //Use the last connected bssdesc for reassoc-ing to the same AP.
5399 //NOTE: What to do when reassoc to a different AP???
5400 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5401 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5402 {
5403 pSirBssDesc = pSession->pConnectBssDesc;
5404 if(pSirBssDesc)
5405 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305406 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5407 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005408 }
5409 }
5410 else
5411 {
5412
5413 if(pCommand->u.roamCmd.pRoamBssEntry)
5414 {
5415 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5416 if(pScanResult != NULL)
5417 {
5418 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5419 //this can be NULL
5420 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305421 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5422 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005423 }
5424 }
5425 }
5426 if( pSirBssDesc )
5427 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005429 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5430 //Save WPA/RSN IE
5431 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005432#ifdef FEATURE_WLAN_ESE
5433 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005434#endif
Mukul Sharma9ca96b22014-11-15 19:40:04 +05305435#ifdef WLAN_FEATURE_VOWIFI_11R
5436 if (pSirBssDesc->mdiePresent)
5437 {
5438 if(csrIsAuthType11r(pProfile->negotiatedAuthType, VOS_TRUE)
5439#ifdef FEATURE_WLAN_ESE
5440 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
5441 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
5442#endif
5443 )
5444 {
5445 // is11Rconnection;
5446 roamInfo.is11rAssoc = VOS_TRUE;
5447 }
5448 else
5449 {
5450 // is11Rconnection;
5451 roamInfo.is11rAssoc = VOS_FALSE;
5452 }
5453 }
5454#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5456 // substate change.
5457 // Moving even save profile above so that below mentioned conditon is also met.
5458 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5459 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5461 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5462 // will be dropped for the security context may not be set properly.
5463 //
5464 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5465 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5466 //
5467 // this reordering was done on titan_prod_usb branch and is being replicated here.
5468 //
5469
5470 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5471 !pProfile->bWPSAssociation)
5472 {
5473 // Issue the set Context request to LIM to establish the Unicast STA context
5474 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5475 pProfile->negotiatedUCEncryptionType,
5476 pSirBssDesc, &(pSirBssDesc->bssId),
5477 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5478 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005479 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005480 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5481 }
5482 // Issue the set Context request to LIM to establish the Broadcast STA context
5483 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5484 pSirBssDesc, &BroadcastMac,
5485 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5486 }
5487 else
5488 {
5489 //Need to wait for supplicant authtication
5490 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 //Set the subestate to WaitForKey in case authentiation is needed
5492 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5493
Jeff Johnson295189b2012-06-20 16:38:30 -07005494 if(pProfile->bWPSAssociation)
5495 {
5496 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5497 }
5498 else
5499 {
5500 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5501 }
5502
5503 //Save sessionId in case of timeout
5504 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5505 //This time should be long enough for the rest of the process plus setting key
5506 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5507 {
5508 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005509 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5511 }
5512 }
5513
5514 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5515 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005516 if(Context)
5517 {
5518 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5519 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005520 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5521 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5522#ifdef WLAN_FEATURE_VOWIFI_11R
5523 len += pJoinRsp->parsedRicRspLen;
5524#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005525#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005526 len += pJoinRsp->tspecIeLen;
5527#endif
5528 if(len)
5529 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305530 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5531 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305533 vos_mem_copy(pSession->connectedInfo.pbFrames,
5534 pJoinRsp->frames, len);
5535 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5536 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5537 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005538#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305539 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005540#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005541#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305542 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005543#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305544 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5545 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5546 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5547 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 }
5549 }
5550 if(pCommand->u.roamCmd.fReassoc)
5551 {
5552 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5553 }
5554 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5555 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5556 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5557 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305558 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 }
5560 else
5561 {
5562 if(pCommand->u.roamCmd.fReassoc)
5563 {
5564 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5565 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5566 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5567 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5568 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5569 }
5570 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305571 /* Update the staId from the previous connected profile info
5572 as the reassociation is triggred at SME/HDD */
5573 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5574 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5575 {
5576 roamInfo.staId = pSession->connectedInfo.staId;
5577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005578#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5579 // Indicate SME-QOS with reassoc success event, only after
5580 // copying the frames
5581 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5582#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 roamInfo.pBssDesc = pSirBssDesc;
5584 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5585 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5586#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5587 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5588#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5589 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5591 //It may be better to let QoS do this????
5592 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005594 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5596 pmcStartUapsd( pMac, NULL, NULL );
5597 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305598 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005599 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5600 if( pSession->bRefAssocStartCnt > 0 )
5601 {
5602 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005603 //Remove this code once SLM_Sessionization is supported
5604 //BMPS_WORKAROUND_NOT_NEEDED
5605 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005606 {
5607 pMac->roam.configParam.doBMPSWorkaround = 1;
5608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005609 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5610 }
5611
5612 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 // reset the PMKID candidate list
5614 csrResetPMKIDCandidateList( pMac, sessionId );
5615 //Update TL's AC weight base on the current EDCA parameters
5616 //These parameters may change in the course of the connection, that sictuation
5617 //is not taken care here. This change is mainly to address a WIFI WMM test where
5618 //BE has a equal or higher TX priority than VI.
5619 //We only do this for infra link
5620 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5621 {
5622 csrCheckAndUpdateACWeight(pMac, pIes);
5623 }
5624#ifdef FEATURE_WLAN_WAPI
5625 // reset the BKID candidate list
5626 csrResetBKIDCandidateList( pMac, sessionId );
5627#endif /* FEATURE_WLAN_WAPI */
5628 }
5629 else
5630 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005631 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 csrScanCancelIdleScan(pMac);
5634 //Not to signal link up because keys are yet to be set.
5635 //The linkup function will overwrite the sub-state that we need to keep at this point.
5636 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5637 {
5638 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5639 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005640 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5641 //enough to let security and DHCP handshake succeed before entry into BMPS
5642 if (pmcShouldBmpsTimerRun(pMac))
5643 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305644 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5645 * until keys are set before going into BMPS.
5646 */
5647 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5648 {
5649 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5650 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5651 "to make sure we wait until keys are set before"
5652 " going to BMPS"));
5653 }
5654
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5656 != eHAL_STATUS_SUCCESS)
5657 {
5658 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5659 }
5660 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 break;
5663
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 case eCsrStartBssSuccess:
5665 // on the StartBss Response, LIM is returning the Bss Description that we
5666 // are beaconing. Add this Bss Description to our scan results and
5667 // chain the Profile to this Bss Description. On a Start BSS, there was no
5668 // detected Bss description (no partner) so we issued the Start Bss to
5669 // start the Ibss without any Bss description. Lim was kind enough to return
5670 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005671 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005673 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305674 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005675 if( CSR_IS_IBSS( pProfile ) )
5676 {
5677 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 else if (CSR_IS_INFRA_AP(pProfile))
5680 {
5681 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005683 else
5684 {
5685 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5686 }
5687 if( !CSR_IS_WDS_STA( pProfile ) )
5688 {
5689 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005691 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5692 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305693 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 roamInfo.pBssDesc = pSirBssDesc;
5695 //We need to associate_complete it first, becasue Associate_start already indicated.
5696 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5697 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5698 break;
5699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005700 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005702 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005703 }
5704 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5705 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5706 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5707 if(pSirBssDesc)
5708 {
5709 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305710 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5711 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005712 }
5713 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305714 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005715#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5716 {
5717 vos_log_ibss_pkt_type *pIbssLog;
5718 tANI_U32 bi;
5719
5720 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5721 if(pIbssLog)
5722 {
5723 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5724 {
5725 //We start the IBSS (didn't find any matched IBSS out there)
5726 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5727 }
5728 else
5729 {
5730 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5731 }
5732 if(pSirBssDesc)
5733 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305734 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5736 }
5737 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5738 {
5739 //***U8 is not enough for beacon interval
5740 pIbssLog->beaconInterval = (v_U8_t)bi;
5741 }
5742 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5743 }
5744 }
5745#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5746 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5747 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5749 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005750 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5751 csrRoamIssueSetContextReq( pMac, sessionId,
5752 pProfile->negotiatedMCEncryptionType,
5753 pSirBssDesc, &BroadcastMac,
5754 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5755 }
5756 }
5757 else
5758 {
5759 //Keep the state to eCSR_ROAMING_STATE_JOINING
5760 //Need to send join_req.
5761 if(pCommand->u.roamCmd.pRoamBssEntry)
5762 {
5763 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5764 {
5765 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5766 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5767 // Set the roaming substate to 'join attempt'...
5768 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005769 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 }
5771 }
5772 else
5773 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005774 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005775 VOS_ASSERT( 0 );
5776 }
5777 }
5778 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5779 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5780 //trigger the connection start indication in Vista
5781 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5782 {
5783 roamStatus = eCSR_ROAM_IBSS_IND;
5784 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5785 if( CSR_IS_WDS( pProfile ) )
5786 {
5787 roamStatus = eCSR_ROAM_WDS_IND;
5788 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005790 if( CSR_IS_INFRA_AP( pProfile ) )
5791 {
5792 roamStatus = eCSR_ROAM_INFRA_IND;
5793 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005795
5796 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5797 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5798 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305799 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005800 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5801 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005802 //We start the IBSS (didn't find any matched IBSS out there)
5803 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305805 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5806 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005807 //Remove this code once SLM_Sessionization is supported
5808 //BMPS_WORKAROUND_NOT_NEEDED
5809 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005810 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005811 {
5812 pMac->roam.configParam.doBMPSWorkaround = 1;
5813 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005814
Jeff Johnson295189b2012-06-20 16:38:30 -07005815 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5816 }
5817
5818 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005819
5820 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 {
5822 //need to send stop BSS because we fail to send join_req
5823 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5824 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5825 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005827 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 case eCsrStartBssFailure:
5829#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5830 {
5831 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5833 if(pIbssLog)
5834 {
5835 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5836 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5837 }
5838 }
5839#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 roamStatus = eCSR_ROAM_IBSS_IND;
5841 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5842 if( CSR_IS_WDS( pProfile ) )
5843 {
5844 roamStatus = eCSR_ROAM_WDS_IND;
5845 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 if( CSR_IS_INFRA_AP( pProfile ) )
5848 {
5849 roamStatus = eCSR_ROAM_INFRA_IND;
5850 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 if(Context)
5853 {
5854 pSirBssDesc = (tSirBssDescription *)Context;
5855 }
5856 else
5857 {
5858 pSirBssDesc = NULL;
5859 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305860 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 roamInfo.pBssDesc = pSirBssDesc;
5862 //We need to associate_complete it first, becasue Associate_start already indicated.
5863 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5864 csrSetDefaultDot11Mode( pMac );
5865 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 case eCsrSilentlyStopRoaming:
5867 // We are here because we try to start the same IBSS
5868 //No message to PE
5869 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005870 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005871 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5872 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305873 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5875 if( roamInfo.pBssDesc )
5876 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305877 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5878 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 }
5880 //Since there is no change in the current state, simply pass back no result otherwise
5881 //HDD may be mistakenly mark to disconnected state.
5882 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5883 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 case eCsrSilentlyStopRoamingSaveState:
5886 //We are here because we try to connect to the same AP
5887 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005888 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305889 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005890
5891 //to aviod resetting the substate to NONE
5892 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5893 //No need to change substate to wai_for_key because there is no state change
5894 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5895 if( roamInfo.pBssDesc )
5896 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305897 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5898 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5901 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5902 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5903 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5904 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5905 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5906 roamInfo.staId = pSession->connectedInfo.staId;
5907 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005909 pSession->bRefAssocStartCnt--;
5910 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5911 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5912 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5913 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005914 case eCsrReassocFailure:
5915#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5916 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5917#endif
5918 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005919 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 csrFreeConnectBssDesc(pMac, sessionId);
5921 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5922 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305923 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5925 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5926 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5927 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5928 eCSR_ROAM_WDS_IND,
5929 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5930 //Need to issue stop_bss
5931 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005932 case eCsrJoinFailure:
5933 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005934 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005935 default:
5936 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005937 smsLog(pMac, LOGW, FL("receives no association indication"));
5938 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005939 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5941 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5942 {
5943 //do not free for the other profiles as we need to send down stop BSS later
5944 csrFreeConnectBssDesc(pMac, sessionId);
5945 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5946 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5947 csrSetDefaultDot11Mode( pMac );
5948 }
5949
5950 switch( pCommand->u.roamCmd.roamReason )
5951 {
5952 // If this transition is because of an 802.11 OID, then we transition
5953 // back to INIT state so we sit waiting for more OIDs to be issued and
5954 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005955 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005956 case eCsrSmeIssuedAssocToSimilarAP:
5957 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005958 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305960 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5962 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5963 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305964 vos_mem_copy(&roamInfo.bssid,
5965 &pSession->joinFailStatusCode.bssId,
5966 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005967
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 /* Defeaturize this later if needed */
5969#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5970 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5971 if (csrRoamIsHandoffInProgress(pMac))
5972 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005973 /* Should indicate neighbor roam algorithm about the connect failure here */
5974 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5975 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005976#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005977 if(pSession->bRefAssocStartCnt > 0)
5978 {
5979 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005980 if(eCsrJoinFailureDueToConcurrency == Result)
5981 {
5982 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5983 eCSR_ROAM_ASSOCIATION_COMPLETION,
5984 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5985 }
5986 else
5987 {
5988 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 eCSR_ROAM_ASSOCIATION_COMPLETION,
5990 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005993 else
5994 {
5995 /* bRefAssocStartCnt is not incremented when
5996 * eRoamState == eCsrStopRoamingDueToConcurrency
5997 * in csrRoamJoinNextBss API. so handle this in
5998 * else case by sending assoc failure
5999 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006000 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006001 pCommand->u.scanCmd.roamId,
6002 eCSR_ROAM_ASSOCIATION_FAILURE,
6003 eCSR_ROAM_RESULT_FAILURE);
6004 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006005 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006006#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05306007 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6009#endif
6010 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6011 csrScanStartIdleScan(pMac);
6012#ifdef FEATURE_WLAN_BTAMP_UT_RF
6013 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
6014 //BT activity and not able to recevie WLAN traffic. Retry the join
6015 if( CSR_IS_WDS_STA(pProfile) )
6016 {
6017 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
6018 }
6019#endif
6020 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 case eCsrHddIssuedReassocToSameAP:
6022 case eCsrSmeIssuedReassocToSameAP:
6023 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6024
6025 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6026#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6027 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6028#endif
6029 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6030 csrScanStartIdleScan(pMac);
6031 break;
6032 case eCsrForcedDisassoc:
6033 case eCsrForcedDeauth:
6034 case eCsrSmeIssuedIbssJoinFailure:
6035 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6036
6037 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
6038 {
6039 // Notify HDD that IBSS join failed
6040 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6041 }
6042 else
6043 {
6044 csrRoamCallCallback(pMac, sessionId, NULL,
6045 pCommand->u.roamCmd.roamId,
6046 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6047 }
6048#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6049 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6050#endif
6051 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006052 /*
6053 *DelSta not done FW still in conneced state so dont
6054 *issue IMPS req
6055 */
6056 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6057 {
6058 smsLog(pMac, LOGW, FL("FW still in connected state "));
6059 break;
6060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 csrScanStartIdleScan(pMac);
6062 break;
6063 case eCsrForcedIbssLeave:
6064 csrRoamCallCallback(pMac, sessionId, NULL,
6065 pCommand->u.roamCmd.roamId,
6066 eCSR_ROAM_IBSS_LEAVE,
6067 eCSR_ROAM_RESULT_IBSS_STOP);
6068 break;
6069 case eCsrForcedDisassocMICFailure:
6070 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6071
6072 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6073#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6074 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6075#endif
6076 csrScanStartIdleScan(pMac);
6077 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 case eCsrStopBss:
6079 csrRoamCallCallback(pMac, sessionId, NULL,
6080 pCommand->u.roamCmd.roamId,
6081 eCSR_ROAM_INFRA_IND,
6082 eCSR_ROAM_RESULT_INFRA_STOPPED);
6083 break;
6084 case eCsrForcedDisassocSta:
6085 case eCsrForcedDeauthSta:
6086 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
6087 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
6088 {
6089 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006090
6091 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6092 {
6093 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05306094 vos_mem_copy(roamInfo.peerMac,
6095 pCommand->u.roamCmd.peerMac,
6096 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07006097 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6098 roamInfo.statusCode = eSIR_SME_SUCCESS;
6099 status = csrRoamCallCallback(pMac, sessionId,
6100 &roamInfo, pCommand->u.roamCmd.roamId,
6101 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
6102 }
6103 }
6104 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006105 case eCsrLostLink1:
6106 // if lost link roam1 failed, then issue lost link Scan2 ...
6107 csrScanRequestLostLink2(pMac, sessionId);
6108 break;
6109 case eCsrLostLink2:
6110 // if lost link roam2 failed, then issue lost link scan3 ...
6111 csrScanRequestLostLink3(pMac, sessionId);
6112 break;
6113 case eCsrLostLink3:
6114 default:
6115 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6116
6117 //We are done with one round of lostlink roaming here
6118 csrScanHandleFailedLostlink3(pMac, sessionId);
6119 break;
6120 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006121 break;
6122 }
6123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 return ( fReleaseCommand );
6125}
6126
Jeff Johnson295189b2012-06-20 16:38:30 -07006127eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6128{
6129 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 return (status);
6131}
6132
Jeff Johnson295189b2012-06-20 16:38:30 -07006133eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6134{
6135 eHalStatus status = eHAL_STATUS_SUCCESS;
6136 tANI_U32 size = 0;
6137
6138 do
6139 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306140 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006141 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6142 {
6143 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306144 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6145 if ( NULL == pDstProfile->BSSIDs.bssid )
6146 status = eHAL_STATUS_FAILURE;
6147 else
6148 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 if(!HAL_STATUS_SUCCESS(status))
6150 {
6151 break;
6152 }
6153 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306154 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6155 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006156 }
6157 if(pSrcProfile->SSIDs.numOfSSIDs)
6158 {
6159 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306160 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6161 if ( NULL == pDstProfile->SSIDs.SSIDList )
6162 status = eHAL_STATUS_FAILURE;
6163 else
6164 status = eHAL_STATUS_SUCCESS;
6165 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006166 {
6167 break;
6168 }
6169 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306170 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6171 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 }
6173 if(pSrcProfile->nWPAReqIELength)
6174 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306175 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6176 if ( NULL == pDstProfile->pWPAReqIE )
6177 status = eHAL_STATUS_FAILURE;
6178 else
6179 status = eHAL_STATUS_SUCCESS;
6180
6181 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006182 {
6183 break;
6184 }
6185 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306186 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6187 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006188 }
6189 if(pSrcProfile->nRSNReqIELength)
6190 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306191 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6192 if ( NULL == pDstProfile->pRSNReqIE )
6193 status = eHAL_STATUS_FAILURE;
6194 else
6195 status = eHAL_STATUS_SUCCESS;
6196
6197 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 {
6199 break;
6200 }
6201 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306202 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6203 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 }
6205#ifdef FEATURE_WLAN_WAPI
6206 if(pSrcProfile->nWAPIReqIELength)
6207 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306208 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6209 if ( NULL == pDstProfile->pWAPIReqIE )
6210 status = eHAL_STATUS_FAILURE;
6211 else
6212 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 if(!HAL_STATUS_SUCCESS(status))
6214 {
6215 break;
6216 }
6217 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306218 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6219 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 }
6221#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006222 if(pSrcProfile->nAddIEScanLength)
6223 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306224 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6225 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006226 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306227 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306228 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306229 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6230 }
6231 else
6232 {
6233 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6234 FL(" AddIEScanLength is not valid %u"),
6235 pSrcProfile->nAddIEScanLength);
6236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006237 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 if(pSrcProfile->nAddIEAssocLength)
6239 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306240 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6241 if ( NULL == pDstProfile->pAddIEAssoc )
6242 status = eHAL_STATUS_FAILURE;
6243 else
6244 status = eHAL_STATUS_SUCCESS;
6245
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 if(!HAL_STATUS_SUCCESS(status))
6247 {
6248 break;
6249 }
6250 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306251 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6252 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006254 if(pSrcProfile->ChannelInfo.ChannelList)
6255 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306256 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6257 pSrcProfile->ChannelInfo.numOfChannels);
6258 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6259 status = eHAL_STATUS_FAILURE;
6260 else
6261 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 if(!HAL_STATUS_SUCCESS(status))
6263 {
6264 break;
6265 }
6266 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306267 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6268 pSrcProfile->ChannelInfo.ChannelList,
6269 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 pDstProfile->AuthType = pSrcProfile->AuthType;
6272 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6273 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6274 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6275 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6276 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006277#ifdef WLAN_FEATURE_11W
6278 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6279 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6280 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006282 pDstProfile->BSSType = pSrcProfile->BSSType;
6283 pDstProfile->phyMode = pSrcProfile->phyMode;
6284 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6285
6286#ifdef FEATURE_WLAN_WAPI
6287 if(csrIsProfileWapi(pSrcProfile))
6288 {
6289 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6290 {
6291 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6292 }
6293 }
6294#endif /* FEATURE_WLAN_WAPI */
6295 pDstProfile->CBMode = pSrcProfile->CBMode;
6296 /*Save the WPS info*/
6297 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006298 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 pDstProfile->privacy = pSrcProfile->privacy;
6302 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6303 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6304 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6305 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6306 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6307 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6308 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6309 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6310 pDstProfile->wps_state = pSrcProfile->wps_state;
6311 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306312 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6313 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006314#ifdef WLAN_FEATURE_VOWIFI_11R
6315 if (pSrcProfile->MDID.mdiePresent)
6316 {
6317 pDstProfile->MDID.mdiePresent = 1;
6318 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6319 }
6320#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006321 }while(0);
6322
6323 if(!HAL_STATUS_SUCCESS(status))
6324 {
6325 csrReleaseProfile(pMac, pDstProfile);
6326 pDstProfile = NULL;
6327 }
6328
6329 return (status);
6330}
Jeff Johnson295189b2012-06-20 16:38:30 -07006331eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6332{
6333 eHalStatus status = eHAL_STATUS_SUCCESS;
6334 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6335 do
6336 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306337 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 if(pSrcProfile->bssid)
6339 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306340 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6341 if ( NULL == pDstProfile->BSSIDs.bssid )
6342 status = eHAL_STATUS_FAILURE;
6343 else
6344 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006345 if(!HAL_STATUS_SUCCESS(status))
6346 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306347 smsLog( pMac, LOGE,
6348 FL("failed to allocate memory for BSSID"
6349 "%02x:%02x:%02x:%02x:%02x:%02x"),
6350 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6351 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 break;
6353 }
6354 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306355 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6356 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006357 }
6358 if(pSrcProfile->SSID.ssId)
6359 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306360 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6361 if ( NULL == pDstProfile->SSIDs.SSIDList )
6362 status = eHAL_STATUS_FAILURE;
6363 else
6364 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 if(!HAL_STATUS_SUCCESS(status))
6366 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306367 smsLog( pMac, LOGE,
6368 FL("failed to allocate memory for SSIDList"
6369 "%02x:%02x:%02x:%02x:%02x:%02x"),
6370 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6371 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 break;
6373 }
6374 pDstProfile->SSIDs.numOfSSIDs = 1;
6375 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6376 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306377 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6378 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006379 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006380 if(pSrcProfile->nAddIEAssocLength)
6381 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306382 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6383 if ( NULL == pDstProfile->pAddIEAssoc)
6384 status = eHAL_STATUS_FAILURE;
6385 else
6386 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006387 if(!HAL_STATUS_SUCCESS(status))
6388 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006389 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006390 break;
6391 }
6392 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306393 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6394 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006395 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306396 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6397 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6398 status = eHAL_STATUS_FAILURE;
6399 else
6400 status = eHAL_STATUS_SUCCESS;
6401
Jeff Johnson295189b2012-06-20 16:38:30 -07006402 if(!HAL_STATUS_SUCCESS(status))
6403 {
6404 break;
6405 }
6406 pDstProfile->ChannelInfo.numOfChannels = 1;
6407 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006408 pDstProfile->AuthType.numEntries = 1;
6409 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6410 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6411 pDstProfile->EncryptionType.numEntries = 1;
6412 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6413 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6414 pDstProfile->mcEncryptionType.numEntries = 1;
6415 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6416 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6417 pDstProfile->BSSType = pSrcProfile->BSSType;
6418 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306419 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6420 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006421#ifdef WLAN_FEATURE_VOWIFI_11R
6422 if (pSrcProfile->MDID.mdiePresent)
6423 {
6424 pDstProfile->MDID.mdiePresent = 1;
6425 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6426 }
6427#endif
6428
6429 }while(0);
6430
6431 if(!HAL_STATUS_SUCCESS(status))
6432 {
6433 csrReleaseProfile(pMac, pDstProfile);
6434 pDstProfile = NULL;
6435 }
6436
6437 return (status);
6438}
6439
Jeff Johnson295189b2012-06-20 16:38:30 -07006440eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6441 tScanResultHandle hBSSList,
6442 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6443 tANI_BOOLEAN fClearScan)
6444{
6445 eHalStatus status = eHAL_STATUS_SUCCESS;
6446 tSmeCmd *pCommand;
6447
6448 pCommand = csrGetCommandBuffer(pMac);
6449 if(NULL == pCommand)
6450 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006451 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006452 status = eHAL_STATUS_RESOURCES;
6453 }
6454 else
6455 {
6456 if( fClearScan )
6457 {
6458 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306459 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006460 }
6461 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6462 if(NULL == pProfile)
6463 {
6464 //We can roam now
6465 //Since pProfile is NULL, we need to build our own profile, set everything to default
6466 //We can only support open and no encryption
6467 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6468 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6469 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6470 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6471 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6472 }
6473 else
6474 {
6475 //make a copy of the profile
6476 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6477 if(HAL_STATUS_SUCCESS(status))
6478 {
6479 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6480 }
6481 }
6482 pCommand->command = eSmeCommandRoam;
6483 pCommand->sessionId = (tANI_U8)sessionId;
6484 pCommand->u.roamCmd.hBSSList = hBSSList;
6485 pCommand->u.roamCmd.roamId = roamId;
6486 pCommand->u.roamCmd.roamReason = reason;
6487 //We need to free the BssList when the command is done
6488 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6489 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006490 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6491 FL("CSR PERSONA=%d"),
6492 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006493 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6494 if( !HAL_STATUS_SUCCESS( status ) )
6495 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006496 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006497 csrReleaseCommandRoam( pMac, pCommand );
6498 }
6499 }
6500
6501 return (status);
6502}
Jeff Johnson295189b2012-06-20 16:38:30 -07006503eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6504 tCsrRoamModifyProfileFields *pMmodProfileFields,
6505 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6506{
6507 eHalStatus status = eHAL_STATUS_SUCCESS;
6508 tSmeCmd *pCommand;
6509
6510 pCommand = csrGetCommandBuffer(pMac);
6511 if(NULL == pCommand)
6512 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006513 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006514 status = eHAL_STATUS_RESOURCES;
6515 }
6516 else
6517 {
6518 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306519 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 if(pProfile)
6521 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006522 //This is likely trying to reassoc to different profile
6523 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6524 //make a copy of the profile
6525 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6526 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006527 }
6528 else
6529 {
6530 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6531 //how to update WPA/WPA2 info in roamProfile??
6532 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006534 if(HAL_STATUS_SUCCESS(status))
6535 {
6536 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6537 }
6538 pCommand->command = eSmeCommandRoam;
6539 pCommand->sessionId = (tANI_U8)sessionId;
6540 pCommand->u.roamCmd.roamId = roamId;
6541 pCommand->u.roamCmd.roamReason = reason;
6542 //We need to free the BssList when the command is done
6543 //For reassoc there is no BSS list, so the boolean set to false
6544 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6545 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6546 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006547 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6548 if( !HAL_STATUS_SUCCESS( status ) )
6549 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006550 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006551 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6552 csrReleaseCommandRoam( pMac, pCommand );
6553 }
6554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006555 return (status);
6556}
6557
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006558eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6559 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306560// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006561{
6562 eHalStatus status = eHAL_STATUS_SUCCESS;
6563 tSmeCmd *pCommand;
6564
6565 pCommand = csrGetCommandBuffer(pMac);
6566 if(NULL == pCommand)
6567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006568 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006569 status = eHAL_STATUS_RESOURCES;
6570 }
6571 else
6572 {
6573 if(pBssDescription)
6574 {
6575 //copy over the parameters we need later
6576 pCommand->command = eSmeCommandRoam;
6577 pCommand->sessionId = (tANI_U8)sessionId;
6578 pCommand->u.roamCmd.roamReason = reason;
6579 //this is the important parameter
6580 //in this case we are using this field for the "next" BSS
6581 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6582 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6583 if( !HAL_STATUS_SUCCESS( status ) )
6584 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006585 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006586 csrReleaseCommandPreauth( pMac, pCommand );
6587 }
6588 }
6589 else
6590 {
6591 //Return failure
6592 status = eHAL_STATUS_RESOURCES;
6593 }
6594 }
6595 return (status);
6596}
6597
6598eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6599{
6600 tListElem *pEntry;
6601 tSmeCmd *pCommand;
6602 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6603 if ( pEntry )
6604 {
6605 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6606 if ( (eSmeCommandRoam == pCommand->command) &&
6607 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6608 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006609 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006610 pCommand->command, pCommand->u.roamCmd.roamReason);
6611 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6612 csrReleaseCommandPreauth( pMac, pCommand );
6613 }
6614 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006615 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006616 pCommand->command, pCommand->u.roamCmd.roamReason);
6617 }
6618 }
6619 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006620 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006621 }
6622 smeProcessPendingQueue( pMac );
6623 return eHAL_STATUS_SUCCESS;
6624}
6625
Jeff Johnson295189b2012-06-20 16:38:30 -07006626eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6627 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6628{
6629 eHalStatus status = eHAL_STATUS_FAILURE;
6630 tScanResultHandle hBSSList;
6631 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6633 if(HAL_STATUS_SUCCESS(status))
6634 {
6635 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6636 if(pRoamId)
6637 {
6638 *pRoamId = roamId;
6639 }
6640 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6641 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6642 if(!HAL_STATUS_SUCCESS(status))
6643 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006644 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 csrScanResultPurge(pMac, hBSSList);
6646 }
6647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006648 return (status);
6649}
6650
Jeff Johnson295189b2012-06-20 16:38:30 -07006651eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6652 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6653{
6654 eHalStatus status = eHAL_STATUS_SUCCESS;
6655 tScanResultHandle hBSSList;
6656 tCsrScanResultFilter *pScanFilter;
6657 tANI_U32 roamId = 0;
6658 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6659 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 if (NULL == pProfile)
6661 {
6662 smsLog(pMac, LOGP, FL("No profile specified"));
6663 return eHAL_STATUS_FAILURE;
6664 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306665 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6666 "encryType = %d"),
6667 lim_BssTypetoString(pProfile->BSSType),
6668 pProfile->BSSType,
6669 pProfile->AuthType.authType[0],
6670 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006671 if( CSR_IS_WDS( pProfile ) &&
6672 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6673 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006674 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006675 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 return status;
6677 }
6678 csrRoamCancelRoaming(pMac, sessionId);
6679 csrScanRemoveFreshScanCommand(pMac, sessionId);
6680 csrScanCancelIdleScan(pMac);
6681 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306682 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306683
6684 if (!vos_concurrent_open_sessions_running() &&
6685 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07006686 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306687 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 csrScanDisable(pMac);
6689 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306690
Jeff Johnson295189b2012-06-20 16:38:30 -07006691 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6692 //Check whether ssid changes
6693 if(csrIsConnStateConnected(pMac, sessionId))
6694 {
6695 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6696 {
6697 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6698 }
6699 }
6700#ifdef FEATURE_WLAN_BTAMP_UT_RF
6701 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6702#endif
6703 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006705 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006706 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6707 if(pRoamId)
6708 {
6709 roamId = *pRoamId;
6710 }
6711 if(!HAL_STATUS_SUCCESS(status))
6712 {
6713 fCallCallback = eANI_BOOLEAN_TRUE;
6714 }
6715 }
6716 else
6717 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306718 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6719 if ( NULL == pScanFilter )
6720 status = eHAL_STATUS_FAILURE;
6721 else
6722 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006723 if(HAL_STATUS_SUCCESS(status))
6724 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306725 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 //Try to connect to any BSS
6727 if(NULL == pProfile)
6728 {
6729 //No encryption
6730 pScanFilter->EncryptionType.numEntries = 1;
6731 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6732 }//we don't have a profile
6733 else
6734 {
6735 //Here is the profile we need to connect to
6736 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6737 }//We have a profile
6738 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6739 if(pRoamId)
6740 {
6741 *pRoamId = roamId;
6742 }
6743
6744 if(HAL_STATUS_SUCCESS(status))
6745 {
6746 /*Save the WPS info*/
6747 if(NULL != pProfile)
6748 {
6749 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006750 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 }
6752 else
6753 {
6754 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006755 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006757 do
6758 {
6759 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006760 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 )
6762 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006763 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6765 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6766 if(!HAL_STATUS_SUCCESS(status))
6767 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006768 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006769 fCallCallback = eANI_BOOLEAN_TRUE;
6770 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006771 else
6772 {
6773 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6774 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006775 break;
6776 }
6777 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006778 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 if(HAL_STATUS_SUCCESS(status))
6780 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006781 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6782 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6783 if(!HAL_STATUS_SUCCESS(status))
6784 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006785 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006786 csrScanResultPurge(pMac, hBSSList);
6787 fCallCallback = eANI_BOOLEAN_TRUE;
6788 }
6789 }//Have scan result
6790 else if(NULL != pProfile)
6791 {
6792 //Check whether it is for start ibss
6793 if(CSR_IS_START_IBSS(pProfile))
6794 {
6795 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6796 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6797 if(!HAL_STATUS_SUCCESS(status))
6798 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006799 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006800 fCallCallback = eANI_BOOLEAN_TRUE;
6801 }
6802 }
6803 else
6804 {
6805 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006806 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 if(!HAL_STATUS_SUCCESS(status))
6808 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006809 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006810 fCallCallback = eANI_BOOLEAN_TRUE;
6811 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006812 else
6813 {
6814 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006816 }
6817 }
6818 else
6819 {
6820 fCallCallback = eANI_BOOLEAN_TRUE;
6821 }
6822 } while (0);
6823 if(NULL != pProfile)
6824 {
6825 //we need to free memory for filter if profile exists
6826 csrFreeScanFilter(pMac, pScanFilter);
6827 }
6828 }//Got the scan filter from profile
6829
Kiet Lam64c1b492013-07-12 13:56:44 +05306830 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 }//allocated memory for pScanFilter
6832 }//No Bsslist coming in
6833 //tell the caller if we fail to trigger a join request
6834 if( fCallCallback )
6835 {
6836 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6837 }
6838
6839 return (status);
6840}
Jeff Johnson295189b2012-06-20 16:38:30 -07006841eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6842 tCsrRoamModifyProfileFields modProfileFields,
6843 tANI_U32 *pRoamId)
6844{
6845 eHalStatus status = eHAL_STATUS_SUCCESS;
6846 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6847 tANI_U32 roamId = 0;
6848 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006849 if (NULL == pProfile)
6850 {
6851 smsLog(pMac, LOGP, FL("No profile specified"));
6852 return eHAL_STATUS_FAILURE;
6853 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306854 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6855 "encryType = %d"),
6856 lim_BssTypetoString(pProfile->BSSType),
6857 pProfile->BSSType,
6858 pProfile->AuthType.authType[0],
6859 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006860 csrRoamCancelRoaming(pMac, sessionId);
6861 csrScanRemoveFreshScanCommand(pMac, sessionId);
6862 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306863 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006864 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 if(csrIsConnStateConnected(pMac, sessionId))
6866 {
6867 if(pProfile)
6868 {
6869 if(pProfile->SSIDs.numOfSSIDs &&
6870 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6871 {
6872 fCallCallback = eANI_BOOLEAN_FALSE;
6873 }
6874 else
6875 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006876 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 }
6878 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306879 else if (!vos_mem_compare(&modProfileFields,
6880 &pSession->connectedProfile.modifyProfileFields,
6881 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006882 {
6883 fCallCallback = eANI_BOOLEAN_FALSE;
6884 }
6885 else
6886 {
6887 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006888 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006889 }
6890 }
6891 else
6892 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006893 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006895 if(!fCallCallback)
6896 {
6897 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6898 if(pRoamId)
6899 {
6900 *pRoamId = roamId;
6901 }
6902
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6904 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006905 }
6906 else
6907 {
6908 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6909 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6910 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006911 return status;
6912}
Jeff Johnson295189b2012-06-20 16:38:30 -07006913eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6914{
6915 eHalStatus status = eHAL_STATUS_FAILURE;
6916 tScanResultHandle hBSSList = NULL;
6917 tCsrScanResultFilter *pScanFilter = NULL;
6918 tANI_U32 roamId;
6919 tCsrRoamProfile *pProfile = NULL;
6920 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006921
6922 if(!pSession)
6923 {
6924 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6925 return eHAL_STATUS_FAILURE;
6926 }
6927
Jeff Johnson295189b2012-06-20 16:38:30 -07006928 do
6929 {
6930 if(pSession->pCurRoamProfile)
6931 {
6932 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306933 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306935 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6936 if ( NULL == pProfile )
6937 status = eHAL_STATUS_FAILURE;
6938 else
6939 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006940 if(!HAL_STATUS_SUCCESS(status))
6941 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306942 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006943 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306944 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006945 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306946 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6947 if ( NULL == pScanFilter )
6948 status = eHAL_STATUS_FAILURE;
6949 else
6950 status = eHAL_STATUS_SUCCESS;
6951
Jeff Johnson295189b2012-06-20 16:38:30 -07006952 if(!HAL_STATUS_SUCCESS(status))
6953 {
6954 break;
6955 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306956 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006957 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6958 if(!HAL_STATUS_SUCCESS(status))
6959 {
6960 break;
6961 }
6962 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6963 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6964 if(HAL_STATUS_SUCCESS(status))
6965 {
6966 //we want to put the last connected BSS to the very beginning, if possible
6967 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6968 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6969 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6970 if(!HAL_STATUS_SUCCESS(status))
6971 {
6972 csrScanResultPurge(pMac, hBSSList);
6973 break;
6974 }
6975 }
6976 else
6977 {
6978 //Do a scan on this profile
6979 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006980 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 if(!HAL_STATUS_SUCCESS(status))
6982 {
6983 break;
6984 }
6985 }
6986 }//We have a profile
6987 else
6988 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006989 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006990 break;
6991 }
6992 }while(0);
6993 if(pScanFilter)
6994 {
6995 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306996 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006997 }
6998 if(NULL != pProfile)
6999 {
7000 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307001 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007002 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007003 return (status);
7004}
Jeff Johnson295189b2012-06-20 16:38:30 -07007005eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
7006{
7007 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007008 if(csrIsConnStateConnected(pMac, sessionId))
7009 {
7010 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7011 if(HAL_STATUS_SUCCESS(status))
7012 {
7013 status = csrRoamJoinLastProfile(pMac, sessionId);
7014 }
7015 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 return (status);
7017}
7018
Jeff Johnson295189b2012-06-20 16:38:30 -07007019eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7020{
7021 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007022 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007023 csrRoamCancelRoaming(pMac, sessionId);
7024 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7025 if(csrIsConnStateDisconnected(pMac, sessionId))
7026 {
7027 status = csrRoamJoinLastProfile(pMac, sessionId);
7028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007029 return (status);
7030}
7031
Jeff Johnson295189b2012-06-20 16:38:30 -07007032eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
7033{
7034 eHalStatus status = eHAL_STATUS_SUCCESS;
7035 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
7036 eCsrRoamSubState NewSubstate;
7037 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05307038
7039 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7040 {
7041 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
7042 " eCSR_ROAM_SUBSTATE_NONE"));
7043 csrRoamStopWaitForKeyTimer( pMac );
7044 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007046 // change state to 'Roaming'...
7047 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7048
7049 if ( csrIsConnStateIbss( pMac, sessionId ) )
7050 {
7051 // If we are in an IBSS, then stop the IBSS...
7052 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7053 fComplete = (!HAL_STATUS_SUCCESS(status));
7054 }
7055 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7056 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007057 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 -07007058 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7059 //Restore AC weight in case we change it
7060 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7061 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7062 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7063 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7064 {
7065 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7066 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307067 else
7068 {
7069 // If we are in neighbor preauth done state then on receiving
7070 // disassoc or deauth we dont roam instead we just disassoc
7071 // from current ap and then go to disconnected state
7072 // This happens for ESE and 11r FT connections ONLY.
7073#ifdef WLAN_FEATURE_VOWIFI_11R
7074 if (csrRoamIs11rAssoc(pMac) &&
7075 (csrNeighborRoamStatePreauthDone(pMac)))
7076 {
7077 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7078 }
7079#endif
7080#ifdef FEATURE_WLAN_ESE
7081 if (csrRoamIsESEAssoc(pMac) &&
7082 (csrNeighborRoamStatePreauthDone(pMac)))
7083 {
7084 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7085 }
7086#endif
7087#ifdef FEATURE_WLAN_LFR
7088 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7089 (csrNeighborRoamStatePreauthDone(pMac)))
7090 {
7091 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7092 }
7093#endif
7094 }
7095
Jeff Johnson295189b2012-06-20 16:38:30 -07007096 if( fDisassoc )
7097 {
7098 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307099#ifdef DEBUG_ROAM_DELAY
7100 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7101#endif /* DEBUG_ROAM_DELAY */
Jeff Johnson295189b2012-06-20 16:38:30 -07007102 }
7103 else
7104 {
7105 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7106 }
7107 fComplete = (!HAL_STATUS_SUCCESS(status));
7108 }
7109 else if ( csrIsConnStateWds( pMac, sessionId ) )
7110 {
7111 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7112 {
7113 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7114 fComplete = (!HAL_STATUS_SUCCESS(status));
7115 }
7116 //This has to be WDS station
7117 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7118 {
7119
7120 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7121 if( fDisassoc )
7122 {
7123 status = csrRoamIssueDisassociate( pMac, sessionId,
7124 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7125 fComplete = (!HAL_STATUS_SUCCESS(status));
7126 }
7127 }
7128 } else {
7129 // we got a dis-assoc request while not connected to any peer
7130 // just complete the command
7131 fComplete = eANI_BOOLEAN_TRUE;
7132 status = eHAL_STATUS_FAILURE;
7133 }
7134 if(fComplete)
7135 {
7136 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7137 }
7138
7139 if(HAL_STATUS_SUCCESS(status))
7140 {
7141 if ( csrIsConnStateInfra( pMac, sessionId ) )
7142 {
7143 //Set the state to disconnect here
7144 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7145 }
7146 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007147 else
7148 {
7149 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7150 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007151 return (status);
7152}
7153
Jeff Johnson295189b2012-06-20 16:38:30 -07007154/* This is been removed from latest code base */
7155/*
7156static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7157{
7158 eHalStatus status;
7159 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007160 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7161 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 return ( status );
7163}
7164*/
7165
Jeff Johnson295189b2012-06-20 16:38:30 -07007166eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7167{
7168 eHalStatus status = eHAL_STATUS_SUCCESS;
7169 tSmeCmd *pCommand;
7170 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 do
7172 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08007173 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007174 pCommand = csrGetCommandBuffer( pMac );
7175 if ( !pCommand )
7176 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007177 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007178 status = eHAL_STATUS_RESOURCES;
7179 break;
7180 }
7181 //Change the substate in case it is wait-for-key
7182 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7183 {
7184 csrRoamStopWaitForKeyTimer( pMac );
7185 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7186 }
7187 pCommand->command = eSmeCommandRoam;
7188 pCommand->sessionId = (tANI_U8)sessionId;
7189 switch ( reason )
7190 {
7191 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7192 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7193 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007194 case eCSR_DISCONNECT_REASON_DEAUTH:
7195 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7196 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 case eCSR_DISCONNECT_REASON_HANDOFF:
7198 fHighPriority = eANI_BOOLEAN_TRUE;
7199 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7200 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7202 case eCSR_DISCONNECT_REASON_DISASSOC:
7203 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7204 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007205 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7206 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7207 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7209 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7210 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007211 default:
7212 break;
7213 }
7214 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7215 if( !HAL_STATUS_SUCCESS( status ) )
7216 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007217 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 csrReleaseCommandRoam( pMac, pCommand );
7219 }
7220 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 return( status );
7222}
7223
Jeff Johnson295189b2012-06-20 16:38:30 -07007224eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7225{
7226 eHalStatus status = eHAL_STATUS_SUCCESS;
7227 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007228 pCommand = csrGetCommandBuffer( pMac );
7229 if ( NULL != pCommand )
7230 {
7231 //Change the substate in case it is wait-for-key
7232 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7233 {
7234 csrRoamStopWaitForKeyTimer( pMac );
7235 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7236 }
7237 pCommand->command = eSmeCommandRoam;
7238 pCommand->sessionId = (tANI_U8)sessionId;
7239 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7240 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7241 if( !HAL_STATUS_SUCCESS( status ) )
7242 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007243 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007244 csrReleaseCommandRoam( pMac, pCommand );
7245 }
7246 }
7247 else
7248 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007249 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007250 status = eHAL_STATUS_RESOURCES;
7251 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 return ( status );
7253}
7254
Jeff Johnson295189b2012-06-20 16:38:30 -07007255eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7256{
7257 eHalStatus status = eHAL_STATUS_SUCCESS;
7258 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007259
7260 if(!pSession)
7261 {
7262 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7263 return eHAL_STATUS_FAILURE;
7264 }
7265
Jeff Johnson295189b2012-06-20 16:38:30 -07007266#ifdef FEATURE_WLAN_BTAMP_UT_RF
7267 //Stop te retry
7268 pSession->maxRetryCount = 0;
7269 csrRoamStopJoinRetryTimer(pMac, sessionId);
7270#endif
7271 //Not to call cancel roaming here
7272 //Only issue disconnect when necessary
7273 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7274 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7275 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7276
7277 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007278 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007279 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7280 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307281 else
7282 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307283 csrScanAbortScanForSSID(pMac, sessionId);
7284 status = eHAL_STATUS_CMD_NOT_QUEUED;
7285 smsLog( pMac, LOG1, FL(" Disconnect cmd not queued, Roam command is not present"
7286 " return with status %d"), status);
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307287 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007288 return (status);
7289}
7290
Jeff Johnson295189b2012-06-20 16:38:30 -07007291eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7292{
7293 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007294
7295 if(!pSession)
7296 {
7297 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7298 return eHAL_STATUS_FAILURE;
7299 }
7300
Jeff Johnson295189b2012-06-20 16:38:30 -07007301 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007302 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7303
7304 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7305}
7306
Jeff Johnson295189b2012-06-20 16:38:30 -07007307eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7308 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7309{
7310 eHalStatus status = eHAL_STATUS_SUCCESS;
7311 tDot11fBeaconIEs *pIesTemp = pIes;
7312 tANI_U8 index;
7313 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7314 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007315
7316 if(!pSession)
7317 {
7318 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7319 return eHAL_STATUS_FAILURE;
7320 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007321 if(pConnectProfile->pAddIEAssoc)
7322 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307323 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007324 pConnectProfile->pAddIEAssoc = NULL;
7325 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307326 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007327 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7328 pConnectProfile->AuthInfo = pProfile->AuthType;
7329 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7330 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7331 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7332 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7333 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7334 pConnectProfile->BSSType = pProfile->BSSType;
7335 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7336 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007337 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307338 if (!pConnectProfile->beaconInterval)
7339 {
7340 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7341 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307342 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007343 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7344 if(pProfile->nAddIEAssocLength)
7345 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307346 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7347 if ( NULL == pConnectProfile->pAddIEAssoc )
7348 status = eHAL_STATUS_FAILURE;
7349 else
7350 status = eHAL_STATUS_SUCCESS;
7351 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007352 {
7353 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7354 return eHAL_STATUS_FAILURE;
7355 }
7356 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307357 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7358 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007359 }
7360
Jeff Johnson295189b2012-06-20 16:38:30 -07007361 //Save bssid
7362 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7363#ifdef WLAN_FEATURE_VOWIFI_11R
7364 if (pSirBssDesc->mdiePresent)
7365 {
7366 pConnectProfile->MDID.mdiePresent = 1;
7367 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7368 }
7369#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007370 if( NULL == pIesTemp )
7371 {
7372 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7373 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007374#ifdef FEATURE_WLAN_ESE
7375 if ((csrIsProfileESE(pProfile) ||
7376 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307377 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7378 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7379 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7380 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7381#ifdef WLAN_FEATURE_11W
7382 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +05307383 || (pProfile->negotiatedAuthType ==
7384 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307385#endif
7386 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007387 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007388 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007389 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007390 }
7391#endif
7392 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007393 if(HAL_STATUS_SUCCESS(status))
7394 {
7395 if(pIesTemp->SSID.present)
7396 {
7397 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307398 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7399 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007400 }
7401
7402 //Save the bss desc
7403 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307404
7405 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307407 //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 -07007408 pConnectProfile->qap = TRUE;
7409 }
7410 else
7411 {
7412 pConnectProfile->qap = FALSE;
7413 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007414 if ( NULL == pIes )
7415 {
7416 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307417 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007418 }
7419 }
7420 //Save Qos connection
7421 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7422
7423 if(!HAL_STATUS_SUCCESS(status))
7424 {
7425 csrFreeConnectBssDesc(pMac, sessionId);
7426 }
7427 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7428 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307429 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7430 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7431 pConnectProfile->SSID.ssId,
7432 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007433 {
7434 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7435 break;
7436 }
7437 pConnectProfile->handoffPermitted = FALSE;
7438 }
7439
7440 return (status);
7441}
7442
Jeff Johnson295189b2012-06-20 16:38:30 -07007443static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7444{
7445 tListElem *pEntry = NULL;
7446 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007447 //The head of the active list is the request we sent
7448 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7449 if(pEntry)
7450 {
7451 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7452 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007453 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7454 {
7455 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7456 {
7457#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7458 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7459#endif
7460 }
7461 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7462 }
7463 else
7464 {
7465 tANI_U32 roamId = 0;
7466 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007467 if(!pSession)
7468 {
7469 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7470 return;
7471 }
7472
Jeff Johnson295189b2012-06-20 16:38:30 -07007473
7474 //The head of the active list is the request we sent
7475 //Try to get back the same profile and roam again
7476 if(pCommand)
7477 {
7478 roamId = pCommand->u.roamCmd.roamId;
7479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007480 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7481 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007482 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007483#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7484 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7485 if (csrRoamIsHandoffInProgress(pMac))
7486 {
7487 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7488 /* Should indicate neighbor roam algorithm about the connect failure here */
7489 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7490 }
7491#endif
7492 if (pCommand)
7493 {
7494 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7495 {
7496 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7497 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7498 csrRoamReissueRoamCommand(pMac);
7499 }
7500 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7501 {
7502 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7503 }
7504 else
7505 {
7506 csrRoam(pMac, pCommand);
7507 }
7508 }
7509 else
7510 {
7511 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7512 }
7513 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7514}
7515
Jeff Johnson295189b2012-06-20 16:38:30 -07007516eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7517 tDot11fBeaconIEs *pIes,
7518 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7519{
7520 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007521 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7522 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007523
7524 // Set the roaming substate to 'join attempt'...
7525 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007526 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007527 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007528 return (status);
7529}
7530
Jeff Johnson295189b2012-06-20 16:38:30 -07007531static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7532 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7533{
7534 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007535 // Set the roaming substate to 'join attempt'...
7536 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7537
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307538 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7539 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307540#ifdef DEBUG_ROAM_DELAY
7541 //HACK usign buff len as Auth type
7542 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7543 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7544#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007545 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007546 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007547}
7548
Jeff Johnson295189b2012-06-20 16:38:30 -07007549void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7550{
7551 tListElem *pEntry;
7552 tSmeCmd *pCommand;
7553 tCsrRoamInfo roamInfo;
7554 tANI_U32 sessionId;
7555 tCsrRoamSession *pSession;
7556
7557 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7558 if(pEntry)
7559 {
7560 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7561 if ( eSmeCommandRoam == pCommand->command )
7562 {
7563 sessionId = pCommand->sessionId;
7564 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007565
7566 if(!pSession)
7567 {
7568 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7569 return;
7570 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307571 /* While switching between two AP, csr will reissue roam command again
7572 to the nextbss if it was interrupted by the dissconnect req for the
7573 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7574 so reset the bRefAssocStartCnt.
7575 */
7576 if(pSession->bRefAssocStartCnt > 0)
7577 {
7578 pSession->bRefAssocStartCnt--;
7579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007580 if( pCommand->u.roamCmd.fStopWds )
7581 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307582 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007583 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7584 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7585 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007586 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007587 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7588 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7589 eCSR_ROAM_WDS_IND,
7590 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007591 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7592 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7593 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7594 eCSR_ROAM_INFRA_IND,
7595 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7596 }
7597
Jeff Johnson295189b2012-06-20 16:38:30 -07007598
Jeff Johnson295189b2012-06-20 16:38:30 -07007599 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7600 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007601 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007602 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7603 }
7604 }
7605 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7606 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007607 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007608 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7609 }
7610 }
7611 else
7612 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007613 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007614 }
7615 }
7616 else
7617 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007618 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007619 }
7620}
7621
Jeff Johnson295189b2012-06-20 16:38:30 -07007622tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7623{
7624 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7625 tListElem *pEntry;
7626 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007627 //alwasy lock active list before locking pending list
7628 csrLLLock( &pMac->sme.smeCmdActiveList );
7629 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7630 if(pEntry)
7631 {
7632 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7633 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7634 {
7635 fRet = eANI_BOOLEAN_TRUE;
7636 }
7637 }
7638 if(eANI_BOOLEAN_FALSE == fRet)
7639 {
7640 csrLLLock(&pMac->sme.smeCmdPendingList);
7641 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7642 while(pEntry)
7643 {
7644 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7645 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7646 {
7647 fRet = eANI_BOOLEAN_TRUE;
7648 break;
7649 }
7650 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7651 }
7652 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7653 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307654 if (eANI_BOOLEAN_FALSE == fRet)
7655 {
7656 csrLLLock(&pMac->roam.roamCmdPendingList);
7657 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7658 while (pEntry)
7659 {
7660 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7661 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7662 {
7663 fRet = eANI_BOOLEAN_TRUE;
7664 break;
7665 }
7666 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7667 }
7668 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7669 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007670 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 return (fRet);
7672}
7673
Jeff Johnson295189b2012-06-20 16:38:30 -07007674tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7675{
7676 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7677 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007678 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7679 {
7680 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7681 {
7682 break;
7683 }
7684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007685 return ( fRet );
7686}
7687
Jeff Johnson295189b2012-06-20 16:38:30 -07007688tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7689{
7690 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007691 //alwasy lock active list before locking pending list
7692 csrLLLock( &pMac->sme.smeCmdActiveList );
7693 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7694 if(eANI_BOOLEAN_FALSE == fRet)
7695 {
7696 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7697 }
7698 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007699 return (fRet);
7700}
7701
Jeff Johnson295189b2012-06-20 16:38:30 -07007702tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7703{
7704 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7705 tListElem *pEntry;
7706 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007707 //alwasy lock active list before locking pending list
7708 csrLLLock( &pMac->sme.smeCmdActiveList );
7709 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7710 if( pEntry )
7711 {
7712 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7713 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7714 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7715 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7716 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7717 {
7718 fRet = eANI_BOOLEAN_TRUE;
7719 }
7720 }
7721 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007722 return (fRet);
7723}
Jeff Johnson295189b2012-06-20 16:38:30 -07007724eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7725{
7726 eHalStatus status = eHAL_STATUS_SUCCESS;
7727 tSmeCmd *pCommand = NULL;
7728 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7729 tANI_BOOLEAN fRemoveCmd = FALSE;
7730 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007731 // Delete the old assoc command. All is setup for reassoc to be serialized
7732 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7733 if ( pEntry )
7734 {
7735 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7736 if ( !pCommand )
7737 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007738 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007739 return eHAL_STATUS_RESOURCES;
7740 }
7741 if ( eSmeCommandRoam == pCommand->command )
7742 {
7743 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7744 {
7745 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7746 }
7747 else
7748 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007749 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007750 }
7751 if (fRemoveCmd == FALSE)
7752 {
7753 // Implies we did not get the serialized assoc command we
7754 // were expecting
7755 pCommand = NULL;
7756 }
7757 }
7758 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007759 if(NULL == pCommand)
7760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007761 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007762 return eHAL_STATUS_RESOURCES;
7763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007764 do
7765 {
7766 //Change the substate in case it is wait-for-key
7767 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7768 {
7769 csrRoamStopWaitForKeyTimer( pMac );
7770 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7771 }
7772 pCommand->command = eSmeCommandRoam;
7773 pCommand->sessionId = (tANI_U8)sessionId;
7774 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007775 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7776 if( !HAL_STATUS_SUCCESS( status ) )
7777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007778 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007779 csrReleaseCommandRoam( pMac, pCommand );
7780 }
7781 } while( 0 );
7782
Jeff Johnson295189b2012-06-20 16:38:30 -07007783 return( status );
7784}
7785static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7786{
7787 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7788 tCsrScanResult *pScanResult = NULL;
7789 tSirBssDescription *pBssDesc = NULL;
7790 tSmeCmd *pCommand = NULL;
7791 tANI_U32 sessionId;
7792 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007793 if(NULL == pEntry)
7794 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307795 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007796 return;
7797 }
7798 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7799 sessionId = pCommand->sessionId;
7800 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007801
7802 if(!pSession)
7803 {
7804 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7805 return;
7806 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307807 smsLog(pMac, LOG1, FL("CFG return value is %d "
7808 " current state is : %d substate is : %d "),
7809 result, pMac->roam.curState[sessionId],
7810 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007811 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7812 {
7813 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007814 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007815 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7816 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007817 /* If the roaming has stopped, not to continue the roaming command*/
7818 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7819 {
7820 //No need to complete roaming here as it already completes
7821 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7822 pCommand->u.roamCmd.roamReason);
7823 csrSetAbortRoamingCommand( pMac, pCommand );
7824 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7825 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007826 else
7827 {
7828 if ( CCM_IS_RESULT_SUCCESS(result) )
7829 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307830 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007831 // Successfully set the configuration parameters for the new Bss. Attempt to
7832 // join the roaming Bss.
7833 if(pCommand->u.roamCmd.pRoamBssEntry)
7834 {
7835 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7836 pBssDesc = &pScanResult->Result.BssDescriptor;
7837 }
7838 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7839 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007840 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007841 )
7842 {
7843 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7844 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7845 pBssDesc, pCommand->u.roamCmd.roamId )))
7846 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307847 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007848 //We need to complete the command
7849 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7850 }
7851 }
7852 else
7853 {
7854 if (!pCommand->u.roamCmd.pRoamBssEntry)
7855 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307856 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 //We need to complete the command
7858 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7859 return;
7860 }
7861 // If we are roaming TO an Infrastructure BSS...
7862 VOS_ASSERT(pScanResult != NULL);
7863 if ( csrIsInfraBssDesc( pBssDesc ) )
7864 {
7865 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307866 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007867 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7868 {
7869 // ..and currently in an Infrastructure connection....
7870 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7871 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307872 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 // ...and the SSIDs are equal, then we Reassoc.
7874 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7875 pIesLocal ) )
7876 // ..and currently in an infrastructure connection
7877 {
7878 // then issue a Reassoc.
7879 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7880 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7881 &pCommand->u.roamCmd.roamProfile );
7882 }
7883 else
7884 {
7885
7886 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7887 // previously associated AP.
7888 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7889 pIesLocal,
7890 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7891 {
7892 //try something else
7893 csrRoam( pMac, pCommand );
7894 }
7895 }
7896 }
7897 else
7898 {
7899 eHalStatus status = eHAL_STATUS_SUCCESS;
7900
7901 /* We need to come with other way to figure out that this is because of HO in BMP
7902 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007903 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007904 * use join request */
7905#ifdef WLAN_FEATURE_VOWIFI_11R
7906 if (csrRoamIsHandoffInProgress(pMac) &&
7907 csrRoamIs11rAssoc(pMac))
7908 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307909 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007910 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7911 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7912 }
7913 else
7914#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007915#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007916 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007917 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07007918 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307919 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 // Now serialize the reassoc command.
7921 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7922 }
7923 else
7924#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007925#ifdef FEATURE_WLAN_LFR
7926 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307927 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007928 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307929 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007930 // Now serialize the reassoc command.
7931 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7932 }
7933 else
7934#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007935 // else we are not connected and attempting to Join. Issue the
7936 // Join request.
7937 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307938 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07007939 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7940 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7941 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7942 }
7943 if(!HAL_STATUS_SUCCESS(status))
7944 {
7945 //try something else
7946 csrRoam( pMac, pCommand );
7947 }
7948 }
7949 if( !pScanResult->Result.pvIes )
7950 {
7951 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307952 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007953 }
7954 }
7955 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7956 else
7957 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007958 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007959 }
7960 }//else
7961 }//if ( WNI_CFG_SUCCESS == result )
7962 else
7963 {
7964 // In the event the configuration failed, for infra let the roam processor
7965 //attempt to join something else...
7966 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7967 {
7968 csrRoam(pMac, pCommand);
7969 }
7970 else
7971 {
7972 //We need to complete the command
7973 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7974 {
7975 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7976 }
7977 else
7978 {
7979 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7980 }
7981 }
7982 }
7983 }//we have active entry
7984}
7985
Jeff Johnson295189b2012-06-20 16:38:30 -07007986static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7987{
7988 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007989 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007990 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7991 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007992 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7994 // join the new one...
7995 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007996 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7997 }
7998 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007999 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008000 /***profHandleLostLinkAfterReset(pAdapter);
8001 // In the event the authenticate fails, let the roam processor attempt to join something else...
8002 roamRoam( pAdapter );***/
8003 }
8004}
8005
Jeff Johnson295189b2012-06-20 16:38:30 -07008006static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
8007{
8008 eCsrRoamCompleteResult result;
8009 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8010 tCsrRoamInfo roamInfo;
8011 tANI_U32 roamId = 0;
8012
8013 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
8014 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008015 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008016 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 /* Defeaturize this part later if needed */
8018#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8019 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
8020 * we need the response contents while processing the result in csrRoamProcessResults() */
8021 if (csrRoamIsHandoffInProgress(pMac))
8022 {
8023 /* Need to dig more on indicating events to SME QoS module */
8024 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8025 csrRoamComplete( pMac, result, pSmeJoinRsp);
8026 }
8027 else
8028#endif
8029 {
8030 csrRoamComplete( pMac, result, NULL );
8031 }
8032 }
8033 /* Should we handle this similar to handling the join failure? Is it ok
8034 * to call csrRoamComplete() with state as CsrJoinFailure */
8035 else
8036 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008037 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008038 result = eCsrReassocFailure;
8039#ifdef WLAN_FEATURE_VOWIFI_11R
8040 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05308041 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
8042 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 {
8044 // Inform HDD to turn off FT flag in HDD
8045 if (pNeighborRoamInfo)
8046 {
8047 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8048 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8049 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008050 /*
8051 * Since the above callback sends a disconnect
8052 * to HDD, we should clean-up our state
8053 * machine as well to be in sync with the upper
8054 * layers. There is no need to send a disassoc
8055 * since: 1) we will never reassoc to the current
8056 * AP in LFR, and 2) there is no need to issue a
8057 * disassoc to the AP with which we were trying
8058 * to reassoc.
8059 */
8060 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8061 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008062 }
8063 }
8064#endif
8065 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8066 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8067 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8068 //The disassoc rsp message will remove the command from active list
8069 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8070 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8071 {
8072 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8073 }
8074 }
8075}
8076
Jeff Johnson295189b2012-06-20 16:38:30 -07008077static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8078{
Jeff Johnson295189b2012-06-20 16:38:30 -07008079#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8080 {
8081 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8083 if(pIbssLog)
8084 {
8085 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8086 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8087 {
8088 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8089 }
8090 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8091 }
8092 }
8093#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008094 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8095 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8096 {
8097 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8098 }
8099 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8100 {
8101 csrRoamReissueRoamCommand(pMac);
8102 }
8103}
8104
Jeff Johnson295189b2012-06-20 16:38:30 -07008105void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8106{
8107 tSirResultCodes statusCode;
8108#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8109 tScanResultHandle hBSSList;
8110 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8111 eHalStatus status;
8112 tCsrRoamInfo roamInfo;
8113 tCsrScanResultFilter *pScanFilter = NULL;
8114 tANI_U32 roamId = 0;
8115 tCsrRoamProfile *pCurRoamProfile = NULL;
8116 tListElem *pEntry = NULL;
8117 tSmeCmd *pCommand = NULL;
8118#endif
8119 tANI_U32 sessionId;
8120 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07008121
Jeff Johnson295189b2012-06-20 16:38:30 -07008122 tSirSmeDisassocRsp SmeDisassocRsp;
8123
8124 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8125 sessionId = SmeDisassocRsp.sessionId;
8126 statusCode = SmeDisassocRsp.statusCode;
8127
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008128 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008129
8130 if ( csrIsConnStateInfra( pMac, sessionId ) )
8131 {
8132 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8133 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008134 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008135
8136 if(!pSession)
8137 {
8138 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8139 return;
8140 }
8141
Jeff Johnson295189b2012-06-20 16:38:30 -07008142 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8143 {
8144 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8145 }
8146 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8147 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8148 {
8149 if ( eSIR_SME_SUCCESS == statusCode )
8150 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008151 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008152 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8153 }
8154 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008156 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8157 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308158 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8159 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008160#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008161 /*
8162 * First ensure if the roam profile is in the scan cache.
8163 * If not, post a reassoc failure and disconnect.
8164 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308165 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8166 if ( NULL == pScanFilter )
8167 status = eHAL_STATUS_FAILURE;
8168 else
8169 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008170 if(HAL_STATUS_SUCCESS(status))
8171 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308172 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008173 status = csrRoamPrepareFilterFromProfile(pMac,
8174 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8175 if(!HAL_STATUS_SUCCESS(status))
8176 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008177 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008178 __func__, status);
8179 goto POST_ROAM_FAILURE;
8180 }
8181 else
8182 {
8183 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8184 if (!HAL_STATUS_SUCCESS(status))
8185 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008186 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008187 __func__, status);
8188 goto POST_ROAM_FAILURE;
8189 }
8190 }
8191 }
8192 else
8193 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008194 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008195 __func__, status);
8196 goto POST_ROAM_FAILURE;
8197 }
8198
8199 /*
8200 * After ensuring that the roam profile is in the scan result list,
8201 * dequeue the command from the active list.
8202 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008203 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8204 if ( pEntry )
8205 {
8206 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008207 /* If the head of the queue is Active and it is a ROAM command, remove
8208 * and put this on the Free queue.
8209 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008210 if ( eSmeCommandRoam == pCommand->command )
8211 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008212
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008213 /*
8214 * we need to process the result first before removing it from active list
8215 * because state changes still happening insides roamQProcessRoamResults so
8216 * no other roam command should be issued.
8217 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008218 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8219 if(pCommand->u.roamCmd.fReleaseProfile)
8220 {
8221 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8222 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8223 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008224 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008225 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008226 else
8227 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008228 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008229 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008230 }
8231 }
8232 else
8233 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008234 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008235 }
8236 }
8237 else
8238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008239 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008240 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008241
8242 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8244
Kiet Lam64c1b492013-07-12 13:56:44 +05308245 vos_mem_copy(roamInfo.bssid,
8246 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8247 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008248
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008249 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8250 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008251
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008252 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308253 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8254 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008255 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308256 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008257 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8258 //make sure to put it at the head of the cmd queue
8259 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8260 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8261 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8262
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 if(!HAL_STATUS_SUCCESS(status))
8264 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008265 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008266 __func__, status);
8267 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 }
8269
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008270 /* Notify sub-modules like QoS etc. that handoff happening */
8271 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008272 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308273 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008274 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308275 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008276 return;
8277 }
8278
8279POST_ROAM_FAILURE:
8280 if (pScanFilter)
8281 {
8282 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308283 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008284 }
8285 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308286 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008287
8288 /* Inform the upper layers that the reassoc failed */
8289 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8290 csrRoamCallCallback(pMac, sessionId,
8291 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8292
8293 /*
8294 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8295 * Upon success, we would re-enter this routine after receiving the disassoc
8296 * response and will fall into the reassoc fail sub-state. And, eventually
8297 * call csrRoamComplete which would remove the roam command from SME active
8298 * queue.
8299 */
8300 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8301 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8302 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008303 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008304 __func__, status);
8305 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008307#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008308
Jeff Johnson295189b2012-06-20 16:38:30 -07008309 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8310 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8311 {
8312 // Disassoc due to Reassoc failure falls into this codepath....
8313 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8314 }
8315 else
8316 {
8317 if ( eSIR_SME_SUCCESS == statusCode )
8318 {
8319 // Successfully disassociated from the 'old' Bss...
8320 //
8321 // We get Disassociate response in three conditions.
8322 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8323 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8324 // Infrastructure network.
8325 // - Third is where we are doing an Infra to Infra roam between networks with different
8326 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8327
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008328 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008329 }
8330 else
8331 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008332 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008333 }
8334 //We are not done yet. Get the data and continue roaming
8335 csrRoamReissueRoamCommand(pMac);
8336 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008337}
8338
Jeff Johnson295189b2012-06-20 16:38:30 -07008339static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8340{
8341 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008342 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008343 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008344 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008345 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008346 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8347 {
8348 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8349 }
8350 else
8351 {
8352 if ( eSIR_SME_SUCCESS == statusCode )
8353 {
8354 // Successfully deauth from the 'old' Bss...
8355 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008356 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008357 }
8358 else
8359 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008360 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008361 }
8362 //We are not done yet. Get the data and continue roaming
8363 csrRoamReissueRoamCommand(pMac);
8364 }
8365}
8366
Jeff Johnson295189b2012-06-20 16:38:30 -07008367static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8368{
8369 eCsrRoamCompleteResult result;
8370
8371 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8372 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008373 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008374 result = eCsrStartBssSuccess;
8375 }
8376 else
8377 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008378 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008379 //Let csrRoamComplete decide what to do
8380 result = eCsrStartBssFailure;
8381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008382 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008383}
8384
Jeff Johnson295189b2012-06-20 16:38:30 -07008385/*
8386 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8387 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8388 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8389 For the messages where sender allocates memory for specific structures, then it can be
8390 cast accordingly.
8391*/
8392void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8393{
8394 tSirSmeRsp *pSmeRsp;
8395 tSmeIbssPeerInd *pIbssPeerInd;
8396 tCsrRoamInfo roamInfo;
8397 // TODO Session Id need to be acquired in this function
8398 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008399 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308400 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8401 pSmeRsp->messageType, pSmeRsp->messageType,
8402 macTraceGetcsrRoamSubState(
8403 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008404 pSmeRsp->messageType = (pSmeRsp->messageType);
8405 pSmeRsp->length = (pSmeRsp->length);
8406 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008407 switch (pSmeRsp->messageType)
8408 {
8409
8410 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8411 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8412 {
8413 //We sent a JOIN_REQ
8414 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8415 }
8416 break;
8417
8418 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8419 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8420 {
8421 //We sent a AUTH_REQ
8422 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8423 }
8424 break;
8425
8426 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8427 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8428 {
8429 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8430 }
8431 break;
8432
8433 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8434 {
8435 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8436 }
8437 break;
8438
8439 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8440 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8441 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8442 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8443 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8444 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8445//HO
8446 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8447 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308448 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8449 macTraceGetcsrRoamSubState(
8450 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05308452#ifdef DEBUG_ROAM_DELAY
8453 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8454#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008455 }
8456 break;
8457
8458 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8459 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8460 {
8461 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8462 }
8463 break;
8464
8465 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8466 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8467 {
8468 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8469 }
8470 break;
8471
8472 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8473 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8474 {
8475 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8476 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008477 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008478 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8479 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8480 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008481 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308482 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8483 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008484 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8485 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308486 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8487 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008488 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8489 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8490 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8491 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008492 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308493 smsLog(pMac, LOG1,
8494 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8495 pSmeRsp->messageType, pSmeRsp->messageType,
8496 macTraceGetcsrRoamSubState(
8497 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008498
8499 //If we are connected, check the link status change
8500 if(!csrIsConnStateDisconnected(pMac, sessionId))
8501 {
8502 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8503 }
8504 break;
8505 }
8506}
8507
Jeff Johnson295189b2012-06-20 16:38:30 -07008508void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8509{
8510 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 switch (pSirMsg->messageType)
8512 {
8513 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008514 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008515 csrRoamStatsRspProcessor( pMac, pSirMsg );
8516 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008517 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8518 {
8519 tCsrRoamSession *pSession;
8520 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8521 tCsrRoamInfo roamInfo;
8522 tCsrRoamInfo *pRoamInfo = NULL;
8523 tANI_U32 sessionId;
8524 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008525 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308526 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008527 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008528 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8529 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8530 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008531
8532 if(!pSession)
8533 {
8534 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8535 return;
8536 }
8537
Jeff Johnson295189b2012-06-20 16:38:30 -07008538 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8539 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8541 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8542 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008543 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8544 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308545 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8546 sizeof(tSirMacAddr));
8547 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8548 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008549 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05308550#ifdef WLAN_FEATURE_AP_HT40_24G
8551 pRoamInfo->HT40MHzIntoEnabledSta =
8552 pUpperLayerAssocCnf->HT40MHzIntoEnabledSta;
8553 smsLog( pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
8554 pRoamInfo->HT40MHzIntoEnabledSta);
8555#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008556 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8557 {
8558 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8559 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8560 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8561 }
8562 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8563 {
8564 vos_sleep( 100 );
8565 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8566 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8567 }
8568
Jeff Johnson295189b2012-06-20 16:38:30 -07008569 }
8570 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008571 default:
8572 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8573 break;
8574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008575}
8576
Jeff Johnson295189b2012-06-20 16:38:30 -07008577eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8578 tSirBssDescription *pBssDescription,
8579 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8580 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8581 tANI_U8 keyId, tANI_U16 keyLength,
8582 tANI_U8 *pKey, tANI_U8 paeRole )
8583{
8584 eHalStatus status = eHAL_STATUS_SUCCESS;
8585 tAniEdType edType;
8586
8587 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8588 {
8589 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8590 }
8591
8592 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8593
8594 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8595 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8596 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8597 addKey )
8598 {
8599 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008600 setKey.encType = EncryptType;
8601 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308602 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008603 setKey.paeRole = paeRole; //0 for supplicant
8604 setKey.keyId = keyId; // Kye index
8605 setKey.keyLength = keyLength;
8606 if( keyLength )
8607 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308608 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 }
8610 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008612 return (status);
8613}
8614
Jeff Johnson295189b2012-06-20 16:38:30 -07008615static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8616 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8617{
8618 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8619 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008620#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008621 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008622#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008623
8624 do
8625 {
8626 pCommand = csrGetCommandBuffer(pMac);
8627 if(NULL == pCommand)
8628 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008629 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008630 status = eHAL_STATUS_RESOURCES;
8631 break;
8632 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05308633 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07008634 pCommand->command = eSmeCommandSetKey;
8635 pCommand->sessionId = (tANI_U8)sessionId;
8636 // validate the key length, Adjust if too long...
8637 // for static WEP the keys are not set thru' SetContextReq
8638 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8639 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8640 {
8641 //KeyLength maybe 0 for static WEP
8642 if( pSetKey->keyLength )
8643 {
8644 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8645 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008646 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008647 break;
8648 }
8649
8650 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308651 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8652 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008653 }
8654 }
8655 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8656 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8657 {
8658 //KeyLength maybe 0 for static WEP
8659 if( pSetKey->keyLength )
8660 {
8661 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8662 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008663 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008664 break;
8665 }
8666
8667 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308668 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8669 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008670 }
8671 }
8672 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8673 {
8674 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8675 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008676 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008677 break;
8678 }
8679 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308680 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8681 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008682 }
8683 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8684 {
8685 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8686 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008687 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008688 break;
8689 }
8690 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308691 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8692 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008693 }
8694#ifdef FEATURE_WLAN_WAPI
8695 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8696 {
8697 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8698 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008699 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008700 break;
8701 }
8702 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308703 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8704 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008705 }
8706#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008707#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008708 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8709 {
8710 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8711 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008712 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008713 break;
8714 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008715 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308716 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008717 pSession->eseCckmInfo.reassoc_req_num=1;
8718 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008719 status = eHAL_STATUS_SUCCESS;
8720 break;
8721 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008722#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008723
Jeff Johnson295189b2012-06-20 16:38:30 -07008724#ifdef WLAN_FEATURE_11W
8725 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008726 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008727 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008728 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008729 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008730 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008731 break;
8732 }
8733 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308734 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008735 }
8736#endif
8737 status = eHAL_STATUS_SUCCESS;
8738 pCommand->u.setKeyCmd.roamId = roamId;
8739 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8740 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308741 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8742 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008743 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8744 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308745 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 //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
8747
8748 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8749 if( !HAL_STATUS_SUCCESS( status ) )
8750 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008751 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008752 }
8753 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008754 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008755 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008756 if ( ( NULL != pCommand ) &&
8757 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008758#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008759 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008760#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008761 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008762 {
8763 csrReleaseCommandSetKey( pMac, pCommand );
8764 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008765 return( status );
8766}
8767
Jeff Johnson295189b2012-06-20 16:38:30 -07008768eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8769 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8770{
8771 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8772 tSmeCmd *pCommand = NULL;
8773 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008774 do
8775 {
8776 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008778 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008779 status = eHAL_STATUS_CSR_WRONG_STATE;
8780 break;
8781 }
8782 pCommand = csrGetCommandBuffer(pMac);
8783 if(NULL == pCommand)
8784 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008785 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 status = eHAL_STATUS_RESOURCES;
8787 break;
8788 }
8789 pCommand->command = eSmeCommandRemoveKey;
8790 pCommand->sessionId = (tANI_U8)sessionId;
8791 pCommand->u.removeKeyCmd.roamId = roamId;
8792 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308793 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8794 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008795 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8796 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8797 {
8798 //in this case, put it to the end of the Q incase there is a set key pending.
8799 fImediate = eANI_BOOLEAN_FALSE;
8800 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008801 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008802 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008803 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008804 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8805 if( !HAL_STATUS_SUCCESS( status ) )
8806 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008807 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008808 break;
8809 }
8810 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008811 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8812 {
8813 csrReleaseCommandRemoveKey( pMac, pCommand );
8814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008815 return (status );
8816}
8817
Jeff Johnson295189b2012-06-20 16:38:30 -07008818eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8819{
8820 eHalStatus status;
8821 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8822 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8823 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8824 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008825#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8826 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8827 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308828 if(!pSession)
8829 {
8830 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8831 return eHAL_STATUS_FAILURE;
8832 }
lukez3c809222013-05-03 10:23:02 -07008833 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008834 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308835 vos_mem_set(&setKeyEvent,
8836 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008837 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8838 {
8839 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8840 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8841 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8842 }
8843 else
8844 {
8845 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8846 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8847 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8848 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308849 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008850 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008851 {
8852 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008853 //It has to be static WEP here
8854 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8855 {
8856 setKeyEvent.keyId = (v_U8_t)defKeyId;
8857 }
8858 }
8859 else
8860 {
8861 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8862 }
8863 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8864 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8865 }
8866#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008867 if( csrIsSetKeyAllowed(pMac, sessionId) )
8868 {
8869 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8870 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8871 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8872 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8873 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8874 pCommand->u.setKeyCmd.keyRsc);
8875 }
8876 else
8877 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008878 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 //Set this status so the error handling take care of the case.
8880 status = eHAL_STATUS_CSR_WRONG_STATE;
8881 }
8882 if( !HAL_STATUS_SUCCESS(status) )
8883 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008884 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008885 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008886#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008887 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008888 {
8889 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8890 {
8891 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8892 }
8893 else
8894 {
8895 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8896 }
8897 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8898 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8899 }
8900#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008901 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008902 return ( status );
8903}
8904
Jeff Johnson295189b2012-06-20 16:38:30 -07008905eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8906{
8907 eHalStatus status;
8908 tpSirSmeRemoveKeyReq pMsg = NULL;
8909 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8910 tANI_U8 *p;
8911 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008912#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8913 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8914 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308915 if(!pSession)
8916 {
8917 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8918 return eHAL_STATUS_FAILURE;
8919 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308920 vos_mem_set(&removeKeyEvent,
8921 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008922 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8923 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8924 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308925 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008926 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8927 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8928 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8929#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 if( csrIsSetKeyAllowed(pMac, sessionId) )
8931 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308932 pMsg = vos_mem_malloc(wMsgLen);
8933 if ( NULL == pMsg )
8934 status = eHAL_STATUS_FAILURE;
8935 else
8936 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008937 }
8938 else
8939 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008940 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008941 //Set the error status so error handling kicks in below
8942 status = eHAL_STATUS_CSR_WRONG_STATE;
8943 }
8944 if( HAL_STATUS_SUCCESS( status ) )
8945 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308946 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008947 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8948 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008949 pMsg->sessionId = (tANI_U8)sessionId;
8950 pMsg->transactionId = 0;
8951 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8952 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8953 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308954 vos_mem_copy(p,
8955 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8956 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008957 p += sizeof(tSirMacAddr);
8958 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308959 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008960 p += sizeof(tSirMacAddr);
8961 // edType
8962 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8963 p++;
8964 // weptype
8965 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8966 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8967 {
8968 *p = (tANI_U8)eSIR_WEP_STATIC;
8969 }
8970 else
8971 {
8972 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8973 }
8974 p++;
8975 //keyid
8976 *p = pCommand->u.removeKeyCmd.keyId;
8977 p++;
8978 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008979 status = palSendMBMessage(pMac->hHdd, pMsg);
8980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008981 if( !HAL_STATUS_SUCCESS( status ) )
8982 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008983 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008984#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8985 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008986 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008987 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8988#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008989 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8990 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008991 return ( status );
8992}
8993
Jeff Johnson295189b2012-06-20 16:38:30 -07008994eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8995{
8996 eHalStatus status;
8997
8998 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8999 {
9000 status = eHAL_STATUS_CSR_WRONG_STATE;
9001 }
9002 else
9003 {
9004 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
9005 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009006 return ( status );
9007}
9008
Jeff Johnson295189b2012-06-20 16:38:30 -07009009/*
9010 Prepare a filter base on a profile for parsing the scan results.
9011 Upon successful return, caller MUST call csrFreeScanFilter on
9012 pScanFilter when it is done with the filter.
9013*/
9014eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9015 tCsrScanResultFilter *pScanFilter)
9016{
9017 eHalStatus status = eHAL_STATUS_SUCCESS;
9018 tANI_U32 size = 0;
9019 tANI_U8 index = 0;
9020
9021 do
9022 {
9023 if(pProfile->BSSIDs.numOfBSSIDs)
9024 {
9025 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309026 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
9027 if ( NULL == pScanFilter->BSSIDs.bssid )
9028 status = eHAL_STATUS_FAILURE;
9029 else
9030 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009031 if(!HAL_STATUS_SUCCESS(status))
9032 {
9033 break;
9034 }
9035 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309036 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009037 }
9038 if(pProfile->SSIDs.numOfSSIDs)
9039 {
9040 if( !CSR_IS_WDS_STA( pProfile ) )
9041 {
9042 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
9043 }
9044 else
9045 {
9046 //For WDS station
9047 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
9048 pScanFilter->SSIDs.numOfSSIDs = 1;
9049 }
9050 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309051 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9052 if ( NULL == pScanFilter->SSIDs.SSIDList )
9053 status = eHAL_STATUS_FAILURE;
9054 else
9055 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009056 if(!HAL_STATUS_SUCCESS(status))
9057 {
9058 break;
9059 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309060 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9061 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009062 }
9063 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9064 {
9065 pScanFilter->ChannelInfo.numOfChannels = 0;
9066 pScanFilter->ChannelInfo.ChannelList = NULL;
9067 }
9068 else if(pProfile->ChannelInfo.numOfChannels)
9069 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309070 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9071 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9072 pProfile->ChannelInfo.numOfChannels);
9073 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9074 status = eHAL_STATUS_FAILURE;
9075 else
9076 status = eHAL_STATUS_SUCCESS;
9077
Jeff Johnson295189b2012-06-20 16:38:30 -07009078 pScanFilter->ChannelInfo.numOfChannels = 0;
9079 if(HAL_STATUS_SUCCESS(status))
9080 {
9081 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9082 {
9083 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9084 {
9085 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9086 = pProfile->ChannelInfo.ChannelList[index];
9087 pScanFilter->ChannelInfo.numOfChannels++;
9088 }
9089 else
9090 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009091 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009093 }
9094 }
9095 else
9096 {
9097 break;
9098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009099 }
9100 else
9101 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309102 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009103 status = eHAL_STATUS_FAILURE;
9104 break;
9105 }
9106 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
9107 pScanFilter->authType = pProfile->AuthType;
9108 pScanFilter->EncryptionType = pProfile->EncryptionType;
9109 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9110 pScanFilter->BSSType = pProfile->BSSType;
9111 pScanFilter->phyMode = pProfile->phyMode;
9112#ifdef FEATURE_WLAN_WAPI
9113 //check if user asked for WAPI with 11n or auto mode, in that case modify
9114 //the phymode to 11g
9115 if(csrIsProfileWapi(pProfile))
9116 {
9117 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9118 {
9119 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9120 }
9121 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9122 {
9123 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9124 }
9125 if(!pScanFilter->phyMode)
9126 {
9127 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9128 }
9129 }
9130#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009131 /*Save the WPS info*/
9132 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009133 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009134 if( pProfile->countryCode[0] )
9135 {
9136 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309137 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9138 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009139 }
9140#ifdef WLAN_FEATURE_VOWIFI_11R
9141 if (pProfile->MDID.mdiePresent)
9142 {
9143 pScanFilter->MDID.mdiePresent = 1;
9144 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9145 }
9146#endif
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309147
9148#ifdef WLAN_FEATURE_11W
9149 // Management Frame Protection
9150 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9151 pScanFilter->MFPRequired = pProfile->MFPRequired;
9152 pScanFilter->MFPCapable = pProfile->MFPCapable;
9153#endif
9154
Jeff Johnson295189b2012-06-20 16:38:30 -07009155 }while(0);
9156
9157 if(!HAL_STATUS_SUCCESS(status))
9158 {
9159 csrFreeScanFilter(pMac, pScanFilter);
9160 }
9161
9162 return(status);
9163}
9164
Jeff Johnson295189b2012-06-20 16:38:30 -07009165tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9166 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9167{
9168 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9169 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009170 do
9171 {
9172 // Validate the type is ok...
9173 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9174 pCommand = csrGetCommandBuffer( pMac );
9175 if ( !pCommand )
9176 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009177 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009178 break;
9179 }
9180 //Change the substate in case it is waiting for key
9181 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9182 {
9183 csrRoamStopWaitForKeyTimer( pMac );
9184 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9185 }
9186 pCommand->command = eSmeCommandWmStatusChange;
9187 pCommand->sessionId = (tANI_U8)sessionId;
9188 pCommand->u.wmStatusChangeCmd.Type = Type;
9189 if ( eCsrDisassociated == Type )
9190 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309191 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9192 pSmeRsp,
9193 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009194 }
9195 else
9196 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309197 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9198 pSmeRsp,
9199 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009200 }
9201 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9202 {
9203 fCommandQueued = eANI_BOOLEAN_TRUE;
9204 }
9205 else
9206 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009207 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009208 csrReleaseCommandWmStatusChange( pMac, pCommand );
9209 }
9210
Jeff Johnson295189b2012-06-20 16:38:30 -07009211 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9212 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009213 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009214 return( fCommandQueued );
9215}
9216
Jeff Johnson295189b2012-06-20 16:38:30 -07009217static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9218{
9219 v_S7_t rssi = 0;
9220 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9221 if(pGetRssiReq)
9222 {
9223 if(NULL != pGetRssiReq->pVosContext)
9224 {
9225 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9226 }
9227 else
9228 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009229 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009230 return;
9231 }
9232
9233 if(NULL != pGetRssiReq->rssiCallback)
9234 {
9235 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9236 }
9237 else
9238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009239 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009240 return;
9241 }
9242 }
9243 else
9244 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009245 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009246 }
9247 return;
9248}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309249
9250static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9251{
9252 tANI_S8 snr = 0;
9253 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9254
9255 if (pGetSnrReq)
9256 {
9257 if (VOS_STATUS_SUCCESS !=
9258 WDA_GetSnr(pGetSnrReq->staId, &snr))
9259 {
9260 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9261 return;
9262 }
9263
9264 if (pGetSnrReq->snrCallback)
9265 {
9266 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9267 pGetSnrReq->pDevContext);
9268 }
9269 else
9270 {
9271 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9272 return;
9273 }
9274 }
9275 else
9276 {
9277 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9278 }
9279 return;
9280}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009281#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009282void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9283{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009284 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9285
Jeff Johnson36d483b2013-04-08 11:08:53 -07009286 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009287 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009288 /* Get roam Rssi request is backed up and passed back to the response,
9289 Extract the request message to fetch callback */
9290 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9291 v_S7_t rssi = pRoamRssiRsp->rssi;
9292
9293 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009294 {
9295 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9296 reqBkp->rssiCallback = NULL;
9297 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009298 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009299 }
9300 else
9301 {
9302 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9303 if (NULL != reqBkp)
9304 {
9305 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009306 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009307 }
9308 }
9309 }
9310 else
9311 {
9312 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9313 }
9314 return;
9315}
9316#endif
9317
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009318
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009319#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009320void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9321{
9322 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9323
9324 if (NULL != pTsmStatsRsp)
9325 {
9326 /* Get roam Rssi request is backed up and passed back to the response,
9327 Extract the request message to fetch callback */
9328 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9329
9330 if (NULL != reqBkp)
9331 {
9332 if (NULL != reqBkp->tsmStatsCallback)
9333 {
9334 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9335 pTsmStatsRsp->staId, reqBkp->pDevContext);
9336 reqBkp->tsmStatsCallback = NULL;
9337 }
9338 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009339 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009340 }
9341 else
9342 {
9343 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9344 if (NULL != reqBkp)
9345 {
9346 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009347 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009348 }
9349 }
9350 }
9351 else
9352 {
9353 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9354 }
9355 return;
9356}
9357
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009358void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009359{
9360 tANI_U32 roamTS2 = 0;
9361 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009362 tpPESession pSessionEntry = NULL;
9363 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009364
9365 if (NULL == pSession)
9366 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009367 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009368 return;
9369 }
9370
9371 roamTS2 = vos_timer_get_system_time();
9372 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009373 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9374 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009375 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009376
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009377 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9378 if (NULL == pSessionEntry)
9379 {
9380 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9381 return;
9382 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009383 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009384 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009385 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009386}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009387#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009388
Jeff Johnsone7245742012-09-05 17:12:55 -07009389static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9390{
9391 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9392 if(pTlRssiInd)
9393 {
9394 if(NULL != pTlRssiInd->tlCallback)
9395 {
9396 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009397 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009398 }
9399 else
9400 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009401 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009402 }
9403 }
9404 else
9405 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009406 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009407 }
9408 return;
9409}
Jeff Johnson295189b2012-06-20 16:38:30 -07009410
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309411eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9412{
9413 tpSirResetAPCapsChange pMsg;
9414 tANI_U16 len;
9415 eHalStatus status = eHAL_STATUS_SUCCESS;
9416
9417 /* Create the message and send to lim */
9418 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309419 pMsg = vos_mem_malloc(len);
9420 if ( NULL == pMsg )
9421 status = eHAL_STATUS_FAILURE;
9422 else
9423 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309424 if (HAL_STATUS_SUCCESS(status))
9425 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309426 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309427 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9428 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309429 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009430 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9431 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309432 status = palSendMBMessage(pMac->hHdd, pMsg);
9433 }
9434 else
9435 {
9436 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9437 }
9438 return status;
9439}
9440
Jeff Johnson295189b2012-06-20 16:38:30 -07009441void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9442{
9443 tSirSmeAssocInd *pAssocInd;
9444 tSirSmeDisassocInd *pDisassocInd;
9445 tSirSmeDeauthInd *pDeauthInd;
9446 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9447 tSirSmeNewBssInfo *pNewBss;
9448 tSmeIbssPeerInd *pIbssPeerInd;
9449 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9450 tSirSmeApNewCaps *pApNewCaps;
9451 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9452 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9453 tCsrRoamInfo *pRoamInfo = NULL;
9454 tCsrRoamInfo roamInfo;
9455 eHalStatus status;
9456 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9457 tCsrRoamSession *pSession = NULL;
9458 tpSirSmeSwitchChannelInd pSwitchChnInd;
9459 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309460 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009461
9462
9463 if (NULL == pSirMsg)
9464 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9465 return;
9466 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 switch( pSirMsg->messageType )
9468 {
9469 case eWNI_SME_ASSOC_IND:
9470 {
9471 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009472 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009473 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9474 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9475 if( HAL_STATUS_SUCCESS( status ) )
9476 {
9477 pSession = CSR_GET_SESSION(pMac, sessionId);
9478
Jeff Johnson32d95a32012-09-10 13:15:23 -07009479 if(!pSession)
9480 {
9481 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9482 return;
9483 }
9484
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 pRoamInfo = &roamInfo;
9486
9487 // Required for indicating the frames to upper layer
9488 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9489 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9490
9491 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9492 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9493 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9494 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9495
9496 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9497 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9498 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9499
9500 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9501 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309502 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9503 sizeof(tSirMacAddr));
9504 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9505 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009506 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05309507#ifdef WLAN_FEATURE_AP_HT40_24G
9508 pRoamInfo->HT40MHzIntoEnabledSta =
9509 pAssocInd->HT40MHzIntoEnabledSta;
9510 smsLog(pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
9511 pRoamInfo->HT40MHzIntoEnabledSta);
9512#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009513 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009514 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009515 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9516 {
9517 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9518 {
9519 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9520 pSession->pConnectBssDesc,
9521 &(pRoamInfo->peerMac),
9522 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9523 pRoamInfo->fAuthRequired = FALSE;
9524 }
9525 else
9526 {
9527 pRoamInfo->fAuthRequired = TRUE;
9528 }
9529 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9530 if (!HAL_STATUS_SUCCESS(status))
9531 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009533 /* Send Association completion message to PE */
9534 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9535
9536 /* send a message to CSR itself just to avoid the EAPOL frames going
9537 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009538 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9539 {
9540 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009542 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9543 {
9544 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9545 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9546 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009548 }
9549 }
9550 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009551 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009552 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309553 // Check if AP dis-associated us because of MIC failure. If so,
9554 // then we need to take action immediately and not wait till the
9555 // the WmStatusChange requests is pushed and processed
9556 tSmeCmd *pCommand;
9557
9558 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9559 status = csrRoamGetSessionIdFromBSSID( pMac,
9560 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9561 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009562 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309563 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9564 " for session %d "), sessionId);
9565 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9566 MAC_ADDRESS_STR " "
9567 " reason = %d status = %d "),
9568 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9569 pDisassocInd->reasonCode,
9570 pDisassocInd->statusCode);
9571 // If we are in neighbor preauth done state then on receiving
9572 // disassoc or deauth we dont roam instead we just disassoc
9573 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009574 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309575#ifdef WLAN_FEATURE_VOWIFI_11R
9576 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9577 {
9578 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009580#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009581#ifdef FEATURE_WLAN_ESE
9582 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309583 {
9584 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9585 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009586#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009587#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309588 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9589 {
9590 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9591 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009592#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309593 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009594
Agarwal Ashish4f616132013-12-30 23:32:50 +05309595 if (!pSession)
9596 {
9597 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9598 return;
9599 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009600
Agarwal Ashish4f616132013-12-30 23:32:50 +05309601 if ( csrIsConnStateInfra( pMac, sessionId ) )
9602 {
9603 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009605#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309606 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009607#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309608 csrRoamLinkDown(pMac, sessionId);
9609 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9610 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9611 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309612 pRoamInfo = &roamInfo;
9613 pRoamInfo->statusCode = pDisassocInd->statusCode;
9614 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9615 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009616
Agarwal Ashish4f616132013-12-30 23:32:50 +05309617 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9618 sizeof(tSirMacAddr));
9619 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9620 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009621
Agarwal Ashish4f616132013-12-30 23:32:50 +05309622 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9623 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009624
Agarwal Ashish4f616132013-12-30 23:32:50 +05309625 /*
9626 * STA/P2P client got disassociated so remove any pending deauth
9627 * commands in sme pending list
9628 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309629 pCommand = csrGetCommandBuffer(pMac);
9630 if (NULL == pCommand)
9631 {
9632 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9633 status = eHAL_STATUS_RESOURCES;
9634 return;
9635 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309636 pCommand->command = eSmeCommandRoam;
9637 pCommand->sessionId = (tANI_U8)sessionId;
9638 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9639 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9640 pDisassocInd->peerMacAddr,
9641 sizeof(tSirMacAddr));
9642 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9643 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009644
Agarwal Ashish4f616132013-12-30 23:32:50 +05309645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009646 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309647 else
9648 {
9649 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9650 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9651 }
Kiet Lam82004c62013-11-11 13:24:28 +05309652 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009653 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009654 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009655 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009656 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9657 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9658 if( HAL_STATUS_SUCCESS( status ) )
9659 {
9660 // If we are in neighbor preauth done state then on receiving
9661 // disassoc or deauth we dont roam instead we just disassoc
9662 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009663 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009664#ifdef WLAN_FEATURE_VOWIFI_11R
9665 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9666 {
9667 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9668 }
9669#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009670#ifdef FEATURE_WLAN_ESE
9671 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 {
9673 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9674 }
9675#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009676#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309677 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009678 {
9679 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9680 }
9681#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009682 pSession = CSR_GET_SESSION( pMac, sessionId );
9683
Jeff Johnson32d95a32012-09-10 13:15:23 -07009684 if(!pSession)
9685 {
9686 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9687 return;
9688 }
9689
Jeff Johnson295189b2012-06-20 16:38:30 -07009690 if ( csrIsConnStateInfra( pMac, sessionId ) )
9691 {
9692 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9693 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009694#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9695 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9696#endif
9697 csrRoamLinkDown(pMac, sessionId);
9698 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009699 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9700 {
9701
9702 pRoamInfo = &roamInfo;
9703
9704 pRoamInfo->statusCode = pDeauthInd->statusCode;
9705 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9706
9707 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9708
Kiet Lam64c1b492013-07-12 13:56:44 +05309709 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9710 sizeof(tSirMacAddr));
9711 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9712 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009713
9714 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9715 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009716 }
9717 break;
9718
9719 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 -08009720 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009721 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9722 //Update with the new channel id.
9723 //The channel id is hidden in the statusCode.
9724 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9725 if( HAL_STATUS_SUCCESS( status ) )
9726 {
9727 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009728 if(!pSession)
9729 {
9730 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9731 return;
9732 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009733 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9734 if(pSession->pConnectBssDesc)
9735 {
9736 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9737 }
9738 }
9739 break;
9740
9741 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009742 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009743 {
9744 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9745 sessionId = pDeauthRsp->sessionId;
9746 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9747 {
9748 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009749 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9750 {
9751 pRoamInfo = &roamInfo;
9752 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309753 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9754 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009755 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9756 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9757 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9758 }
9759 }
9760 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009761 break;
9762
9763 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009764 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009765 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009766 {
9767 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9768 sessionId = pDisassocRsp->sessionId;
9769 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9770 {
9771 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009772 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9773 {
9774 pRoamInfo = &roamInfo;
9775 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309776 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9777 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009778 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9779 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9780 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9781 }
9782 }
9783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009784 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009785 case eWNI_SME_MIC_FAILURE_IND:
9786 {
9787 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9788 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9789 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009790
9791 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9792 if( HAL_STATUS_SUCCESS( status ) )
9793 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309794 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009795 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9796 pRoamInfo = &roamInfo;
9797 if(pMicInd->info.multicast)
9798 {
9799 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9800 }
9801 else
9802 {
9803 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9804 }
9805 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9806 }
9807
Jeff Johnson295189b2012-06-20 16:38:30 -07009808#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9809 {
lukez3c809222013-05-03 10:23:02 -07009810 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009811 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009812 if(!pSession)
9813 {
9814 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9815 return;
9816 }
lukez3c809222013-05-03 10:23:02 -07009817
Kiet Lam64c1b492013-07-12 13:56:44 +05309818 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009819 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9820 secEvent.encryptionModeMulticast =
9821 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9822 secEvent.encryptionModeUnicast =
9823 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9824 secEvent.authMode =
9825 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309826 vos_mem_copy(secEvent.bssid,
9827 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009828 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9829 }
9830#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009831 }
9832 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009833 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9834 {
9835 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9836 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009837 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009838
9839 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9840 if( HAL_STATUS_SUCCESS( status ) )
9841 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309842 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009843 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9844 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9845 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9846 }
9847 }
9848 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009849
Jeff Johnson295189b2012-06-20 16:38:30 -07009850 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9851 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9852 switch( pStatusChangeMsg->statusChangeCode )
9853 {
9854 case eSIR_SME_IBSS_ACTIVE:
9855 sessionId = csrFindIbssSession( pMac );
9856 if( CSR_SESSION_ID_INVALID != sessionId )
9857 {
9858 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009859 if(!pSession)
9860 {
9861 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9862 return;
9863 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009864 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9865 if(pSession->pConnectBssDesc)
9866 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309867 vos_mem_copy(&roamInfo.bssid,
9868 pSession->pConnectBssDesc->bssId,
9869 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009870 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9871 pRoamInfo = &roamInfo;
9872 }
9873 else
9874 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009875 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009876 }
9877 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9878 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9879 }
9880 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009881 case eSIR_SME_IBSS_INACTIVE:
9882 sessionId = csrFindIbssSession( pMac );
9883 if( CSR_SESSION_ID_INVALID != sessionId )
9884 {
9885 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009886 if(!pSession)
9887 {
9888 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9889 return;
9890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009891 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9892 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9893 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9894 }
9895 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009896 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9897 sessionId = csrFindIbssSession( pMac );
9898 if( CSR_SESSION_ID_INVALID != sessionId )
9899 {
9900 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009901 if(!pSession)
9902 {
9903 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9904 return;
9905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 // update the connection state information
9907 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009908#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9909 {
9910 vos_log_ibss_pkt_type *pIbssLog;
9911 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009912 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9913 if(pIbssLog)
9914 {
9915 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9916 if(pNewBss)
9917 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309918 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009919 if(pNewBss->ssId.length)
9920 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309921 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9922 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009923 }
9924 pIbssLog->operatingChannel = pNewBss->channelNumber;
9925 }
9926 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9927 {
9928 //***U8 is not enough for beacon interval
9929 pIbssLog->beaconInterval = (v_U8_t)bi;
9930 }
9931 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9932 }
9933 }
9934#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009935 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009936
9937 if ((eCSR_ENCRYPT_TYPE_NONE ==
9938 pSession->connectedProfile.EncryptionType ))
9939 {
9940 csrRoamIssueSetContextReq( pMac, sessionId,
9941 pSession->connectedProfile.EncryptionType,
9942 pSession->pConnectBssDesc,
9943 &Broadcastaddr,
9944 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9945 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009946 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9947 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309948 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9949 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009950 pRoamInfo = &roamInfo;
9951 //This BSSID is th ereal BSSID, let's save it
9952 if(pSession->pConnectBssDesc)
9953 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309954 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9955 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009956 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009957 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009958 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009960 // detection by LIM that the capabilities of the associated AP have changed.
9961 case eSIR_SME_AP_CAPS_CHANGED:
9962 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009963 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009964 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9965 if( HAL_STATUS_SUCCESS( status ) )
9966 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009967 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9968 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309969 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009970 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9971 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9972 )
9973 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309974 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9975 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009976 }
9977 else
9978 {
9979 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309980 FL("Skipping csrScanForCapabilityChange as "
9981 "CSR is in state %s and sub-state %s"),
9982 macTraceGetcsrRoamState(
9983 pMac->roam.curState[sessionId]),
9984 macTraceGetcsrRoamSubState(
9985 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309986 /* We ignore the caps change event if CSR is not in full connected state.
9987 * Send one event to PE to reset limSentCapsChangeNtf
9988 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9989 * otherwise lim cannot send any CAPS change events to SME */
9990 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009992 }
9993 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309994
Jeff Johnson295189b2012-06-20 16:38:30 -07009995 default:
9996 roamStatus = eCSR_ROAM_FAILED;
9997 result = eCSR_ROAM_RESULT_NONE;
9998 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009999 } // end switch on statusChangeCode
10000 if(eCSR_ROAM_RESULT_NONE != result)
10001 {
10002 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
10003 }
10004 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010005 case eWNI_SME_IBSS_NEW_PEER_IND:
10006 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070010007#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10008 {
10009 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010010 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10011 if(pIbssLog)
10012 {
10013 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +053010014 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010015 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10016 }
10017 }
10018#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010019 sessionId = csrFindIbssSession( pMac );
10020 if( CSR_SESSION_ID_INVALID != sessionId )
10021 {
10022 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010023
10024 if(!pSession)
10025 {
10026 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10027 return;
10028 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010029 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
10030 if(pSession->pConnectBssDesc)
10031 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010032 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10033 sizeof(tCsrBssid));
10034 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
10035 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010036 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
10037 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010038 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
10039 - sizeof(tSmeIbssPeerInd)));
10040 if ( NULL == roamInfo.pbFrames )
10041 status = eHAL_STATUS_FAILURE;
10042 else
10043 status = eHAL_STATUS_SUCCESS;
10044 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010045 {
10046 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +053010047 vos_mem_copy(roamInfo.pbFrames,
10048 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
10049 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070010050 }
10051 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10052 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10053 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010054 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
10055 if ( NULL == roamInfo.pBssDesc )
10056 status = eHAL_STATUS_FAILURE;
10057 else
10058 status = eHAL_STATUS_SUCCESS;
10059 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010060 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010061 vos_mem_copy(roamInfo.pBssDesc,
10062 pSession->pConnectBssDesc,
10063 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010064 }
10065 if(HAL_STATUS_SUCCESS(status))
10066 {
10067 pRoamInfo = &roamInfo;
10068 }
10069 else
10070 {
10071 if(roamInfo.pbFrames)
10072 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010073 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010074 }
10075 if(roamInfo.pBssDesc)
10076 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010077 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010078 }
10079 }
10080 }
10081 else
10082 {
10083 pRoamInfo = &roamInfo;
10084 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010085 if ((eCSR_ENCRYPT_TYPE_NONE ==
10086 pSession->connectedProfile.EncryptionType ))
10087 {
10088 csrRoamIssueSetContextReq( pMac, sessionId,
10089 pSession->connectedProfile.EncryptionType,
10090 pSession->pConnectBssDesc,
10091 &(pIbssPeerInd->peerAddr),
10092 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10093 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010094 }
10095 else
10096 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010097 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 }
10099 //send up the sec type for the new peer
10100 if (pRoamInfo)
10101 {
10102 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10103 }
10104 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10105 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10106 if(pRoamInfo)
10107 {
10108 if(roamInfo.pbFrames)
10109 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010110 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010111 }
10112 if(roamInfo.pBssDesc)
10113 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010114 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010115 }
10116 }
10117 }
10118 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010119 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10120 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10121 sessionId = csrFindIbssSession( pMac );
10122 if( CSR_SESSION_ID_INVALID != sessionId )
10123 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010124#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10125 {
10126 vos_log_ibss_pkt_type *pIbssLog;
10127
10128 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10129 if(pIbssLog)
10130 {
10131 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10132 if(pIbssPeerInd)
10133 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010134 vos_mem_copy(pIbssLog->peerMacAddr,
10135 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010136 }
10137 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10138 }
10139 }
10140#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010141 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010142 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10143 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10144 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010145 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10146 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010147 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10148 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10149 }
10150 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010151 case eWNI_SME_SETCONTEXT_RSP:
10152 {
10153 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10154 tListElem *pEntry;
10155 tSmeCmd *pCommand;
10156
10157 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10158 if ( pEntry )
10159 {
10160 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10161 if ( eSmeCommandSetKey == pCommand->command )
10162 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010163 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010164 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010165
10166 if(!pSession)
10167 {
10168 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10169 return;
10170 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010171
10172#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10173 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10174 {
10175 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010176 vos_mem_set(&setKeyEvent,
10177 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010178 if( pRsp->peerMacAddr[0] & 0x01 )
10179 {
10180 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
10181 }
10182 else
10183 {
10184 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
10185 }
10186 setKeyEvent.encryptionModeMulticast =
10187 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10188 setKeyEvent.encryptionModeUnicast =
10189 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010190 vos_mem_copy(setKeyEvent.bssid,
10191 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010192 setKeyEvent.authMode =
10193 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010194 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010195 {
10196 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10197 }
10198 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10199 }
10200#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10201 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10202 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010203 csrRoamStopWaitForKeyTimer( pMac );
10204
Jeff Johnson295189b2012-06-20 16:38:30 -070010205 //We are done with authentication, whethere succeed or not
10206 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010207 //We do it here because this linkup function is not called after association
10208 //when a key needs to be set.
10209 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10210 {
10211 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10212 }
10213 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010214 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010215 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010216 vos_mem_copy(&roamInfo.peerMac,
10217 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010218 //Make sure we install the GTK before indicating to HDD as authenticated
10219 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010220 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10221 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010222 {
Yathish9f22e662012-12-10 14:21:35 -080010223#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10224 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10225 {
10226 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010227 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010228 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
10229 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
10230 pMsg->seesionId = sessionId;
10231 status = palSendMBMessage(pMac->hHdd, pMsg );
10232 }
10233#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010234 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010235 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010236 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE
10237 && (VOS_P2P_GO_MODE !=
10238 pSession->pCurRoamProfile->csrPersona
10239 && VOS_STA_SAP_MODE !=
10240 pSession->pCurRoamProfile->csrPersona))
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010241 {
10242 tpSirSmeHT40OBSSScanInd pMsg;
10243 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10244 pMsg->messageType =
10245 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10246 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010247 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10248 vos_mem_copy(pMsg->peerMacAddr,
10249 pSession->connectedProfile.bssid,
10250 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010251 status = palSendMBMessage(pMac->hHdd,
10252 pMsg );
10253 }
10254 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010255 }
10256 else
10257 {
10258 result = eCSR_ROAM_RESULT_NONE;
10259 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010260 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 }
10262 else
10263 {
10264 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010265 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10266 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10267 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010268 }
10269 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10270 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010271 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10272 // can go ahead and initiate the TSPEC if any are pending
10273 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010274#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010275 //Send Adjacent AP repot to new AP.
10276 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10277 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010278 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010279 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010280#ifdef FEATURE_WLAN_ESE_UPLOAD
10281 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010282#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010283 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010284#endif
10285 pSession->isPrevApInfoValid = FALSE;
10286 }
10287#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010288 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10289 {
10290 csrReleaseCommandSetKey( pMac, pCommand );
10291 }
10292 }
10293 else
10294 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010295 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010296 }
10297 }
10298 else
10299 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010300 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010301 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010302 smeProcessPendingQueue( pMac );
10303 }
10304 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010305 case eWNI_SME_REMOVEKEY_RSP:
10306 {
10307 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10308 tListElem *pEntry;
10309 tSmeCmd *pCommand;
10310
10311 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10312 if ( pEntry )
10313 {
10314 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10315 if ( eSmeCommandRemoveKey == pCommand->command )
10316 {
10317 sessionId = pCommand->sessionId;
10318 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010319
10320 if(!pSession)
10321 {
10322 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10323 return;
10324 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010325#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10326 {
10327 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010328 vos_mem_set(&removeKeyEvent,
10329 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010330 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10331 removeKeyEvent.encryptionModeMulticast =
10332 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10333 removeKeyEvent.encryptionModeUnicast =
10334 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010335 vos_mem_copy( removeKeyEvent.bssid,
10336 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010337 removeKeyEvent.authMode =
10338 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010339 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010340 {
10341 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10342 }
10343 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10344 }
10345#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010346 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010347 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010348 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10349 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010350 result = eCSR_ROAM_RESULT_NONE;
10351 pRoamInfo = &roamInfo;
10352 }
10353 else
10354 {
10355 result = eCSR_ROAM_RESULT_FAILURE;
10356 }
10357 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10358 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10359 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10360 {
10361 csrReleaseCommandRemoveKey( pMac, pCommand );
10362 }
10363 }
10364 else
10365 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010366 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010367 }
10368 }
10369 else
10370 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010371 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010372 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010373 smeProcessPendingQueue( pMac );
10374 }
10375 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010376 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010377 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010378 csrRoamStatsRspProcessor( pMac, pSirMsg );
10379 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010380#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010381 case eWNI_SME_GET_ROAM_RSSI_RSP:
10382 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10383 csrRoamRssiRspProcessor( pMac, pSirMsg );
10384 break;
10385#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010386#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010387 case eWNI_SME_GET_TSM_STATS_RSP:
10388 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10389 csrTsmStatsRspProcessor( pMac, pSirMsg );
10390 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010391#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010392 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010393 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010394 csrUpdateRssi( pMac, pSirMsg );
10395 break;
10396
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010397 case eWNI_SME_GET_SNR_REQ:
10398 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10399 csrUpdateSnr(pMac, pSirMsg);
10400 break;
10401
Jeff Johnson295189b2012-06-20 16:38:30 -070010402#ifdef WLAN_FEATURE_VOWIFI_11R
10403 case eWNI_SME_FT_PRE_AUTH_RSP:
10404 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10405 break;
10406#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010407 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10408 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010409 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 -070010410 sessionId = pSmeMaxAssocInd->sessionId;
10411 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010412 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10413 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010414 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10415 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10416 break;
10417
10418 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010419 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010420 btampEstablishLogLinkHdlr( pSirMsg );
10421 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010422 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010423 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010424 csrRoamRssiIndHdlr( pMac, pSirMsg );
10425 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010426#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10427 case eWNI_SME_CANDIDATE_FOUND_IND:
10428 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10429 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10430 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010431 case eWNI_SME_HANDOFF_REQ:
10432 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10433 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10434 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010435#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010436
10437 default:
10438 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010439 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010440}
10441
Jeff Johnson295189b2012-06-20 16:38:30 -070010442void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10443 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10444{
10445 if(pSession)
10446 {
10447 if(pSession->bRefAssocStartCnt)
10448 {
10449 pSession->bRefAssocStartCnt--;
10450 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10451 //Need to call association_completion because there is an assoc_start pending.
10452 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10453 eCSR_ROAM_ASSOCIATION_COMPLETION,
10454 eCSR_ROAM_RESULT_FAILURE);
10455 }
10456 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10457 }
10458 else
10459 {
10460 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10461 }
10462}
10463
10464
10465eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10466{
10467 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010468 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10469 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10470 {
10471 status = csrScanRequestLostLink1( pMac, sessionId );
10472 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010473 return(status);
10474}
10475
Jeff Johnson295189b2012-06-20 16:38:30 -070010476//return a boolean to indicate whether roaming completed or continue.
10477tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10478 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10479{
10480 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10481 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10482 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10483 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010484 if(!pSession)
10485 {
10486 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10487 return eANI_BOOLEAN_FALSE;
10488 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010489 //Check whether time is up
10490 if(pSession->fCancelRoaming || fForce ||
10491 ((curTime - pSession->roamingStartTime) > roamTime) ||
10492 eCsrReassocRoaming == pSession->roamingReason ||
10493 eCsrDynamicRoaming == pSession->roamingReason)
10494 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010495 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010496 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10497 {
10498 //roaming is cancelled, tell HDD to indicate disconnect
10499 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10500 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10501 //to be eSIR_BEACON_MISSED
10502 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10503 {
10504 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10505 }
10506 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10507 {
10508 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10509 }
10510 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10511 {
10512 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10513 }
10514 else
10515 {
10516 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10517 }
10518 }
10519 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10520 pSession->roamingReason = eCsrNotRoaming;
10521 }
10522 else
10523 {
10524 pSession->roamResult = roamResult;
10525 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10526 {
10527 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10528 pSession->roamingReason = eCsrNotRoaming;
10529 }
10530 else
10531 {
10532 fCompleted = eANI_BOOLEAN_FALSE;
10533 }
10534 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010535 return(fCompleted);
10536}
10537
Jeff Johnson295189b2012-06-20 16:38:30 -070010538void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10539{
10540 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010541
10542 if(!pSession)
10543 {
10544 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10545 return;
10546 }
10547
Jeff Johnson295189b2012-06-20 16:38:30 -070010548 if(CSR_IS_ROAMING(pSession))
10549 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010550 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010551 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10552 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10553 {
10554 //No need to do anything in here because the handler takes care of it
10555 }
10556 else
10557 {
10558 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10559 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10560 //Roaming is stopped after here
10561 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10562 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010563 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010564 csrRoamStopRoamingTimer(pMac, sessionId);
10565 }
10566 }
10567}
10568
Jeff Johnson295189b2012-06-20 16:38:30 -070010569void csrRoamRoamingTimerHandler(void *pv)
10570{
10571 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10572 tpAniSirGlobal pMac = pInfo->pMac;
10573 tANI_U32 sessionId = pInfo->sessionId;
10574 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010575
10576 if(!pSession)
10577 {
10578 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10579 return;
10580 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010581
10582 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10583 {
10584 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10585 {
10586 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10587 pSession->roamingReason = eCsrNotRoaming;
10588 }
10589 }
10590}
10591
Jeff Johnson295189b2012-06-20 16:38:30 -070010592eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10593{
10594 eHalStatus status;
10595 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010596
10597 if(!pSession)
10598 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010599 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010600 return eHAL_STATUS_FAILURE;
10601 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010602
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010603 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010604 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010605 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010606
10607 return (status);
10608}
10609
Jeff Johnson295189b2012-06-20 16:38:30 -070010610eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10611{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010612 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010613}
10614
Jeff Johnson295189b2012-06-20 16:38:30 -070010615void csrRoamWaitForKeyTimeOutHandler(void *pv)
10616{
10617 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10618 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010619 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010620 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010621
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010622 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10623 macTraceGetNeighbourRoamState(
10624 pMac->roam.neighborRoamInfo.neighborRoamState),
10625 macTraceGetcsrRoamSubState(
10626 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010627
Jeff Johnson295189b2012-06-20 16:38:30 -070010628 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10629 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010630#ifdef FEATURE_WLAN_LFR
10631 if (csrNeighborRoamIsHandoffInProgress(pMac))
10632 {
10633 /*
10634 * Enable heartbeat timer when hand-off is in progress
10635 * and Key Wait timer expired.
10636 */
10637 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010638 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010639 pMac->roam.configParam.HeartbeatThresh24);
10640 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10641 pMac->roam.configParam.HeartbeatThresh24,
10642 NULL, eANI_BOOLEAN_FALSE);
10643 }
10644#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010645 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010646
Jeff Johnson295189b2012-06-20 16:38:30 -070010647 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010648 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10649 {
10650 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10651 pInfo->sessionId);
10652 }
10653
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010654 if (pSession)
10655 {
10656 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10657 {
10658 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10659 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010660 if( (pSession->connectedProfile.AuthType ==
10661 eCSR_AUTH_TYPE_SHARED_KEY) &&
10662 ( (pSession->connectedProfile.EncryptionType ==
10663 eCSR_ENCRYPT_TYPE_WEP40) ||
10664 (pSession->connectedProfile.EncryptionType ==
10665 eCSR_ENCRYPT_TYPE_WEP104) ))
10666 {
10667 status = sme_AcquireGlobalLock( &pMac->sme );
10668 if ( HAL_STATUS_SUCCESS( status ) )
10669 {
10670 csrRoamDisconnect( pMac, pInfo->sessionId,
10671 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10672 sme_ReleaseGlobalLock( &pMac->sme );
10673 }
10674 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010675 }
10676 else
10677 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010678 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010679 __func__);
10680 }
10681 }
10682 else
10683 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010684 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010685 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010686 }
10687
10688}
10689
Jeff Johnson295189b2012-06-20 16:38:30 -070010690eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10691{
10692 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010693#ifdef FEATURE_WLAN_LFR
10694 if (csrNeighborRoamIsHandoffInProgress(pMac))
10695 {
10696 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010697 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10698 macTraceGetNeighbourRoamState(
10699 pMac->roam.neighborRoamInfo.neighborRoamState),
10700 macTraceGetcsrRoamSubState(
10701 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10702 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010703 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10704 }
10705#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010706 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010707 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010708
10709 return (status);
10710}
10711
Jeff Johnson295189b2012-06-20 16:38:30 -070010712eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10713{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010714 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10715 macTraceGetNeighbourRoamState(
10716 pMac->roam.neighborRoamInfo.neighborRoamState),
10717 macTraceGetcsrRoamSubState(
10718 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010719#ifdef FEATURE_WLAN_LFR
10720 if (csrNeighborRoamIsHandoffInProgress(pMac))
10721 {
10722 /*
10723 * Enable heartbeat timer when hand-off is in progress
10724 * and Key Wait timer got stopped for some reason
10725 */
10726 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010727 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010728 pMac->roam.configParam.HeartbeatThresh24);
10729 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10730 pMac->roam.configParam.HeartbeatThresh24,
10731 NULL, eANI_BOOLEAN_FALSE);
10732 }
10733#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010734 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010735}
10736
Jeff Johnson295189b2012-06-20 16:38:30 -070010737void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10738 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10739{
10740 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10741 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010742 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10743 /* To silence the KW tool Null chaeck is added */
10744 if(!pSession)
10745 {
10746 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10747 return;
10748 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010749
10750 if(pCommand)
10751 {
10752 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010753 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010754 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010755 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10756 {
10757 //if success, force roaming completion
10758 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10759 }
10760 else
10761 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010762 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010763 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010764 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10765 }
10766}
10767
Jeff Johnson295189b2012-06-20 16:38:30 -070010768eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10769{
10770 eHalStatus status = eHAL_STATUS_SUCCESS;
10771 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10772 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10773 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10774 tCsrRoamInfo *pRoamInfo = NULL;
10775 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010776 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010777 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010778 /* To silence the KW tool Null chaeck is added */
10779 if(!pSession)
10780 {
10781 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10782 return eHAL_STATUS_FAILURE;
10783 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010784 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010785 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010786 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10787 if ( eWNI_SME_DISASSOC_IND == type )
10788 {
10789 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10790 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10791 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010792 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010793 }
10794 else if ( eWNI_SME_DEAUTH_IND == type )
10795 {
10796 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10797 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10798 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010799 /* Convert into proper reason code */
10800 pSession->joinFailStatusCode.reasonCode =
10801 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010802 0 : pDeauthIndMsg->reasonCode;
10803 /* cfg layer expects 0 as reason code if
10804 the driver dosent know the reason code
10805 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010806 }
10807 else
10808 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010809 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010810 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010811 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010812 }
10813
10814 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010815 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010816 {
10817 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10818 }
10819
10820 if ( eWNI_SME_DISASSOC_IND == type )
10821 {
10822 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10823 }
10824 else if ( eWNI_SME_DEAUTH_IND == type )
10825 {
10826 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10827 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010828 if(!HAL_STATUS_SUCCESS(status))
10829 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010830 //If fail to send confirmation to PE, not to trigger roaming
10831 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010832 }
10833
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010834 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010835 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010836 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10837 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010838 if( eWNI_SME_DISASSOC_IND == type)
10839 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010840 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010841 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10842 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010843 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10844 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010845 else if( eWNI_SME_DEAUTH_IND == type )
10846 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010847 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010848 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10849 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010850 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10851 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010852 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010853
10854 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10855 that we are roaming. But if we cannot possibly roam, or if we are unable to
10856 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010857 if(fToRoam)
10858 {
10859 //Only remove the connected BSS in infrastructure mode
10860 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10861 //Not to do anying for lostlink with WDS
10862 if( pMac->roam.configParam.nRoamingTime )
10863 {
10864 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10865 ( eWNI_SME_DEAUTH_IND == type ) ?
10866 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10867 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010868 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010869 //For IBSS, we need to give some more info to HDD
10870 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10871 {
10872 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10873 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10874 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10875 }
10876 else
10877 {
10878 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10879 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010880 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010881 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10882 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10883 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10884 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10885 }
10886 else
10887 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010888 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010889 fToRoam = eANI_BOOLEAN_FALSE;
10890 }
10891 }
10892 else
10893 {
10894 //We are told not to roam, indicate lostlink
10895 fToRoam = eANI_BOOLEAN_FALSE;
10896 }
10897 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010898 if(!fToRoam)
10899 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010900 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010901 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010902 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010903 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10904 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10905 * csrRoamCheckForLinkStatusChange API.
10906 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010907 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10908 }
10909
10910 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010911 Still enable idle scan for polling in case concurrent sessions are running */
10912 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10913 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010914 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010915 }
10916 }
10917
10918 return (status);
10919}
10920
Jeff Johnson295189b2012-06-20 16:38:30 -070010921eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10922{
10923 eHalStatus status = eHAL_STATUS_SUCCESS;
10924 tListElem *pEntry = NULL;
10925 tSmeCmd *pCommand = NULL;
10926 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010927
10928 if(!pSession)
10929 {
10930 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10931 return eHAL_STATUS_FAILURE;
10932 }
10933
Jeff Johnson295189b2012-06-20 16:38:30 -070010934 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010935 //Only remove the connected BSS in infrastructure mode
10936 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10937 if(pMac->roam.configParam.nRoamingTime)
10938 {
10939 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10940 {
10941 //before starting the lost link logic release the roam command for handoff
10942 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10943 if(pEntry)
10944 {
10945 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10946 }
10947 if(pCommand)
10948 {
10949 if (( eSmeCommandRoam == pCommand->command ) &&
10950 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10951 {
10952 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10953 {
10954 csrReleaseCommandRoam( pMac, pCommand );
10955 }
10956 }
10957 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010958 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010959 }
10960 }
10961 else
10962 {
10963 //We are told not to roam, indicate lostlink
10964 status = eHAL_STATUS_FAILURE;
10965 }
10966
10967 return (status);
10968}
Jeff Johnson295189b2012-06-20 16:38:30 -070010969void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10970{
10971 tListElem *pEntry;
10972 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010973 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10974 if ( pEntry )
10975 {
10976 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10977 if ( eSmeCommandWmStatusChange == pCommand->command )
10978 {
10979 // Nothing to process in a Lost Link completion.... It just kicks off a
10980 // roaming sequence.
10981 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10982 {
10983 csrReleaseCommandWmStatusChange( pMac, pCommand );
10984 }
10985 else
10986 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010987 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010988 }
10989
10990 }
10991 else
10992 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010993 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010994 }
10995 }
10996 else
10997 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010998 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010999 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011000 smeProcessPendingQueue( pMac );
11001}
11002
Jeff Johnson295189b2012-06-20 16:38:30 -070011003void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
11004{
11005 eHalStatus status = eHAL_STATUS_FAILURE;
11006 tSirSmeRsp *pSirSmeMsg;
11007 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011008
11009 if(!pSession)
11010 {
11011 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
11012 return;
11013 }
11014
Jeff Johnson295189b2012-06-20 16:38:30 -070011015 switch ( pCommand->u.wmStatusChangeCmd.Type )
11016 {
11017 case eCsrDisassociated:
11018 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
11019 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11020 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011021 case eCsrDeauthenticated:
11022 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
11023 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11024 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011025 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011026 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011027 break;
11028 }
11029 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
11030 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
11031 {
11032 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
11033 {
11034 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011035 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011036 }
11037 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011038 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
11039 // command here since there is nothing else to do.
11040 csrRoamWmStatusChangeComplete( pMac );
11041}
11042
Jeff Johnson295189b2012-06-20 16:38:30 -070011043//This function returns band and mode information.
11044//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
11045//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070011046static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11047 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070011048{
Jeff Johnson295189b2012-06-20 16:38:30 -070011049 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
11050 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
11051 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011052 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070011053
Jeff Johnson295189b2012-06-20 16:38:30 -070011054 //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 -070011055 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
11056 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
11057 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
11058 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011059 {
11060 switch( pMac->roam.configParam.uCfgDot11Mode )
11061 {
11062 case eCSR_CFG_DOT11_MODE_11A:
11063 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11064 eBand = eCSR_BAND_5G;
11065 break;
11066 case eCSR_CFG_DOT11_MODE_11B:
11067 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11068 eBand = eCSR_BAND_24;
11069 break;
11070 case eCSR_CFG_DOT11_MODE_11G:
11071 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11072 eBand = eCSR_BAND_24;
11073 break;
11074 case eCSR_CFG_DOT11_MODE_11N:
11075 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011076 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11077 break;
11078#ifdef WLAN_FEATURE_11AC
11079 case eCSR_CFG_DOT11_MODE_11AC:
11080 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11081 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011082 /* If the operating channel is in 2.4 GHz band, check for
11083 * INI item to disable VHT operation in 2.4 GHz band
11084 */
11085 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11086 !pMac->roam.configParam.enableVhtFor24GHz)
11087 {
11088 /* Disable 11AC operation */
11089 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11090 }
11091 else
11092 {
11093 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11094 }
11095 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011096 }
11097 else
11098 {
11099 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11100 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11101 }
11102 break;
11103 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11104 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11105 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011106 /* If the operating channel is in 2.4 GHz band, check for
11107 * INI item to disable VHT operation in 2.4 GHz band
11108 */
11109 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11110 !pMac->roam.configParam.enableVhtFor24GHz)
11111 {
11112 /* Disable 11AC operation */
11113 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11114 }
11115 else
11116 {
11117 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11118 }
11119 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011120 }
11121 else
11122 {
11123 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11124 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11125 }
11126 break;
11127#endif
11128 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011129#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011130 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11131 {
11132 /* If the operating channel is in 2.4 GHz band, check for
11133 * INI item to disable VHT operation in 2.4 GHz band
11134 */
11135 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11136 !pMac->roam.configParam.enableVhtFor24GHz)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011137 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011138 /* Disable 11AC operation */
11139 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011140 }
11141 else
11142 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011143 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11144 }
11145 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11146 }
11147 else
11148 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011149 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11150 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011151 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011152#else
11153 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11154 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11155#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011156 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011157 default:
11158 // Global dot11 Mode setting is 11a/b/g.
11159 // use the channel number to determine the Mode setting.
11160 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11161 {
11162 eBand = pMac->roam.configParam.eBand;
11163 if(eCSR_BAND_24 == eBand)
11164 {
11165 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11166 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11167 }
11168 else
11169 {
11170 //prefer 5GHz
11171 eBand = eCSR_BAND_5G;
11172 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11173 }
11174 }
11175 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11176 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011177 // WiFi tests require IBSS networks to start in 11b mode
11178 // without any change to the default parameter settings
11179 // on the adapter. We use ACU to start an IBSS through
11180 // creation of a startIBSS profile. This startIBSS profile
11181 // has Auto MACProtocol and the adapter property setting
11182 // for dot11Mode is also AUTO. So in this case, let's
11183 // start the IBSS network in 11b mode instead of 11g mode.
11184 // So this is for Auto=profile->MacProtocol && Auto=Global.
11185 // dot11Mode && profile->channel is < 14, then start the IBSS
11186 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011187 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011188 // Note: we used to have this start as an 11g IBSS for best
11189 // performance... now to specify that the user will have to
11190 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011191 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11192 eBand = eCSR_BAND_24;
11193 }
11194 else
11195 {
11196 // else, it's a 5.0GHz channel. Set mode to 11a.
11197 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11198 eBand = eCSR_BAND_5G;
11199 }
11200 break;
11201 }//switch
11202 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11203 else
11204 {
11205 //dot11 mode is set, lets pick the band
11206 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11207 {
11208 // channel is Auto also.
11209 eBand = pMac->roam.configParam.eBand;
11210 if(eCSR_BAND_ALL == eBand)
11211 {
11212 //prefer 5GHz
11213 eBand = eCSR_BAND_5G;
11214 }
11215 }
11216 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11217 {
11218 eBand = eCSR_BAND_24;
11219 }
11220 else
11221 {
11222 eBand = eCSR_BAND_5G;
11223 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011224 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011225 if(pBand)
11226 {
11227 *pBand = eBand;
11228 }
11229
11230 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011231 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011232 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11233 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011234
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011235 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11236 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 -070011237 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011238#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011239 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011240#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011241 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11242 {
11243 //We cannot do 11n here
11244 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11245 {
11246 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11247 }
11248 else
11249 {
11250 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11251 }
11252 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011253 return( cfgDot11Mode );
11254}
11255
Jeff Johnson295189b2012-06-20 16:38:30 -070011256eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11257{
11258 eHalStatus status;
11259 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011260
11261 if(!pSession)
11262 {
11263 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11264 return eHAL_STATUS_FAILURE;
11265 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011266
11267#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11268 {
11269 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011270 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11271 if(pIbssLog)
11272 {
11273 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11274 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11275 }
11276 }
11277#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011278 // Set the roaming substate to 'stop Bss request'...
11279 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11280
11281 // attempt to stop the Bss (reason code is ignored...)
11282 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011283 if(!HAL_STATUS_SUCCESS(status))
11284 {
11285 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11286 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011287 return (status);
11288}
11289
Jeff Johnson295189b2012-06-20 16:38:30 -070011290//pNumChan is a caller allocated space with the sizeof pChannels
11291eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11292{
11293
11294 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11295 (tANI_U8 *)pChannels,
11296 pNumChan));
11297}
11298
Kiran4a17ebe2013-01-31 10:43:43 -080011299tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11300{
11301 tANI_U32 cfgLength = 0;
11302 tANI_U16 cfgId = 0;
11303 tPowerdBm maxTxPwr = 0;
11304 tANI_U8 *pCountryInfo = NULL;
11305 eHalStatus status;
11306 tANI_U8 count = 0;
11307 tANI_U8 firstChannel;
11308 tANI_U8 maxChannels;
11309
11310 if (CSR_IS_CHANNEL_5GHZ(channel))
11311 {
11312 cfgId = WNI_CFG_MAX_TX_POWER_5;
11313 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11314 }
11315 else if (CSR_IS_CHANNEL_24GHZ(channel))
11316 {
11317 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11318 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11319 }
11320 else
11321 return maxTxPwr;
11322
Kiet Lam64c1b492013-07-12 13:56:44 +053011323 pCountryInfo = vos_mem_malloc(cfgLength);
11324 if ( NULL == pCountryInfo )
11325 status = eHAL_STATUS_FAILURE;
11326 else
11327 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011328 if (status != eHAL_STATUS_SUCCESS)
11329 {
11330 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011331 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011332 __FUNCTION__, status);
11333 goto error;
11334 }
11335 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11336 if (status != eHAL_STATUS_SUCCESS)
11337 {
11338 goto error;
11339 }
11340 /* Identify the channel and maxtxpower */
11341 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11342 {
11343 firstChannel = pCountryInfo[count++];
11344 maxChannels = pCountryInfo[count++];
11345 maxTxPwr = pCountryInfo[count++];
11346
11347 if ((channel >= firstChannel) &&
11348 (channel < (firstChannel + maxChannels)))
11349 {
11350 break;
11351 }
11352 }
11353
11354error:
11355 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011356 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011357
11358 return maxTxPwr;
11359}
11360
11361
Jeff Johnson295189b2012-06-20 16:38:30 -070011362tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11363{
11364 tANI_BOOLEAN fValid = FALSE;
11365 tANI_U32 idxValidChannels;
11366 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11367
11368 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11369 {
11370 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11371 {
11372 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11373 {
11374 fValid = TRUE;
11375 break;
11376 }
11377 }
11378 }
11379 pMac->roam.numValidChannels = len;
11380 return fValid;
11381}
11382
Jeff Johnson295189b2012-06-20 16:38:30 -070011383tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11384{
11385 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11386 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011387 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11388 {
11389 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11390 {
11391 fValid = eANI_BOOLEAN_TRUE;
11392 break;
11393 }
11394 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011395 return (fValid);
11396}
11397
Jeff Johnson295189b2012-06-20 16:38:30 -070011398//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011399 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011400{
Jeff Johnsone7245742012-09-05 17:12:55 -070011401 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011402 tANI_U8 centerChn;
11403 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011404
Jeff Johnson295189b2012-06-20 16:38:30 -070011405 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11406 {
11407 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11408 }
11409 else
11410 {
11411 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11412 }
11413 //Figure what the other side's CB mode
11414 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11415 {
11416 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11417 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011418 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11419 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11420 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11421 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011422 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
11423 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053011424 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011425 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053011426
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011427 {
11428 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11429 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11430 }
11431
11432 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011433 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011434 /* This is called during INFRA STA/CLIENT and should use the merged value of
11435 * supported channel width and recommended tx width as per standard
11436 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011437 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011438 pIes->HTCaps.supportedChannelWidthSet,
11439 pIes->HTInfo.recommendedTxWidthSet,
11440 pIes->HTInfo.secondaryChannelOffset);
11441
11442 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11443 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011444 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011445 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11446 switch (eRet) {
11447 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11448 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11449 break;
11450 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11451 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11452 break;
11453 case PHY_SINGLE_CHANNEL_CENTERED:
11454 default:
11455 centerChn = primaryChn;
11456 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011457 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011458 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011459 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011460 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053011461 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011462 }
11463 }
11464 }
11465 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011466 return eRet;
11467}
Jeff Johnson295189b2012-06-20 16:38:30 -070011468tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11469{
11470 tANI_BOOLEAN fFound = FALSE;
11471 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011472 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11473 {
11474 if( pCipherList->encryptionType[idx] == encryptionType )
11475 {
11476 fFound = TRUE;
11477 break;
11478 }
11479 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011480 return fFound;
11481}
Jeff Johnson295189b2012-06-20 16:38:30 -070011482tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11483{
11484 tANI_BOOLEAN fFound = FALSE;
11485 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011486 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11487 {
11488 if( pAuthList->authType[idx] == authType )
11489 {
11490 fFound = TRUE;
11491 break;
11492 }
11493 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011494 return fFound;
11495}
Jeff Johnson295189b2012-06-20 16:38:30 -070011496tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11497{
11498 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11499 tCsrScanResultFilter *pScanFilter = NULL;
11500 eHalStatus status = eHAL_STATUS_SUCCESS;
11501
11502 if(pProfile1 && pProfile2)
11503 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011504 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11505 if ( NULL == pScanFilter )
11506 status = eHAL_STATUS_FAILURE;
11507 else
11508 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011509 if(HAL_STATUS_SUCCESS(status))
11510 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011511 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011512 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11513 if(HAL_STATUS_SUCCESS(status))
11514 {
11515 fCheck = eANI_BOOLEAN_FALSE;
11516 do
11517 {
11518 tANI_U32 i;
11519 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11520 {
11521 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11522 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11523 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11524 if ( fCheck ) break;
11525 }
11526 if(!fCheck)
11527 {
11528 break;
11529 }
11530 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11531 || pProfile2->BSSType != pProfile1->BSSType
11532 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11533 )
11534 {
11535 fCheck = eANI_BOOLEAN_FALSE;
11536 break;
11537 }
11538#ifdef WLAN_FEATURE_VOWIFI_11R
11539 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11540 {
11541 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11542 {
11543 fCheck = eANI_BOOLEAN_FALSE;
11544 break;
11545 }
11546 }
11547#endif
11548 //Match found
11549 fCheck = eANI_BOOLEAN_TRUE;
11550 }while(0);
11551 csrFreeScanFilter(pMac, pScanFilter);
11552 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011553 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011554 }
11555 }
11556
11557 return (fCheck);
11558}
11559
Jeff Johnson295189b2012-06-20 16:38:30 -070011560tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11561{
11562 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11563 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011564 do
11565 {
11566 //Only check for static WEP
11567 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11568 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11569 {
11570 fCheck = eANI_BOOLEAN_TRUE;
11571 break;
11572 }
11573 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11574 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11575 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11576 {
11577 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011578 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11579 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011580 {
11581 break;
11582 }
11583 }
11584 if( i == CSR_MAX_NUM_KEY)
11585 {
11586 fCheck = eANI_BOOLEAN_TRUE;
11587 }
11588 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011589 return (fCheck);
11590}
11591
Jeff Johnson295189b2012-06-20 16:38:30 -070011592//IBSS
11593
Jeff Johnson295189b2012-06-20 16:38:30 -070011594tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11595{
11596 tANI_U8 channel = 0;
11597 tANI_U32 idx;
11598 tANI_U32 idxValidChannels;
11599 tANI_BOOLEAN fFound = FALSE;
11600 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11601
11602 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11603 {
11604 channel = pMac->roam.configParam.AdHocChannel5G;
11605 if(!csrRoamIsChannelValid(pMac, channel))
11606 {
11607 channel = 0;
11608 }
11609 }
11610 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11611 {
11612 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11613 {
11614 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11615 {
11616 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11617 {
11618 fFound = TRUE;
11619 channel = csrStartIbssChannels50[ idx ];
11620 }
11621 }
11622 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011623 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11624 if (!fFound)
11625 {
11626 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11627 {
Girish Gowli386e76c2014-10-20 22:00:29 +053011628 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idxValidChannels ]) ) // the max channel# in 11g is 14
Jeff Johnson295189b2012-06-20 16:38:30 -070011629 {
Girish Gowli386e76c2014-10-20 22:00:29 +053011630 channel = pMac->roam.validChannelList[ idxValidChannels ];
Jeff Johnson295189b2012-06-20 16:38:30 -070011631 break;
11632 }
11633 }
11634 }
11635 }//if
11636
11637 return( channel );
11638}
11639
Jeff Johnson295189b2012-06-20 16:38:30 -070011640tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11641{
11642 tANI_U8 channel = 1;
11643 tANI_U32 idx;
11644 tANI_U32 idxValidChannels;
11645 tANI_BOOLEAN fFound = FALSE;
11646 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11647
11648 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11649 {
11650 channel = pMac->roam.configParam.AdHocChannel24;
11651 if(!csrRoamIsChannelValid(pMac, channel))
11652 {
11653 channel = 0;
11654 }
11655 }
11656
11657 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11658 {
11659 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11660 {
11661 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11662 {
11663 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11664 {
11665 fFound = TRUE;
11666 channel = csrStartIbssChannels24[ idx ];
11667 }
11668 }
11669 }
11670 }
11671
11672 return( channel );
11673}
11674
Jeff Johnson295189b2012-06-20 16:38:30 -070011675static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11676 tCsrRoamStartBssParams *pParam )
11677{
11678 eCsrCfgDot11Mode cfgDot11Mode;
11679 eCsrBand eBand;
11680 tANI_U8 channel = 0;
11681 tSirNwType nwType;
11682 tANI_U8 operationChannel = 0;
11683
11684 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11685 {
11686 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11687 }
11688
Jeff Johnson295189b2012-06-20 16:38:30 -070011689 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011690
Jeff Johnson295189b2012-06-20 16:38:30 -070011691 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11692 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11693 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11694 )
11695 {
11696 /* This should never happen */
11697 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011698 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011699 pProfile->csrPersona);
11700 VOS_ASSERT(0);
11701 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011702 switch( cfgDot11Mode )
11703 {
11704 case eCSR_CFG_DOT11_MODE_11G:
11705 nwType = eSIR_11G_NW_TYPE;
11706 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011707 case eCSR_CFG_DOT11_MODE_11B:
11708 nwType = eSIR_11B_NW_TYPE;
11709 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011710 case eCSR_CFG_DOT11_MODE_11A:
11711 nwType = eSIR_11A_NW_TYPE;
11712 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011713 default:
11714 case eCSR_CFG_DOT11_MODE_11N:
11715 case eCSR_CFG_DOT11_MODE_TAURUS:
11716 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11717 if(eCSR_BAND_24 == eBand)
11718 {
11719 nwType = eSIR_11G_NW_TYPE;
11720 }
11721 else
11722 {
11723 nwType = eSIR_11A_NW_TYPE;
11724 }
11725 break;
11726 }
11727
11728 pParam->extendedRateSet.numRates = 0;
11729
11730 switch ( nwType )
11731 {
11732 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011733 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011734 case eSIR_11A_NW_TYPE:
11735
11736 pParam->operationalRateSet.numRates = 8;
11737
11738 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11739 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11740 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11741 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11742 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11743 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11744 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11745 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11746
11747 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11748 {
11749 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11750 if( 0 == channel &&
11751 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11752 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11753 )
11754 {
11755 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11756 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11757 nwType = eSIR_11B_NW_TYPE;
11758 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11759 pParam->operationalRateSet.numRates = 4;
11760 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11761 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11762 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11763 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11764 }
11765 }
11766 else
11767 {
11768 channel = operationChannel;
11769 }
11770 break;
11771
11772 case eSIR_11B_NW_TYPE:
11773 pParam->operationalRateSet.numRates = 4;
11774 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11775 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11776 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11777 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011778 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11779 {
11780 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11781 }
11782 else
11783 {
11784 channel = operationChannel;
11785 }
11786
11787 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011788 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011789 /* For P2P Client and P2P GO, disable 11b rates */
11790 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11791 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11792 )
11793 {
11794 pParam->operationalRateSet.numRates = 8;
11795
11796 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11797 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11798 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11799 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11800 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11801 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11802 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11803 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11804 }
11805 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011806 {
11807 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011808 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11809 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11810 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11811 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11812
11813 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011814 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11815 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11816 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11817 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11818 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11819 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11820 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11821 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11822 }
11823
11824 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11825 {
11826 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11827 }
11828 else
11829 {
11830 channel = operationChannel;
11831 }
11832
11833 break;
11834 }
11835 pParam->operationChn = channel;
11836 pParam->sirNwType = nwType;
11837}
11838
Jeff Johnson295189b2012-06-20 16:38:30 -070011839static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11840 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11841{
11842
11843 if( pParam )
11844 {
11845 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011846 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011847 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011848 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011849
11850 if( pIes )
11851 {
11852 if(pIes->SuppRates.present)
11853 {
11854 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11855 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11856 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011857 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 -070011858 pIes->SuppRates.num_rates);
11859 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11860 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011861 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11862 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011863 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011864 if (pIes->ExtSuppRates.present)
11865 {
11866 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011867 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011868 {
11869 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11870 SIR_MAC_RATESET_EID_MAX, resetting to \
11871 SIR_MAC_RATESET_EID_MAX"),
11872 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011873 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011874 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011875 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011876 pIes->ExtSuppRates.rates,
11877 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011879 if( pIes->SSID.present )
11880 {
11881 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011882 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11883 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011884 }
11885 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011886 }
11887 else
11888 {
11889 pParam->ssId.length = 0;
11890 pParam->operationalRateSet.numRates = 0;
11891 }
11892 }
11893}
11894
Jeff Johnson295189b2012-06-20 16:38:30 -070011895static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11896{
11897 tANI_U8 MaxRate = 0;
11898 tANI_U32 i;
11899 tANI_U8 *pRate;
11900
11901 pRate = pSirRateSet->rate;
11902 for ( i = 0; i < pSirRateSet->numRates; i++ )
11903 {
11904 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11905 }
11906
11907 // Save the max rate in the connected state information...
11908
11909 // modify LastRates variable as well
11910
11911 return;
11912}
11913
Jeff Johnson295189b2012-06-20 16:38:30 -070011914eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11915 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11916{
11917 eHalStatus status = eHAL_STATUS_SUCCESS;
11918 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011919 // Set the roaming substate to 'Start BSS attempt'...
11920 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011921#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11922 //Need to figure out whether we need to log WDS???
11923 if( CSR_IS_IBSS( pProfile ) )
11924 {
11925 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011926 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11927 if(pIbssLog)
11928 {
11929 if(pBssDesc)
11930 {
11931 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011932 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011933 }
11934 else
11935 {
11936 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11937 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011938 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011939 if(pProfile->ChannelInfo.numOfChannels == 0)
11940 {
11941 pIbssLog->channelSetting = AUTO_PICK;
11942 }
11943 else
11944 {
11945 pIbssLog->channelSetting = SPECIFIED;
11946 }
11947 pIbssLog->operatingChannel = pParam->operationChn;
11948 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11949 }
11950 }
11951#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11952 //Put RSN information in for Starting BSS
Abhishek Singh00e46532014-11-13 05:34:55 -080011953 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11954 pParam->pRSNIE = pProfile->pRSNReqIE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011955
Jeff Johnson295189b2012-06-20 16:38:30 -070011956 pParam->privacy = pProfile->privacy;
11957 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11958 pParam->authType = pProfile->csr80211AuthType;
11959 pParam->beaconInterval = pProfile->beaconInterval;
11960 pParam->dtimPeriod = pProfile->dtimPeriod;
11961 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11962 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11963 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11964 {
11965 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11966 {
11967 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11968 }
11969 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011970 pParam->protEnabled = pProfile->protEnabled;
11971 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11972 pParam->ht_protection = pProfile->cfg_protection;
11973 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011974
Jeff Johnson295189b2012-06-20 16:38:30 -070011975 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11976 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011977 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080011978
11979#ifdef WLAN_FEATURE_11W
11980 pParam->mfpCapable = (0 != pProfile->MFPCapable);
11981 pParam->mfpRequired = (0 != pProfile->MFPRequired);
11982#endif
11983
Jeff Johnson295189b2012-06-20 16:38:30 -070011984 // When starting an IBSS, start on the channel from the Profile.
11985 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011986 return (status);
11987}
11988
Jeff Johnson295189b2012-06-20 16:38:30 -070011989static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011990 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011991{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011992 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011993 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011994 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011995
11996 if(!pSession)
11997 {
11998 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11999 return;
12000 }
12001
Jeff Johnson295189b2012-06-20 16:38:30 -070012002 if( pBssDesc )
12003 {
12004 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
12005 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
12006 //The following code has to be do after that.
12007 //For WDS station, use selfMac as the self BSSID
12008 if( CSR_IS_WDS_STA( pProfile ) )
12009 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012010 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12011 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012012 }
12013 }
12014 else
12015 {
12016 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070012017 //Use the first SSID
12018 if(pProfile->SSIDs.numOfSSIDs)
12019 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012020 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
12021 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012022 }
12023 //For WDS station, use selfMac as the self BSSID
12024 if( CSR_IS_WDS_STA( pProfile ) )
12025 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012026 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12027 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012028 }
12029 //Use the first BSSID
12030 else if( pProfile->BSSIDs.numOfBSSIDs )
12031 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012032 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
12033 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012034 }
12035 else
12036 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012037 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012038 }
12039 }
12040 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070012041 //Set operating channel in pProfile which will be used
12042 //in csrRoamSetBssConfigCfg() to determine channel bonding
12043 //mode and will be configured in CFG later
12044 pProfile->operationChannel = Channel;
12045
12046 if(Channel == 0)
12047 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053012048 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070012049 }
12050 else
12051 {
12052
12053 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012054 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012055 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012056 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012057 {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012058#ifdef WLAN_FEATURE_AP_HT40_24G
12059 if (CSR_IS_INFRA_AP(pProfile))
12060 cbMode = pMac->roam.configParam.channelBondingAPMode24GHz;
12061 else
12062 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12063#else
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012064 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012065#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012066 }
12067 else
12068 {
12069 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12070 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012071 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070012072 pBssConfig->cbMode = cbMode;
12073 pSession->bssParams.cbMode = cbMode;
12074 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012075 }
12076}
12077
Jeff Johnson295189b2012-06-20 16:38:30 -070012078static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12079 tANI_BOOLEAN *pfSameIbss )
12080{
12081 eHalStatus status = eHAL_STATUS_SUCCESS;
12082 tANI_BOOLEAN fSameIbss = FALSE;
12083
12084 if ( csrIsConnStateIbss( pMac, sessionId ) )
12085 {
12086 // Check if any profile parameter has changed ? If any profile parameter
12087 // has changed then stop old BSS and start a new one with new parameters
12088 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12089 {
12090 fSameIbss = TRUE;
12091 }
12092 else
12093 {
12094 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12095 }
12096 }
12097 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12098 {
12099 // Disassociate from the connected Infrastructure network...
12100 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12101 }
12102 else
12103 {
12104 tBssConfigParam *pBssConfig;
12105
Kiet Lam64c1b492013-07-12 13:56:44 +053012106 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12107 if ( NULL == pBssConfig )
12108 status = eHAL_STATUS_FAILURE;
12109 else
12110 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012111 if(HAL_STATUS_SUCCESS(status))
12112 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012113 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012114 // there is no Bss description before we start an IBSS so we need to adopt
12115 // all Bss configuration parameters from the Profile.
12116 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12117 if(HAL_STATUS_SUCCESS(status))
12118 {
12119 //save dotMode
12120 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12121 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012122 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012123 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12124 NULL, pBssConfig,
12125 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012126 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012127
12128 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012129 }//Allocate memory
12130 }
12131
12132 if(pfSameIbss)
12133 {
12134 *pfSameIbss = fSameIbss;
12135 }
12136 return( status );
12137}
12138
Jeff Johnson295189b2012-06-20 16:38:30 -070012139static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12140 tSirSmeNewBssInfo *pNewBss )
12141{
12142 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012143
12144 if(!pSession)
12145 {
12146 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12147 return;
12148 }
12149
Jeff Johnson295189b2012-06-20 16:38:30 -070012150 if( pNewBss )
12151 {
12152 // Set the operating channel.
12153 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12154 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012155 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12156 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012157 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012158 return;
12159}
12160
Jeff Johnson295189b2012-06-20 16:38:30 -070012161#ifdef FEATURE_WLAN_WAPI
12162eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12163 tANI_U32 numItems )
12164{
12165 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12166 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012167 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12168 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012169 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012170 return status;
12171 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012172 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012173 pSession = CSR_GET_SESSION( pMac, sessionId );
12174 if(numItems <= CSR_MAX_BKID_ALLOWED)
12175 {
12176 status = eHAL_STATUS_SUCCESS;
12177 //numItems may be 0 to clear the cache
12178 pSession->NumBkidCache = (tANI_U16)numItems;
12179 if(numItems && pBKIDCache)
12180 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012181 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12182 sizeof(tBkidCacheInfo) * numItems);
12183 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012184 }
12185 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012186 return (status);
12187}
Jeff Johnson295189b2012-06-20 16:38:30 -070012188eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12189 tBkidCacheInfo *pBkidCache)
12190{
12191 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12192 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012193 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12194 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012195 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012196 return status;
12197 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012198 pSession = CSR_GET_SESSION( pMac, sessionId );
12199 if(pNum && pBkidCache)
12200 {
12201 if(pSession->NumBkidCache == 0)
12202 {
12203 *pNum = 0;
12204 status = eHAL_STATUS_SUCCESS;
12205 }
12206 else if(*pNum >= pSession->NumBkidCache)
12207 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012208 if(pSession->NumBkidCache > CSR_MAX_BKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012209 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012210 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 -070012211 pSession->NumBkidCache);
Girish Gowli2c26e902014-10-20 22:18:17 +053012212 pSession->NumBkidCache = CSR_MAX_BKID_ALLOWED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012213 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012214 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12215 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012216 *pNum = pSession->NumBkidCache;
12217 status = eHAL_STATUS_SUCCESS;
12218 }
12219 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012220 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012221}
Jeff Johnson295189b2012-06-20 16:38:30 -070012222tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12223{
12224 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012225}
12226#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012227eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012228 tPmkidCacheInfo *pPMKIDCache,
12229 tANI_U32 numItems,
12230 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012231{
12232 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12233 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012234
12235 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012236 {
12237 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12238 return eHAL_STATUS_FAILURE;
12239 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012240
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012241 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012242
12243 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012244 {
12245#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12246 {
12247 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012248 vos_mem_set(&secEvent,
12249 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012250 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12251 secEvent.encryptionModeMulticast =
12252 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12253 secEvent.encryptionModeUnicast =
12254 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012255 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012256 secEvent.authMode =
12257 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12258 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12259 }
12260#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012261 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012262 if (update_entire_cache) {
12263 pSession->NumPmkidCache = (tANI_U16)numItems;
12264 if (numItems && pPMKIDCache)
12265 {
12266 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12267 sizeof(tPmkidCacheInfo) * numItems);
12268 }
12269 } else {
12270 tANI_U32 i = 0, j = 0;
12271 tANI_U8 BSSIDMatched = 0;
12272 tPmkidCacheInfo *pmksa;
12273
12274 for (i = 0; i < numItems; i++) {
12275 pmksa = &pPMKIDCache[i];
12276 for (j = 0; j < CSR_MAX_PMKID_ALLOWED; j++) {
12277 if (vos_mem_compare(pSession->PmkidCacheInfo[j].BSSID,
12278 pmksa->BSSID, VOS_MAC_ADDR_SIZE)) {
12279 /* If a matching BSSID found, update it */
12280 BSSIDMatched = 1;
12281 vos_mem_copy(pSession->PmkidCacheInfo[j].PMKID,
12282 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12283 break;
12284 }
12285 }
12286
12287 if (!BSSIDMatched) {
12288 vos_mem_copy(
12289 pSession->PmkidCacheInfo[pSession->NumPmkidCache].BSSID,
12290 pmksa->BSSID, VOS_MAC_ADDR_SIZE);
12291 vos_mem_copy(
12292 pSession->PmkidCacheInfo[pSession->NumPmkidCache].PMKID,
12293 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12294 /* Increment the CSR local cache index */
12295 if (pSession->NumPmkidCache < (CSR_MAX_PMKID_ALLOWED - 1))
12296 pSession->NumPmkidCache++;
12297 else
12298 pSession->NumPmkidCache = 0;
12299 }
12300 BSSIDMatched = 0;
12301 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012302 }
12303 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012304 return (status);
12305}
12306
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012307eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012308 tANI_U8 *pBSSId,
12309 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012310{
12311 eHalStatus status = eHAL_STATUS_FAILURE;
12312 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12313 tANI_BOOLEAN fMatchFound = FALSE;
12314 tANI_U32 Index;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012315
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012316 if(!pSession)
12317 {
12318 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12319 return eHAL_STATUS_FAILURE;
12320 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012321
12322 /* Check if there are no entries to delete */
12323 if (0 == pSession->NumPmkidCache) {
12324 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
12325 return eHAL_STATUS_SUCCESS;
12326 }
12327
12328 if (!flush_cache) {
12329 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
12330 if (vos_mem_compare(pSession->PmkidCacheInfo[Index].BSSID,
12331 pBSSId, VOS_MAC_ADDR_SIZE)) {
12332 fMatchFound = 1;
12333
12334 /* Clear this - the matched entry */
12335 vos_mem_zero(&pSession->PmkidCacheInfo[Index],
12336 sizeof(tPmkidCacheInfo));
12337 status = eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012338 break;
12339 }
12340 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012341
12342 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12343 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "MAC_ADDRESS_STR),
12344 MAC_ADDR_ARRAY(pBSSId));
12345 return status;
12346 }
12347
12348 return status;
12349 } else {
12350 /* Flush the entire cache */
12351 vos_mem_zero(pSession->PmkidCacheInfo,
12352 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12353 pSession->NumPmkidCache = 0;
12354 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012355 }
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012356}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012357
Jeff Johnson295189b2012-06-20 16:38:30 -070012358tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12359{
12360 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12361}
12362
Jeff Johnson295189b2012-06-20 16:38:30 -070012363eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12364{
12365 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12366 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012367
12368 if(!pSession)
12369 {
12370 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12371 return eHAL_STATUS_FAILURE;
12372 }
12373
Jeff Johnson295189b2012-06-20 16:38:30 -070012374 if(pNum && pPmkidCache)
12375 {
12376 if(pSession->NumPmkidCache == 0)
12377 {
12378 *pNum = 0;
12379 status = eHAL_STATUS_SUCCESS;
12380 }
12381 else if(*pNum >= pSession->NumPmkidCache)
12382 {
12383 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12384 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012385 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 -070012386 pSession->NumPmkidCache);
12387 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12388 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012389 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12390 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012391 *pNum = pSession->NumPmkidCache;
12392 status = eHAL_STATUS_SUCCESS;
12393 }
12394 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012395 return (status);
12396}
12397
Jeff Johnson295189b2012-06-20 16:38:30 -070012398eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12399{
12400 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12401 tANI_U32 len;
12402 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012403
12404 if(!pSession)
12405 {
12406 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12407 return eHAL_STATUS_FAILURE;
12408 }
12409
Jeff Johnson295189b2012-06-20 16:38:30 -070012410 if(pLen)
12411 {
12412 len = *pLen;
12413 *pLen = pSession->nWpaRsnReqIeLength;
12414 if(pBuf)
12415 {
12416 if(len >= pSession->nWpaRsnReqIeLength)
12417 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012418 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12419 pSession->nWpaRsnReqIeLength);
12420 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012421 }
12422 }
12423 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012424 return (status);
12425}
12426
Jeff Johnson295189b2012-06-20 16:38:30 -070012427eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12428{
12429 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12430 tANI_U32 len;
12431 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012432
12433 if(!pSession)
12434 {
12435 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12436 return eHAL_STATUS_FAILURE;
12437 }
12438
Jeff Johnson295189b2012-06-20 16:38:30 -070012439 if(pLen)
12440 {
12441 len = *pLen;
12442 *pLen = pSession->nWpaRsnRspIeLength;
12443 if(pBuf)
12444 {
12445 if(len >= pSession->nWpaRsnRspIeLength)
12446 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012447 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12448 pSession->nWpaRsnRspIeLength);
12449 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012450 }
12451 }
12452 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012453 return (status);
12454}
Jeff Johnson295189b2012-06-20 16:38:30 -070012455#ifdef FEATURE_WLAN_WAPI
12456eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12457{
12458 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12459 tANI_U32 len;
12460 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012461
12462 if(!pSession)
12463 {
12464 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12465 return eHAL_STATUS_FAILURE;
12466 }
12467
Jeff Johnson295189b2012-06-20 16:38:30 -070012468 if(pLen)
12469 {
12470 len = *pLen;
12471 *pLen = pSession->nWapiReqIeLength;
12472 if(pBuf)
12473 {
12474 if(len >= pSession->nWapiReqIeLength)
12475 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012476 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12477 pSession->nWapiReqIeLength);
12478 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012479 }
12480 }
12481 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012482 return (status);
12483}
Jeff Johnson295189b2012-06-20 16:38:30 -070012484eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12485{
12486 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12487 tANI_U32 len;
12488 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012489
12490 if(!pSession)
12491 {
12492 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12493 return eHAL_STATUS_FAILURE;
12494 }
12495
Jeff Johnson295189b2012-06-20 16:38:30 -070012496 if(pLen)
12497 {
12498 len = *pLen;
12499 *pLen = pSession->nWapiRspIeLength;
12500 if(pBuf)
12501 {
12502 if(len >= pSession->nWapiRspIeLength)
12503 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012504 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12505 pSession->nWapiRspIeLength);
12506 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012507 }
12508 }
12509 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012510 return (status);
12511}
12512#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012513eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12514{
12515 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12516 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012517
12518 if(!pSession)
12519 {
12520 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12521 return (retStatus);
12522 }
12523
Jeff Johnson295189b2012-06-20 16:38:30 -070012524 if(CSR_IS_ROAMING(pSession))
12525 {
12526 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12527 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12528 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012529 return (retStatus);
12530}
12531
Jeff Johnson295189b2012-06-20 16:38:30 -070012532//This function remove the connected BSS from te cached scan result
12533eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12534 tCsrRoamConnectedProfile *pConnProfile)
12535{
12536 eHalStatus status = eHAL_STATUS_FAILURE;
12537 tCsrScanResultFilter *pScanFilter = NULL;
12538 tListElem *pEntry;
12539 tCsrScanResult *pResult;
12540 tDot11fBeaconIEs *pIes;
12541 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012542 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12543 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12544 {
12545 do
12546 {
12547 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012548 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12549 if ( NULL == pScanFilter )
12550 status = eHAL_STATUS_FAILURE;
12551 else
12552 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012554 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12555 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12556 if ( NULL == pScanFilter->BSSIDs.bssid )
12557 status = eHAL_STATUS_FAILURE;
12558 else
12559 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012560 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012561 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12562 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012563 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12564 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12565 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012566 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12567 if ( NULL == pScanFilter->SSIDs.SSIDList )
12568 status = eHAL_STATUS_FAILURE;
12569 else
12570 status = eHAL_STATUS_SUCCESS;
12571 if (!HAL_STATUS_SUCCESS(status)) break;
12572 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12573 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 }
12575 pScanFilter->authType.numEntries = 1;
12576 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12577 pScanFilter->BSSType = pConnProfile->BSSType;
12578 pScanFilter->EncryptionType.numEntries = 1;
12579 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12580 pScanFilter->mcEncryptionType.numEntries = 1;
12581 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12582 //We ignore the channel for now, BSSID should be enough
12583 pScanFilter->ChannelInfo.numOfChannels = 0;
12584 //Also ignore the following fields
12585 pScanFilter->uapsd_mask = 0;
12586 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012587 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012588 pScanFilter->countryCode[0] = 0;
12589 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012590 csrLLLock(&pMac->scan.scanResultList);
12591 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12592 while( pEntry )
12593 {
12594 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12595 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12596 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12597 pScanFilter, NULL, NULL, NULL, &pIes);
12598 //Release the IEs allocated by csrMatchBSS is needed
12599 if( !pResult->Result.pvIes )
12600 {
12601 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012602 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012603 }
12604 if(fMatch)
12605 {
12606 //We found the one
12607 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12608 {
12609 //Free the memory
12610 csrFreeScanResultEntry( pMac, pResult );
12611 }
12612 break;
12613 }
12614 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12615 }//while
12616 csrLLUnlock(&pMac->scan.scanResultList);
12617 }while(0);
12618 if(pScanFilter)
12619 {
12620 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012621 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012622 }
12623 }
12624 return (status);
12625}
12626
Jeff Johnson295189b2012-06-20 16:38:30 -070012627//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012628eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12629{
12630 eHalStatus status = eHAL_STATUS_SUCCESS;
12631 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012632 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12633 {
12634 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12635 {
12636 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12637 {
12638 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012639 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012640 status = eHAL_STATUS_CSR_WRONG_STATE;
12641 break;
12642 }
12643 if( csrIsConnStateInfra( pMac, sessionId ) )
12644 {
12645 if( chnId &&
12646 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12647 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012648 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012649 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12650 status = eHAL_STATUS_CSR_WRONG_STATE;
12651 break;
12652 }
12653 }
12654 }
12655 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012656 return ( status );
12657}
12658
Jeff Johnson295189b2012-06-20 16:38:30 -070012659static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12660{
12661 eHalStatus status = eHAL_STATUS_SUCCESS;
12662 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12663 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012664
12665 if(!pSession)
12666 {
12667 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12668 return eHAL_STATUS_FAILURE;
12669 }
12670
Jeff Johnson295189b2012-06-20 16:38:30 -070012671 if ( csrIsConnStateIbss( pMac, sessionId ) )
12672 {
12673 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12674 }
12675 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12676 {
12677 // Disassociate from the connected Infrastructure network...
12678 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12679 }
12680 else
12681 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012682 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12683 //Otherwise we need to add code to handle the
12684 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12685 //send stop_bss to PE, before we can continue.
12686 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012687 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012688 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012689 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12690 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012691 // there is no Bss description before we start an WDS so we need
12692 // to adopt all Bss configuration parameters from the Profile.
12693 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12694 if(HAL_STATUS_SUCCESS(status))
12695 {
12696 //Save profile for late use
12697 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012698 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12699 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012700 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012701 vos_mem_set(pSession->pCurRoamProfile,
12702 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012703 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12704 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012705 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012706 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012707 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12708 NULL, &bssConfig,
12709 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012710 }
12711 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012712
Jeff Johnson295189b2012-06-20 16:38:30 -070012713 return( status );
12714}
12715
Jeff Johnson295189b2012-06-20 16:38:30 -070012716////////////////////Mail box
12717
Jeff Johnson295189b2012-06-20 16:38:30 -070012718//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12719//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012720static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12721 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012722 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12723{
12724 tCsrChannelSet channelGroup;
12725 tSirMacCapabilityInfo *pAP_capabilityInfo;
12726 tAniBool fTmp;
12727 tANI_BOOLEAN found = FALSE;
12728 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012729 tANI_S8 pwrLimit = 0;
12730 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012731 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12732 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12733 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12734 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012735 // 802.11h
12736 //We can do this because it is in HOST CPU order for now.
12737 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012738 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12739 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12740 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 fTmp = (tAniBool)pal_cpu_to_be32(1);
12742 }
12743 else
12744 fTmp = (tAniBool)0;
12745
12746 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012747 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012748 pBuf += sizeof(tAniBool);
12749 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012750 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012751 // This is required for 11k test VoWiFi Ent: Test 2.
12752 // We need the power capabilities for Assoc Req.
12753 // This macro is provided by the halPhyCfg.h. We pick our
12754 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012755 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12756 if (0 != pwrLimit)
12757 {
12758 *pBuf++ = pwrLimit;
12759 }
12760 else
12761 {
12762 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12763 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012764 size = sizeof(pMac->roam.validChannelList);
12765 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12766 {
12767 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12768 for ( i = 0; i < size; i++)
12769 {
12770 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12771
12772 }
12773 }
12774 else
12775 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012776 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 *pBuf++ = 0; //tSirSupChnl->numChnl
12778 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012779 //Check whether it is ok to enter UAPSD
12780#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12781 if( btcIsReadyForUapsd(pMac) )
12782#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12783 {
12784 *pBuf++ = uapsdMask;
12785 }
12786#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12787 else
12788 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012789 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012790 *pBuf++ = 0;
12791 }
12792#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12793
Jeff Johnson295189b2012-06-20 16:38:30 -070012794 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012795 vos_mem_copy(pBuf, pBssDescription,
12796 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012797 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12798}
12799
Jeff Johnson295189b2012-06-20 16:38:30 -070012800/*
12801 * The communication between HDD and LIM is thru mailbox (MB).
12802 * Both sides will access the data structure "tSirSmeJoinReq".
12803 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12804 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12805 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12806 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12807 */
12808eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012809 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012810{
12811 eHalStatus status = eHAL_STATUS_SUCCESS;
12812 tSirSmeJoinReq *pMsg;
12813 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012814 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012815 tANI_U16 msgLen, wTmp, ieLen;
12816 tSirMacRateSet OpRateSet;
12817 tSirMacRateSet ExRateSet;
12818 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12819 tANI_U32 dwTmp;
12820 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012821 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053012822 tANI_U8 txBFCsnValue = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012823
12824 if(!pSession)
12825 {
12826 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12827 return eHAL_STATUS_FAILURE;
12828 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012829 /* To satisfy klockworks */
12830 if (NULL == pBssDescription)
12831 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012832 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012833 return eHAL_STATUS_FAILURE;
12834 }
12835
Jeff Johnson295189b2012-06-20 16:38:30 -070012836 do {
12837 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12838 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053012839 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012840 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12841 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12842 // IE fields, but the length field in the bssDescription needs to be interpreted to
12843 // determine length of the IE fields.
12844 //
12845 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12846 // add in the length from the bssDescription (then add the size of the 'length' field
12847 // itself because that is NOT included in the length field).
12848 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12849 pBssDescription->length + sizeof( pBssDescription->length ) +
12850 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 +053012851 pMsg = vos_mem_malloc(msgLen);
12852 if (NULL == pMsg)
12853 status = eHAL_STATUS_FAILURE;
12854 else
12855 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012856 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012857 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012858 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012859 pMsg->length = pal_cpu_to_be16(msgLen);
12860 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012861 // sessionId
12862 *pBuf = (tANI_U8)sessionId;
12863 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012864 // transactionId
12865 *pBuf = 0;
12866 *( pBuf + 1 ) = 0;
12867 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012868 // ssId
12869 if( pIes->SSID.present && pIes->SSID.num_ssid )
12870 {
12871 // ssId len
12872 *pBuf = pIes->SSID.num_ssid;
12873 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012874 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012875 pBuf += pIes->SSID.num_ssid;
12876 }
12877 else
12878 {
12879 *pBuf = 0;
12880 pBuf++;
12881 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012882 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012883 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12884 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012885 pBuf += sizeof(tSirMacAddr);
12886 // bsstype
12887 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12888 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012889 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012890 pBuf += sizeof(tSirBssType);
12891 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012892 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12893 if (pBssDescription->channelId <= 14 &&
12894 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12895 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12896 {
12897 //Need to disable VHT operation in 2.4 GHz band
12898 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12899 }
12900 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012901 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012902 //Persona
12903 *pBuf = (tANI_U8)pProfile->csrPersona;
12904 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012905 //CBMode
12906 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12907 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012908
12909 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012910 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12911
Jeff Johnson295189b2012-06-20 16:38:30 -070012912 // uapsdPerAcBitmask
12913 *pBuf = pProfile->uapsd_mask;
12914 pBuf++;
12915
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012916
12917
Jeff Johnson295189b2012-06-20 16:38:30 -070012918 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012919 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012920 {
12921 // OperationalRateSet
12922 if (OpRateSet.numRates) {
12923 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012924 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012925 pBuf += OpRateSet.numRates;
12926 } else *pBuf++ = 0;
12927 // ExtendedRateSet
12928 if (ExRateSet.numRates) {
12929 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012930 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012931 pBuf += ExRateSet.numRates;
12932 } else *pBuf++ = 0;
12933 }
12934 else
12935 {
12936 *pBuf++ = 0;
12937 *pBuf++ = 0;
12938 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012939 // rsnIE
12940 if ( csrIsProfileWpa( pProfile ) )
12941 {
12942 // Insert the Wpa IE into the join request
12943 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12944 (tCsrWpaIe *)( wpaRsnIE ) );
12945 }
12946 else if( csrIsProfileRSN( pProfile ) )
12947 {
12948 // Insert the RSN IE into the join request
12949 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12950 (tCsrRSNIe *)( wpaRsnIE ) );
12951 }
12952#ifdef FEATURE_WLAN_WAPI
12953 else if( csrIsProfileWapi( pProfile ) )
12954 {
12955 // Insert the WAPI IE into the join request
12956 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12957 (tCsrWapiIe *)( wpaRsnIE ) );
12958 }
12959#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012960 else
12961 {
12962 ieLen = 0;
12963 }
12964 //remember the IE for future use
12965 if( ieLen )
12966 {
12967 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12968 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012969 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 -070012970 ieLen = DOT11F_IE_RSN_MAX_LEN;
12971 }
12972#ifdef FEATURE_WLAN_WAPI
12973 if( csrIsProfileWapi( pProfile ) )
12974 {
12975 //Check whether we need to allocate more memory
12976 if(ieLen > pSession->nWapiReqIeLength)
12977 {
12978 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12979 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012980 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012981 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012982 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12983 if (NULL == pSession->pWapiReqIE)
12984 status = eHAL_STATUS_FAILURE;
12985 else
12986 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 if(!HAL_STATUS_SUCCESS(status)) break;
12988 }
12989 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012990 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012991 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012992 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012993 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012994 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012995 pBuf += ieLen;
12996 }
12997 else//should be WPA/WPA2 otherwise
12998#endif /* FEATURE_WLAN_WAPI */
12999 {
13000 //Check whether we need to allocate more memory
13001 if(ieLen > pSession->nWpaRsnReqIeLength)
13002 {
13003 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
13004 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013005 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013006 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013007 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
13008 if (NULL == pSession->pWpaRsnReqIE)
13009 status = eHAL_STATUS_FAILURE;
13010 else
13011 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013012 if(!HAL_STATUS_SUCCESS(status)) break;
13013 }
13014 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013015 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013016 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013017 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013018 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013019 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013020 pBuf += ieLen;
13021 }
13022 }
13023 else
13024 {
13025 //free whatever old info
13026 pSession->nWpaRsnReqIeLength = 0;
13027 if(pSession->pWpaRsnReqIE)
13028 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013029 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013030 pSession->pWpaRsnReqIE = NULL;
13031 }
13032#ifdef FEATURE_WLAN_WAPI
13033 pSession->nWapiReqIeLength = 0;
13034 if(pSession->pWapiReqIE)
13035 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013036 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013037 pSession->pWapiReqIE = NULL;
13038 }
13039#endif /* FEATURE_WLAN_WAPI */
13040 //length is two bytes
13041 *pBuf = 0;
13042 *(pBuf + 1) = 0;
13043 pBuf += 2;
13044 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013045#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013046 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013047 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013048 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070013049 //length is two bytes
13050 *pBuf = 0;
13051 *(pBuf + 1) = 0;
13052 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013053 }
13054 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013055 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013056 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013057 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013058 {
13059 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013060#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013061 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013062 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013063 pSession->suppCckmIeInfo.cckmIe, ieLen);
13064#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013065 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013066 pSession,
13067 pProfile,
13068 pBssDescription,
13069 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013070 pSession->nWpaRsnReqIeLength,
13071 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013072#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013073 }
13074 else
13075 {
13076 ieLen = 0;
13077 }
13078 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13079 if( ieLen )
13080 {
13081 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13082 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013083 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013084 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013085 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013086 pBuf += ieLen;
13087 }
13088 else
13089 {
13090 //Indicate you have no CCKM IE
13091 //length is two bytes
13092 *pBuf = 0;
13093 *(pBuf + 1) = 0;
13094 pBuf += 2;
13095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013096 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013097#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013098 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013099 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 {
13101 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013102 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013103 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013104 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013105 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013106 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013107 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013108 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013109 pBuf += ieLen;
13110 }
13111 else
13112 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013113 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013114 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013115 *pBuf = 0;
13116 *(pBuf + 1) = 0;
13117 pBuf += 2;
13118 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013119 // addIEAssoc
13120 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13121 {
13122 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013123 if(ieLen > pSession->nAddIEAssocLength)
13124 {
13125 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013126 {
13127 vos_mem_free(pSession->pAddIEAssoc);
13128 }
13129 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13130 if (NULL == pSession->pAddIEAssoc)
13131 status = eHAL_STATUS_FAILURE;
13132 else
13133 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013134 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013136 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013137 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013138 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013139 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013140 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013141 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013142 pBuf += ieLen;
13143 }
13144 else
13145 {
13146 pSession->nAddIEAssocLength = 0;
13147 if(pSession->pAddIEAssoc)
13148 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013149 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013150 pSession->pAddIEAssoc = NULL;
13151 }
13152 *pBuf = 0;
13153 *(pBuf + 1) = 0;
13154 pBuf += 2;
13155 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013156
13157 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013158 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013159 //Unmask any AC in reassoc that is ACM-set
13160 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13161 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013162 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013163 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13164 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013165#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013166 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013167#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013168 }
13169 else
13170 {
13171 uapsd_mask = 0;
13172 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013173 }
13174 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013175
Jeff Johnson295189b2012-06-20 16:38:30 -070013176 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013177 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013178 pBuf += sizeof(tANI_U32);
13179
Jeff Johnson295189b2012-06-20 16:38:30 -070013180 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013181 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013182 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013183#ifdef WLAN_FEATURE_11W
13184 //MgmtEncryption
13185 if (pProfile->MFPEnabled)
13186 {
13187 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13188 }
13189 else
13190 {
13191 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13192 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013193 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013194 pBuf += sizeof(tANI_U32);
13195#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013196#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013197 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013198 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013199#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013200 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013201 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013202#endif
13203 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013204 {
13205 // is11Rconnection;
13206 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013207 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013208 pBuf += sizeof(tAniBool);
13209 }
13210 else
13211 {
13212 // is11Rconnection;
13213 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013214 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013215 pBuf += sizeof(tAniBool);
13216 }
13217#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013218#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013219
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013220 // isESEFeatureIniEnabled
13221 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013222 {
13223 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013224 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013225 pBuf += sizeof(tAniBool);
13226 }
13227 else
13228 {
13229 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013230 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013231 pBuf += sizeof(tAniBool);
13232 }
13233
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013234 /* A profile can not be both ESE and 11R. But an 802.11R AP
13235 * may be advertising support for ESE as well. So if we are
13236 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013237 * If we are associating explictly 11R only then we will get
13238 * 11R.
13239 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013240 if ((csrIsProfileESE(pProfile) ||
13241 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013242 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13243 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13244 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13245 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13246#ifdef WLAN_FEATURE_11W
13247 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013248 || (pProfile->negotiatedAuthType ==
13249 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013250#endif
13251 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013252 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013253 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013254 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013255 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013256 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013257 pBuf += sizeof(tAniBool);
13258 }
13259 else
13260 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013261 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013262 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013263 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013264 pBuf += sizeof(tAniBool);
13265 }
13266
13267 if (eWNI_SME_JOIN_REQ == messageType)
13268 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013269 tESETspecInfo eseTspec;
13270 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013271 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013272 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13273 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13274 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013275 }
13276 else if (eWNI_SME_REASSOC_REQ == messageType)
13277 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013278 if ((csrIsProfileESE(pProfile) ||
13279 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013280 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13281 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13282 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13283 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13284#ifdef WLAN_FEATURE_11W
13285 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013286 || (pProfile->negotiatedAuthType ==
13287 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013288#endif
13289 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013290 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013291 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013292 tESETspecInfo eseTspec;
13293 // ESE Tspec information
13294 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13295 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13296 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013297 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013298 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013299 if (eseTspec.numTspecs) {
13300 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13301 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013302 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013303 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013304 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013305 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013306 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013307 tESETspecInfo eseTspec;
13308 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013309 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013310 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13311 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13312 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013313 }
13314 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013315#endif // FEATURE_WLAN_ESE
13316#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013317 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013318 if (pMac->roam.configParam.isFastTransitionEnabled
13319#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013320 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013321#endif
13322 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013324 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013325 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013326 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013327 }
13328 else
13329 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013330 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013331 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013332 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013333 }
13334#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013335#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013336 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013337 {
13338 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013339 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013340 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013341 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013342 }
13343 else
13344 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013345 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013346 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013347 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013348 }
13349#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013350
13351 // txLdpcIniFeatureEnabled
13352 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13353 pBuf++;
13354
Kiran4a17ebe2013-01-31 10:43:43 -080013355 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13356 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13357 {
13358 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13359 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13360 csrApplyPower2Current(pMac);
13361 }
13362
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013363#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013364 // txBFIniFeatureEnabled
13365 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13366 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013367
13368 // txBFCsnValue
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013369 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13370 if (pIes->VHTCaps.present)
13371 {
13372 txBFCsnValue = CSR_ROAM_MIN(txBFCsnValue, pIes->VHTCaps.numSoundingDim);
13373 }
13374 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013375 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053013376
13377 /* Only enable MuBf if no other MuBF session exist
13378 * and FW and HOST is MuBF capable.
13379 */
13380 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
13381 {
13382 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
13383 pBuf++;
13384 }
13385 else
13386 {
13387 *pBuf = 0;
13388 pBuf++;
13389 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013390#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013391 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13392 pBuf++;
13393
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013394 // WME
13395 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13396 {
13397 //WME enabled
13398 dwTmp = pal_cpu_to_be32(TRUE);
13399 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13400 pBuf += sizeof(tAniBool);
13401 }
13402 else
13403 {
13404 dwTmp = pal_cpu_to_be32(FALSE);
13405 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13406 pBuf += sizeof(tAniBool);
13407 }
13408
13409 // QOS
13410 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13411 {
13412 //QOS enabled
13413 dwTmp = pal_cpu_to_be32(TRUE);
13414 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13415 pBuf += sizeof(tAniBool);
13416 }
13417 else
13418 {
13419 dwTmp = pal_cpu_to_be32(FALSE);
13420 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13421 pBuf += sizeof(tAniBool);
13422 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013423 //BssDesc
13424 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13425 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013426
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013427 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053013428 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
13429 pMsg = NULL;
13430
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013431 if(!HAL_STATUS_SUCCESS(status))
13432 {
13433 break;
13434 }
13435 else
13436 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013437#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013438 if (eWNI_SME_JOIN_REQ == messageType)
13439 {
13440 //Tush-QoS: notify QoS module that join happening
13441 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13442 }
13443 else if (eWNI_SME_REASSOC_REQ == messageType)
13444 {
13445 //Tush-QoS: notify QoS module that reassoc happening
13446 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13447 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013448#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013449 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013450 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053013451
13452 if (pMsg != NULL)
13453 {
13454 vos_mem_free( pMsg );
13455 }
13456
Jeff Johnson295189b2012-06-20 16:38:30 -070013457 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013458}
13459
Jeff Johnson295189b2012-06-20 16:38:30 -070013460//
13461eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13462{
13463 eHalStatus status = eHAL_STATUS_SUCCESS;
13464 tSirSmeDisassocReq *pMsg;
13465 tANI_U8 *pBuf;
13466 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013467 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13468 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13469 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013470 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013471 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13472 if (NULL == pMsg)
13473 status = eHAL_STATUS_FAILURE;
13474 else
13475 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013476 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013477 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013478 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13479 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013480 pBuf = &pMsg->sessionId;
13481 // sessionId
13482 *pBuf++ = (tANI_U8)sessionId;
13483 // transactionId
13484 *pBuf = 0;
13485 *( pBuf + 1 ) = 0;
13486 pBuf += sizeof(tANI_U16);
13487
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013488 if ( (pSession->pCurRoamProfile != NULL) &&
13489 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13490 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013491 {
13492 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013493 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13494 sizeof( tSirMacAddr ));
13495 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013496 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013497 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013498 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13499 //perMacAddr is passed as bssId for softAP
13500 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013501 pBuf = pBuf + sizeof ( tSirMacAddr );
13502 }
13503 else
13504 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013505 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013506 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13507 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013508 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013509 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13510 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013511 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013512 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013513 if(!HAL_STATUS_SUCCESS(status))
13514 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013515 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013516 break;
13517 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013518 // reasonCode
13519 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013520 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13521 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013522 if(!HAL_STATUS_SUCCESS(status))
13523 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013524 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013525 break;
13526 }
13527 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013528 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13529 Here we should not send the disassoc over the air to the AP */
13530 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13531#ifdef WLAN_FEATURE_VOWIFI_11R
13532 && csrRoamIs11rAssoc(pMac)
13533#endif
13534 )
13535 {
13536 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13537 }
13538 pBuf += sizeof(tANI_U8);
13539 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013540 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013541 return( status );
13542}
Jeff Johnson295189b2012-06-20 16:38:30 -070013543eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13544{
13545 eHalStatus status = eHAL_STATUS_SUCCESS;
13546 tSirSmeTkipCntrMeasReq *pMsg;
13547 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013548 do
13549 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013550 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13551 if ( NULL == pMsg )
13552 status = eHAL_STATUS_FAILURE;
13553 else
13554 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013555 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013556 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013557 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13558 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013559 pBuf = &pMsg->sessionId;
13560 // sessionId
13561 *pBuf++ = (tANI_U8)sessionId;
13562 // transactionId
13563 *pBuf = 0;
13564 *( pBuf + 1 ) = 0;
13565 pBuf += sizeof(tANI_U16);
13566 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013567 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13568 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013569 pBuf = pBuf + sizeof ( tSirMacAddr );
13570 // bEnable
13571 *pBuf = (tANI_BOOLEAN)bEnable;
13572 if(!HAL_STATUS_SUCCESS(status))
13573 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013574 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013575 break;
13576 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013578 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013579 return( status );
13580}
Jeff Johnson295189b2012-06-20 16:38:30 -070013581eHalStatus
13582csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13583 VOS_MODULE_ID modId, tSirMacAddr bssId,
13584 void *pUsrContext, void *pfnSapEventCallback,
13585 tANI_U8 *pAssocStasBuf )
13586{
13587 eHalStatus status = eHAL_STATUS_SUCCESS;
13588 tSirSmeGetAssocSTAsReq *pMsg;
13589 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13590 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013591 do
13592 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013593 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13594 if ( NULL == pMsg )
13595 status = eHAL_STATUS_FAILURE;
13596 else
13597 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013598 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013599 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013600 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013601 pBuf = (tANI_U8 *)&pMsg->bssId;
13602 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013603 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013604 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013605 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013606 // modId
13607 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013608 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013609 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013610 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013611 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13612 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013613 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013614 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13615 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013616 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013617 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13618 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013619 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 status = palSendMBMessage( pMac->hHdd, pMsg );
13621 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013622 return( status );
13623 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013624eHalStatus
13625csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13626 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13627 {
13628 eHalStatus status = eHAL_STATUS_SUCCESS;
13629 tSirSmeGetWPSPBCSessionsReq *pMsg;
13630 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013631
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 do
13633 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013634 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13635 if ( NULL == pMsg )
13636 status = eHAL_STATUS_FAILURE;
13637 else
13638 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013639 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013640 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013641 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013642 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013643 VOS_ASSERT(pBuf);
13644
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013646 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013647 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13648 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013649 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013650 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13651 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013652 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013653 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013654 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013655 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013656 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013657 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013658 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013659 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013660 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013661 return( status );
13662}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013663
13664eHalStatus
13665csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13666{
13667 tpSirChangeBIParams pMsg;
13668 tANI_U16 len = 0;
13669 eHalStatus status = eHAL_STATUS_SUCCESS;
13670 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13671
13672 if(!pSession)
13673 {
13674 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13675 return eHAL_STATUS_FAILURE;
13676 }
13677
13678 //NO need to update the Beacon Params if update beacon parameter flag is not set
13679 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13680 return eHAL_STATUS_SUCCESS;
13681
13682 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13683
13684 /* Create the message and send to lim */
13685 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013686 pMsg = vos_mem_malloc(len);
13687 if ( NULL == pMsg )
13688 status = eHAL_STATUS_FAILURE;
13689 else
13690 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013691 if(HAL_STATUS_SUCCESS(status))
13692 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013693 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013694 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13695 pMsg->length = len;
13696
13697 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013698 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13699 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013700 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13701 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013702 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013703 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013704 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13705 status = palSendMBMessage(pMac->hHdd, pMsg);
13706 }
13707 return status;
13708}
13709
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +053013710#ifdef WLAN_FEATURE_AP_HT40_24G
13711eHalStatus csrSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 cbMode)
13712{
13713 tpSirSetHT2040Mode pMsg;
13714 tANI_U16 len = 0;
13715 eHalStatus status = eHAL_STATUS_SUCCESS;
13716 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13717
13718 if(!pSession)
13719 {
13720 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13721 return eHAL_STATUS_FAILURE;
13722 }
13723
13724 /* Create the message and send to lim */
13725 len = sizeof(tSirSetHT2040Mode);
13726 pMsg = vos_mem_malloc(len);
13727
13728 if ( NULL == pMsg )
13729 {
13730 smsLog( pMac, LOGE, FL("Memory Allocation Fail !!!"));
13731 status = eHAL_STATUS_FAILURE;
13732 }
13733 else
13734 status = eHAL_STATUS_SUCCESS;
13735
13736 if(HAL_STATUS_SUCCESS(status))
13737 {
13738 vos_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
13739 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
13740 pMsg->length = len;
13741
13742 // bssId
13743 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13744 sizeof(tSirMacAddr));
13745
13746 smsLog( pMac, LOGW, FL("CSR Attempting to set "
13747 "HT20/40 mode for Bssid= "MAC_ADDRESS_STR),
13748 MAC_ADDR_ARRAY(pMsg->bssId));
13749
13750 pMsg->sessionId = sessionId;
13751 pMsg->cbMode = cbMode;
13752
13753 smsLog(pMac, LOGW, FL("session %d Channel Bonding: %d"),
13754 sessionId, cbMode);
13755
13756 status = palSendMBMessage(pMac->hHdd, pMsg);
13757 }
13758 return status;
13759}
13760#endif
13761
Jeff Johnson295189b2012-06-20 16:38:30 -070013762eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13763{
13764 eHalStatus status = eHAL_STATUS_SUCCESS;
13765 tSirSmeDeauthReq *pMsg;
13766 tANI_U8 *pBuf;
13767 tANI_U16 wTmp;
13768 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13769 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13770 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013771 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013772 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13773 if ( NULL == pMsg )
13774 status = eHAL_STATUS_FAILURE;
13775 else
13776 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013777 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013778 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013779 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13780 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13781 //sessionId
13782 pBuf = &pMsg->sessionId;
13783 *pBuf++ = (tANI_U8)sessionId;
13784
13785 //tansactionId
13786 *pBuf = 0;
13787 *(pBuf + 1 ) = 0;
13788 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013789 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013790 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013791 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13792 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013793 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13794 sizeof( pMsg->peerMacAddr ) );
13795 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013796 pBuf = pBuf + sizeof(tSirMacAddr);
13797 }
13798 else
13799 {
13800 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013801 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13802 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013803 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 }
13805 if(!HAL_STATUS_SUCCESS(status))
13806 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013807 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013808 break;
13809 }
13810 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013811 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13812 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013813 pBuf = pBuf + sizeof(tSirMacAddr);
13814 if(!HAL_STATUS_SUCCESS(status))
13815 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013816 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013817 break;
13818 }
13819 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013820 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13821 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013822 if(!HAL_STATUS_SUCCESS(status))
13823 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013824 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013825 break;
13826 }
13827 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013828 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013829 return( status );
13830}
13831
Jeff Johnson295189b2012-06-20 16:38:30 -070013832eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13833{
13834 eHalStatus status = eHAL_STATUS_SUCCESS;
13835 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013837 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13838 if ( NULL == pMsg )
13839 status = eHAL_STATUS_FAILURE;
13840 else
13841 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013842 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013843 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013844 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13845 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13846 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013847 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13848 sizeof(pMsg->peerMacAddr));
13849 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013850 if(!HAL_STATUS_SUCCESS(status))
13851 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013852 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013853 break;
13854 }
13855//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013856 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13857 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013858 if(!HAL_STATUS_SUCCESS(status))
13859 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013860 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013861 break;
13862 }
13863//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013864 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013865 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013866 return( status );
13867}
13868
Jeff Johnson295189b2012-06-20 16:38:30 -070013869eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13870{
13871 eHalStatus status = eHAL_STATUS_SUCCESS;
13872 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013873 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013874 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13875 if ( NULL == pMsg )
13876 status = eHAL_STATUS_FAILURE;
13877 else
13878 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013879 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013880 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13882 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13883 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013884 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13885 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013886 if(!HAL_STATUS_SUCCESS(status))
13887 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013888 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013889 break;
13890 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013891 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13892 sizeof(pMsg->peerMacAddr));
13893 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013894 if(!HAL_STATUS_SUCCESS(status))
13895 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013896 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013897 break;
13898 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013899 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013900 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013901 return( status );
13902}
Jeff Johnson295189b2012-06-20 16:38:30 -070013903eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13904{
13905 eHalStatus status = eHAL_STATUS_SUCCESS;
13906 tSirSmeAssocCnf *pMsg;
13907 tANI_U8 *pBuf;
13908 tSirResultCodes statusCode;
13909 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013910 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013911 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13912 if ( NULL == pMsg )
13913 status = eHAL_STATUS_FAILURE;
13914 else
13915 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013916 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013917 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13919 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013920 pBuf = (tANI_U8 *)&pMsg->statusCode;
13921 if(HAL_STATUS_SUCCESS(Halstatus))
13922 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13923 else
13924 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013925 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013926 pBuf += sizeof(tSirResultCodes);
13927 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013928 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13929 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013930 pBuf += sizeof (tSirMacAddr);
13931 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013932 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13933 sizeof(tSirMacAddr));
13934 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013935 pBuf += sizeof (tSirMacAddr);
13936 // aid
13937 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013938 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013939 pBuf += sizeof (tANI_U16);
13940 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013941 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13942 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013943 pBuf += sizeof (tSirMacAddr);
13944 // alternateChannelId
13945 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013946 status = palSendMBMessage( pMac->hHdd, pMsg );
13947 if(!HAL_STATUS_SUCCESS(status))
13948 {
13949 //pMsg is freed by palSendMBMessage
13950 break;
13951 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013952 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013953 return( status );
13954}
Jeff Johnson295189b2012-06-20 16:38:30 -070013955eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13956 tpSirSmeAssocInd pAssocInd,
13957 eHalStatus Halstatus,
13958 tANI_U8 sessionId)
13959{
13960 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013961 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13962 tANI_U8 *pBuf;
13963 tSirResultCodes statusCode;
13964 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013965 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013966 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13967 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13968 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013969
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13971 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13972
13973 pMsg->sessionId = sessionId;
13974
13975 pBuf = (tANI_U8 *)&pMsg->statusCode;
13976 if(HAL_STATUS_SUCCESS(Halstatus))
13977 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13978 else
13979 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013980 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 pBuf += sizeof(tSirResultCodes);
13982 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013983 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013984 pBuf += sizeof (tSirMacAddr);
13985 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013986 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13987 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 pBuf += sizeof (tSirMacAddr);
13989 // StaId
13990 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013991 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013992 pBuf += sizeof (tANI_U16);
13993 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013994 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013995 pBuf += sizeof (tSirMacAddr);
13996 // alternateChannelId
13997 *pBuf = 11;
13998 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013999 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070014000 //Wmm
14001 *pBuf = pAssocInd->wmmEnabledSta;
14002 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070014003 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053014004 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070014005 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070014006 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053014007 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070014008 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070014009 //reassocReq
14010 *pBuf = pAssocInd->reassocReq;
14011 pBuf += sizeof (tANI_U8);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053014012#ifdef WLAN_FEATURE_AP_HT40_24G
14013 // 40 MHz Intolerant
14014 *pBuf = pAssocInd->HT40MHzIntoEnabledSta;
14015 pBuf += sizeof (tANI_U8);
14016#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014017 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
14018 msgQ.bodyptr = pMsg;
14019 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014020 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014021 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053014022 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070014023}
Jeff Johnson295189b2012-06-20 16:38:30 -070014024
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014025eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
14027 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
14028 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
14029 tANI_U8 *pKeyRsc )
14030{
14031 tSirSmeSetContextReq *pMsg;
14032 tANI_U16 msgLen;
14033 eHalStatus status = eHAL_STATUS_FAILURE;
14034 tAniEdType tmpEdType;
14035 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053014036 tANI_U8 *pBuf = NULL;
14037 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014038 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Sushant Kaushike7de85f2014-06-16 17:13:30 +053014039 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
14040 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014041 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014042 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014043 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
14044 // key set. Since we only support upto one key, we always allocate memory for 1 key
14045 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
14046 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
14047 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
14048 ( sizeof( pMsg->keyMaterial.key ) );
14049
Kiet Lam64c1b492013-07-12 13:56:44 +053014050 pMsg = vos_mem_malloc(msgLen);
14051 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14052 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014053 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
14054 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014055 //sessionId
14056 pBuf = &pMsg->sessionId;
14057 *pBuf = (tANI_U8)sessionId;
14058 pBuf++;
14059 // transactionId
14060 *pBuf = 0;
14061 *(pBuf + 1) = 0;
14062 pBuf += sizeof(tANI_U16);
14063 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014064 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014065
14066 pBuf += sizeof(tSirMacAddr);
14067
14068 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014069 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14070 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014071
14072 pBuf += sizeof(tSirMacAddr);
14073
14074 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014075 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
14076 // in the tSirKeyMaterial keyMaterial; field).
14077 //
14078 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
14079 // shorter than this max size. Is LIM interpreting this ok ?
14080 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 -070014081 // set pMsg->keyMaterial.edType
14082 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014083 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014084 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070014085 // set the pMsg->keyMaterial.numKeys field
14086 *p = numKeys;
14087 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070014088 // set pSirKey->keyId = keyId;
14089 *p = keyId;
14090 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014091 // set pSirKey->unicast = (tANI_U8)fUnicast;
14092 *p = (tANI_U8)fUnicast;
14093 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070014094 // set pSirKey->keyDirection = aniKeyDirection;
14095 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053014096 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070014097 p += sizeof(tAniKeyDirection);
14098 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053014099 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070014101 // set pSirKey->paeRole
14102 *p = paeRole; // 0 is Supplicant
14103 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014104 // set pSirKey->keyLength = keyLength;
14105 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070014106 if ( keyLength && pKey )
14107 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014108 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070014109 if(keyLength == 16)
14110 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014111 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 -070014112 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
14113 pKey[5], pKey[6], pKey[7], pKey[8],
14114 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
14115 }
14116 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014117 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014118 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014119 return( status );
14120}
14121
Jeff Johnson295189b2012-06-20 16:38:30 -070014122eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
14123 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
14124{
14125 eHalStatus status;
14126 tSirSmeStartBssReq *pMsg;
14127 tANI_U8 *pBuf = NULL;
14128 tANI_U8 *wTmpBuf = NULL;
14129 tANI_U16 msgLen, wTmp;
14130 tANI_U32 dwTmp;
14131 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070014132 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014133 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070014134 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014135
14136 if(!pSession)
14137 {
14138 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14139 return eHAL_STATUS_FAILURE;
14140 }
14141
Jeff Johnson295189b2012-06-20 16:38:30 -070014142 do {
14143 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
14144 pSession->joinFailStatusCode.reasonCode = 0;
14145 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014146 pMsg = vos_mem_malloc(msgLen);
14147 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14148 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014149 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014150 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014151 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014152 //sessionId
14153 *pBuf = (tANI_U8)sessionId;
14154 pBuf++;
14155 // transactionId
14156 *pBuf = 0;
14157 *(pBuf + 1) = 0;
14158 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014159 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014160 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014161 pBuf += sizeof(tSirMacAddr);
14162 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014163 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014164 pBuf += sizeof(tSirMacAddr);
14165 // beaconInterval
14166 if( pBssDesc && pBssDesc->beaconInterval )
14167 {
14168 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
14169 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014170 else if(pParam->beaconInterval)
14171 {
14172 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
14173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014174 else
14175 {
14176 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
14177 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070014178 if(csrIsconcurrentsessionValid (pMac, sessionId,
14179 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070014180 == eHAL_STATUS_SUCCESS )
14181 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014182 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070014183 pParam->bssPersona);
14184 //Update the beacon Interval
14185 pParam->beaconInterval = wTmp;
14186 }
14187 else
14188 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014189 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014190 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053014191 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070014192 return status;
14193 }
14194
Kiet Lam64c1b492013-07-12 13:56:44 +053014195 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014196 pBuf += sizeof(tANI_U16);
14197 // dot11mode
14198 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
14199 pBuf += 1;
14200 // bssType
14201 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053014202 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014203 pBuf += sizeof(tSirBssType);
14204 // ssId
14205 if( pParam->ssId.length )
14206 {
14207 // ssId len
14208 *pBuf = pParam->ssId.length;
14209 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014210 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070014211 pBuf += pParam->ssId.length;
14212 }
14213 else
14214 {
14215 *pBuf = 0;
14216 pBuf++;
14217 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014218 // set the channel Id
14219 *pBuf = pParam->operationChn;
14220 pBuf++;
14221 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070014222 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014223 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070014224 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014225
Jeff Johnson295189b2012-06-20 16:38:30 -070014226 // Set privacy
14227 *pBuf = pParam->privacy;
14228 pBuf++;
14229
14230 //Set Uapsd
14231 *pBuf = pParam->ApUapsdEnable;
14232 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014233 //Set SSID hidden
14234 *pBuf = pParam->ssidHidden;
14235 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014236 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
14237 pBuf++;
14238
14239 //Ht protection Enable/Disable
14240 *pBuf = (tANI_U8)pParam->protEnabled;
14241 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014242 //Enable Beacons to Receive for OBSS protection Enable/Disable
14243 *pBuf = (tANI_U8)pParam->obssProtEnabled;
14244 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014245 //set cfg related to protection
14246 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053014247 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014248 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014249 // Set Auth type
14250 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014251 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014252 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014253 // Set DTIM
14254 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053014255 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014256 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014257 // Set wps_state
14258 *pBuf = pParam->wps_state;
14259 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080014260 // set isCoalesingInIBSSAllowed
14261 *pBuf = pMac->isCoalesingInIBSSAllowed;
14262 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014263 //Persona
14264 *pBuf = (tANI_U8)pParam->bssPersona;
14265 pBuf++;
14266
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080014267 //txLdpcIniFeatureEnabled
14268 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
14269 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070014270
Chet Lanctot8cecea22014-02-11 19:09:36 -080014271#ifdef WLAN_FEATURE_11W
14272 // Set MFP capable/required
14273 *pBuf = (tANI_U8)pParam->mfpCapable;
14274 pBuf++;
14275 *pBuf = (tANI_U8)pParam->mfpRequired;
14276 pBuf++;
14277#endif
14278
krunal soni4f087d22013-07-29 16:32:26 -070014279 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070014280 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
14281 {
14282 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053014283 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014284 break;
14285 }
14286 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053014287 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014288 pBuf += sizeof(tANI_U16);
14289 if( wTmp )
14290 {
14291 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053014292 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014293 pBuf += wTmp;
14294 }
14295 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014296 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014297 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014298 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
14299 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014300 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
14301 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070014302 pBuf += pParam->operationalRateSet.numRates ;
14303 *pBuf++ = pParam->extendedRateSet.numRates;
14304 if(0 != pParam->extendedRateSet.numRates)
14305 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014306 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
14307 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070014308 pBuf += pParam->extendedRateSet.numRates;
14309 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053014310#ifdef WLAN_FEATURE_AP_HT40_24G
14311 *pBuf++ = (tANI_U8)pMac->roam.configParam.apHT40_24GEnabled;
14312#endif
krunal sonie9002db2013-11-25 14:24:17 -080014313
Jeff Johnson295189b2012-06-20 16:38:30 -070014314 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
14315 pMsg->length = pal_cpu_to_be16(msgLen);
14316
14317 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014318 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014319 return( status );
14320}
14321
Jeff Johnson295189b2012-06-20 16:38:30 -070014322eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
14323{
14324 eHalStatus status = eHAL_STATUS_FAILURE;
14325 tSirSmeStopBssReq *pMsg;
14326 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14327 tANI_U8 *pBuf;
14328 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070014329
14330 if(!pSession)
14331 {
14332 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14333 return eHAL_STATUS_FAILURE;
14334 }
14335
Jeff Johnson295189b2012-06-20 16:38:30 -070014336 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014337 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14338 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14339 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014340 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14341 pBuf = &pMsg->sessionId;
14342 //sessionId
14343 *pBuf = (tANI_U8)sessionId;
14344 pBuf++;
14345 // transactionId
14346 *pBuf = 0;
14347 pBuf += sizeof(tANI_U16);
14348 //reason code
14349 *pBuf = 0;
14350 pBuf += sizeof(tSirResultCodes);
14351 // bssid
14352 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14353 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14354 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014355 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
14356 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014357 }
14358 else
14359 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014360 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14361 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014362 }
14363 pBuf += sizeof(tSirMacAddr);
14364 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
14365 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014366 status = palSendMBMessage( pMac->hHdd, pMsg );
14367#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053014368 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14369 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14370 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014371 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14372 pMsg->reasonCode = 0;
14373 // bssid
14374 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14375 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14376 {
14377 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
14378 }
14379 else
14380 {
14381 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
14382 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014383 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014384 pMsg->transactionId = 0;
14385 pMsg->sessionId = (tANI_U8)sessionId;
14386 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
14387 status = palSendMBMessage( pMac->hHdd, pMsg );
14388#endif
14389 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014390 return( status );
14391}
14392
Jeff Johnson295189b2012-06-20 16:38:30 -070014393eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14394 tCsrRoamModifyProfileFields *pModProfileFields,
14395 tANI_U32 *pRoamId, v_BOOL_t fForce)
14396{
Jeff Johnson295189b2012-06-20 16:38:30 -070014397 eHalStatus status = eHAL_STATUS_FAILURE;
14398 tANI_U32 roamId = 0;
14399 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014400 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014401 (fForce || (!vos_mem_compare( &pModProfileFields,
14402 &pSession->connectedProfile.modifyProfileFields,
14403 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014404 {
14405 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14406 if(pRoamId)
14407 {
14408 *pRoamId = roamId;
14409 }
14410
Jeff Johnson295189b2012-06-20 16:38:30 -070014411 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14412 eCsrSmeIssuedReassocToSameAP, roamId,
14413 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014414 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014415 return status;
14416}
Jeff Johnson295189b2012-06-20 16:38:30 -070014417static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14418{
14419 eHalStatus status = eHAL_STATUS_SUCCESS;
14420 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014421 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014422 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14423 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14424 return (status);
14425}
Jeff Johnson295189b2012-06-20 16:38:30 -070014426eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14427{
14428 eHalStatus status = eHAL_STATUS_SUCCESS;
14429 tListElem *pEntry = NULL;
14430 tSmeCmd *pCommand = NULL;
14431 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014432 do
14433 {
14434 if(pMsg == NULL)
14435 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014436 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014437 status = eHAL_STATUS_FAILURE;
14438 break;
14439 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014440 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14441 if(pEntry)
14442 {
14443 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14444 if(eSmeCommandAddStaSession == pCommand->command)
14445 {
14446 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014447 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053014448 if (pRsp->status == eSIR_FAILURE) {
14449 VOS_ASSERT( 0 );
14450 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014451 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014452 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014453 //Remove this command out of the active list
14454 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14455 {
14456 //Now put this command back on the avilable command list
14457 csrReleaseCommand(pMac, pCommand);
14458 }
14459 smeProcessPendingQueue( pMac );
14460 }
14461 else
14462 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014463 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 -070014464 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014465 status = eHAL_STATUS_FAILURE;
14466 break;
14467 }
14468 }
14469 else
14470 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014471 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 -070014472 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014473 status = eHAL_STATUS_FAILURE;
14474 break;
14475 }
14476 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014477 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014478}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014479eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14480 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014481{
14482 tSirSmeAddStaSelfReq *pMsg;
14483 tANI_U16 msgLen;
14484 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014485 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014486 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014487 pMsg = vos_mem_malloc(msgLen);
14488 if ( NULL == pMsg ) break;
14489 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014490 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14491 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014492 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014493 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014494 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14495
14496 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14497
Arif Hussain24bafea2013-11-15 15:10:03 -080014498 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14499 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014500 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014501 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014502 return( status );
14503}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014504eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14505 tANI_U32 sessionId,
14506 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014507{
14508 eHalStatus status = eHAL_STATUS_SUCCESS;
14509 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014510 pCommand = csrGetCommandBuffer(pMac);
14511 if(NULL == pCommand)
14512 {
14513 status = eHAL_STATUS_RESOURCES;
14514 }
14515 else
14516 {
14517 pCommand->command = eSmeCommandAddStaSession;
14518 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014519 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14520 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014521 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014522 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14523 if( !HAL_STATUS_SUCCESS( status ) )
14524 {
14525 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014526 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014527 }
14528 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014529 return (status);
14530}
Jeff Johnson295189b2012-06-20 16:38:30 -070014531eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14532{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014533 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014534}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014535eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14536 csrRoamCompleteCallback callback,
14537 void *pContext, tANI_U8 *pSelfMacAddr,
14538 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014539{
14540 eHalStatus status = eHAL_STATUS_SUCCESS;
14541 tANI_U32 i;
14542 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014543 *pbSessionId = CSR_SESSION_ID_INVALID;
14544 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14545 {
14546 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14547 {
14548 pSession = CSR_GET_SESSION( pMac, i );
14549 status = eHAL_STATUS_SUCCESS;
14550 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14551 pSession->sessionId = (tANI_U8)i;
14552 pSession->callback = callback;
14553 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014554 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014555 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014556 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14557 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014558 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014559 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014560 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014561 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014562 break;
14563 }
14564#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014565 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14566 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014567 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014568 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014569 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014570 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014571 break;
14572 }
14573#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014574 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014575 break;
14576 }
14577 }
14578 if( CSR_ROAM_SESSION_MAX == i )
14579 {
14580 //No session is available
14581 status = eHAL_STATUS_RESOURCES;
14582 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014583 return ( status );
14584}
Jeff Johnson295189b2012-06-20 16:38:30 -070014585eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14586{
14587 eHalStatus status = eHAL_STATUS_SUCCESS;
14588 tListElem *pEntry = NULL;
14589 tSmeCmd *pCommand = NULL;
14590 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014591 do
14592 {
14593 if(pMsg == NULL)
14594 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014595 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014596 status = eHAL_STATUS_FAILURE;
14597 break;
14598 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014599 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14600 if(pEntry)
14601 {
14602 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14603 if(eSmeCommandDelStaSession == pCommand->command)
14604 {
14605 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014606 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014607 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014608 //This session is done.
14609 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014610 if(pCommand->u.delStaSessionCmd.callback)
14611 {
14612
14613 status = sme_ReleaseGlobalLock( &pMac->sme );
14614 if ( HAL_STATUS_SUCCESS( status ) )
14615 {
14616 pCommand->u.delStaSessionCmd.callback(
14617 pCommand->u.delStaSessionCmd.pContext);
14618 status = sme_AcquireGlobalLock( &pMac->sme );
14619 if (! HAL_STATUS_SUCCESS( status ) )
14620 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014621 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014622 return status;
14623 }
14624 }
14625 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014626 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014627 }
14628 }
14629
14630 //Remove this command out of the active list
14631 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14632 {
14633 //Now put this command back on the avilable command list
14634 csrReleaseCommand(pMac, pCommand);
14635 }
14636 smeProcessPendingQueue( pMac );
14637 }
14638 else
14639 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014640 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 -070014641 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014642 status = eHAL_STATUS_FAILURE;
14643 break;
14644 }
14645 }
14646 else
14647 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014648 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 -070014649 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014650 status = eHAL_STATUS_FAILURE;
14651 break;
14652 }
14653 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014654 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014655}
Jeff Johnson295189b2012-06-20 16:38:30 -070014656eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14657{
14658 tSirSmeDelStaSelfReq *pMsg;
14659 tANI_U16 msgLen;
14660 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014661 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014662 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14663 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014664 pMsg = vos_mem_malloc(msgLen);
14665 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14666 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014667 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14668 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014669 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014670 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14671 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014672 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014673 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014674 return( status );
14675}
Jeff Johnson295189b2012-06-20 16:38:30 -070014676eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14677 tSirMacAddr sessionMacAddr,
14678 csrRoamSessionCloseCallback callback,
14679 void *pContext)
14680{
14681 eHalStatus status = eHAL_STATUS_SUCCESS;
14682 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014683 pCommand = csrGetCommandBuffer(pMac);
14684 if(NULL == pCommand)
14685 {
14686 status = eHAL_STATUS_RESOURCES;
14687 }
14688 else
14689 {
14690 pCommand->command = eSmeCommandDelStaSession;
14691 pCommand->sessionId = (tANI_U8)sessionId;
14692 pCommand->u.delStaSessionCmd.callback = callback;
14693 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014694 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14695 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014696 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14697 if( !HAL_STATUS_SUCCESS( status ) )
14698 {
14699 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014700 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014701 }
14702 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014703 return (status);
14704}
Jeff Johnson295189b2012-06-20 16:38:30 -070014705eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14706{
14707 return csrSendMBDelSelfStaReqMsg( pMac,
14708 pCommand->u.delStaSessionCmd.selfMacAddr );
14709}
Jeff Johnson295189b2012-06-20 16:38:30 -070014710static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14711{
14712 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14713 tListElem *pEntry, *pNext;
14714 tSmeCmd *pCommand;
14715 tDblLinkList localList;
14716
14717 vos_mem_zero(&localList, sizeof(tDblLinkList));
14718 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14719 {
14720 smsLog(pMac, LOGE, FL(" failed to open list"));
14721 return;
14722 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014723 csrLLLock(pList);
14724 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14725 while(pEntry != NULL)
14726 {
14727 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14728 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14729 if(pCommand->sessionId == sessionId)
14730 {
14731 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14732 {
14733 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14734 }
14735 }
14736 pEntry = pNext;
14737 }
14738 csrLLUnlock(pList);
14739
14740 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14741 {
14742 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14743 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14744 }
14745 csrLLClose(&localList);
14746}
14747
Jeff Johnson295189b2012-06-20 16:38:30 -070014748void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14749{
14750 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14751 {
14752 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014753 csrRoamStop(pMac, sessionId);
14754 csrFreeConnectBssDesc(pMac, sessionId);
14755 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14756 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014757 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014758#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014759 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014760#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014761 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14762 if (pMac->fScanOffload)
14763 {
14764 purgeSmeSessionCmdList(pMac, sessionId,
14765 &pMac->sme.smeScanCmdPendingList);
14766 }
14767
Jeff Johnson295189b2012-06-20 16:38:30 -070014768 purgeCsrSessionCmdList(pMac, sessionId);
14769 csrInitSession(pMac, sessionId);
14770 }
14771}
14772
Jeff Johnson295189b2012-06-20 16:38:30 -070014773eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14774 tANI_BOOLEAN fSync,
14775 csrRoamSessionCloseCallback callback,
14776 void *pContext )
14777{
14778 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014779 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14780 {
14781 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14782 if(fSync)
14783 {
14784 csrCleanupSession(pMac, sessionId);
14785 }
14786 else
14787 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014788 purgeSmeSessionCmdList(pMac, sessionId,
14789 &pMac->sme.smeCmdPendingList);
14790 if (pMac->fScanOffload)
14791 {
14792 purgeSmeSessionCmdList(pMac, sessionId,
14793 &pMac->sme.smeScanCmdPendingList);
14794 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014795 purgeCsrSessionCmdList(pMac, sessionId);
14796 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14797 pSession->selfMacAddr, callback, pContext);
14798 }
14799 }
14800 else
14801 {
14802 status = eHAL_STATUS_INVALID_PARAMETER;
14803 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014804 return ( status );
14805}
14806
Jeff Johnson295189b2012-06-20 16:38:30 -070014807static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14808{
14809 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014810
14811 if(!pSession)
14812 {
14813 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14814 return;
14815 }
14816
Jeff Johnson295189b2012-06-20 16:38:30 -070014817 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14818 pSession->sessionId = CSR_SESSION_ID_INVALID;
14819 pSession->callback = NULL;
14820 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014821 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14822 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14823 csrFreeRoamProfile( pMac, sessionId );
14824 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14825 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14826 csrFreeConnectBssDesc(pMac, sessionId);
14827 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014828 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14829 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014830 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014831 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014832 pSession->pWpaRsnReqIE = NULL;
14833 }
14834 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014835 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014836 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014837 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014838 pSession->pWpaRsnRspIE = NULL;
14839 }
14840 pSession->nWpaRsnRspIeLength = 0;
14841#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014842 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014843 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014844 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014845 pSession->pWapiReqIE = NULL;
14846 }
14847 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014848 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014849 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014850 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014851 pSession->pWapiRspIE = NULL;
14852 }
14853 pSession->nWapiRspIeLength = 0;
14854#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014855 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014856 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014857 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014858 }
14859 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014860
Kiet Lam64c1b492013-07-12 13:56:44 +053014861 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014862 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014863 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014864 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014865 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014866 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014867}
14868
Jeff Johnson295189b2012-06-20 16:38:30 -070014869eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14870{
14871 eHalStatus status = eHAL_STATUS_FAILURE;
14872 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014873 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14874 {
14875 if( CSR_IS_SESSION_VALID( pMac, i ) )
14876 {
14877 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14878 {
14879 //Found it
14880 status = eHAL_STATUS_SUCCESS;
14881 *pSessionId = i;
14882 break;
14883 }
14884 }
14885 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014886 return( status );
14887}
14888
Jeff Johnson295189b2012-06-20 16:38:30 -070014889//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14890//session because for IBSS, the bssid changes.
14891static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14892{
14893 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14894 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014895 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14896 {
14897 if( CSR_IS_SESSION_VALID( pMac, i ) )
14898 {
14899 pSession = CSR_GET_SESSION( pMac, i );
14900 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14901 {
14902 //Found it
14903 nRet = i;
14904 break;
14905 }
14906 }
14907 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014908 return (nRet);
14909}
Jeff Johnson295189b2012-06-20 16:38:30 -070014910static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14911{
Mukul Sharma20aa6582014-08-07 21:36:12 +053014912 VOS_STATUS status = VOS_STATUS_SUCCESS;
14913
14914 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070014915 profile info from pmac global structure */
14916
Arif Hussain24bafea2013-11-15 15:10:03 -080014917 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14918 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014919 /* Check for user misconfig of RSSI trigger threshold */
14920 pMac->roam.configParam.vccRssiThreshold =
14921 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14922 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14923 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014924 /* Check for user misconfig of UL MAC Loss trigger threshold */
14925 pMac->roam.configParam.vccUlMacLossThreshold =
14926 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14927 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014928#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14929 {
14930 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014931 /* Indicate the neighbor roal algorithm about the connect indication */
14932 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14933 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053014934
14935 // Making sure we are roaming force fully to 5GHz AP only once and
14936 // only when we connected to 2.4GH AP only during initial association.
14937 if(pMac->roam.neighborRoamInfo.cfgParams.neighborInitialForcedRoamTo5GhEnable &&
14938 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel) == SIR_BAND_2_4_GHZ)
14939 {
14940 //Making ini value to false here only so we just roam to
14941 //only once for whole driver load to unload tenure
14942 pMac->roam.neighborRoamInfo.cfgParams.neighborInitialForcedRoamTo5GhEnable = VOS_FALSE;
14943
14944 status = vos_timer_start(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer,
14945 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
14946 //MUKUL TODO: change the neighborResultsRefreshPeriod to some ini value reuqired ??
14947 if ( status != VOS_STATUS_SUCCESS )
14948 {
14949 smsLog(pMac, LOGE, FL("%s Neighbor forcedInitialRoamTo5GHTimer start failed with status %d"), __func__, status);
14950 }
14951 smsLog(pMac, LOGE, FL("%s: Forced roam to 5G started Timer"), __func__);
14952 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014953 }
14954#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014955}
14956
Jeff Johnson295189b2012-06-20 16:38:30 -070014957static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14958{
14959 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014960
14961 if(!pSession)
14962 {
14963 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14964 return;
14965 }
14966
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 //Only to handle the case for Handover on infra link
14968 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14969 {
14970 return;
14971 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14973 csrRoamDeregStatisticsReq(pMac);
14974 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14975#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14976 /* Indicate the neighbor roal algorithm about the disconnect indication */
14977 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14978#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014979
14980 //Remove this code once SLM_Sessionization is supported
14981 //BMPS_WORKAROUND_NOT_NEEDED
14982 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014983 csrIsInfraApStarted( pMac ) &&
14984 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014985 {
14986 pMac->roam.configParam.doBMPSWorkaround = 0;
14987 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014988}
14989
Jeff Johnson295189b2012-06-20 16:38:30 -070014990void csrRoamTlStatsTimerHandler(void *pv)
14991{
14992 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14993 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014994 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14995
Jeff Johnsone7245742012-09-05 17:12:55 -070014996 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14997
Jeff Johnson295189b2012-06-20 16:38:30 -070014998#if 0
14999 // TODO Persession .???
15000 //req TL for stats
15001 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
15002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015003 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015004 }
15005 else
15006 {
15007 //save in SME
15008 csrRoamSaveStatsFromTl(pMac, tlStats);
15009 }
15010#endif
15011 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15012 {
15013 if(pMac->roam.tlStatsReqInfo.periodicity)
15014 {
15015 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015016 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15017 pMac->roam.tlStatsReqInfo.periodicity);
15018 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015019 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015020 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015021 return;
15022 }
15023 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15024 }
15025 }
15026}
Jeff Johnson295189b2012-06-20 16:38:30 -070015027void csrRoamPeStatsTimerHandler(void *pv)
15028{
15029 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
15030 eHalStatus status;
15031 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
15032 VOS_STATUS vosStatus;
15033 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070015034 pPeStatsReqListEntry->timerRunning = FALSE;
15035 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
15036 {
15037 // If we entered here, meaning the timer could not be successfully
15038 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
15039
15040 /* Destroy the timer */
15041 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
15042 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15043 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015044 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015045 }
15046
15047 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015048 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070015049 pPeStatsReqListEntry = NULL;
15050 }
15051 else
15052 {
15053 if(!pPeStatsReqListEntry->rspPending)
15054 {
15055 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
15056 pPeStatsReqListEntry->staId);
15057 if(!HAL_STATUS_SUCCESS(status))
15058 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015059 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015060 }
15061 else
15062 {
15063 pPeStatsReqListEntry->rspPending = TRUE;
15064 }
15065 }
15066
15067 //send down a req
15068 if(pPeStatsReqListEntry->periodicity &&
15069 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
15070 {
15071 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15072 if(ePMC_FULL_POWER == powerState)
15073 {
15074 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15075 {
15076 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15077 }
15078 }
15079 else
15080 {
15081 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15082 {
15083 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15084 }
15085 }
15086 //start timer
15087 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
15088 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15089 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015090 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015091 return;
15092 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015093 pPeStatsReqListEntry->timerRunning = TRUE;
15094
15095 }
15096
15097 }
15098}
Jeff Johnson295189b2012-06-20 16:38:30 -070015099void csrRoamStatsClientTimerHandler(void *pv)
15100{
15101 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070015102 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
15103 {
15104#if 0
15105 // TODO Stats fix for multisession
15106 //start the timer
15107 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
15108
15109 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15110 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015111 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015112 }
15113#endif
15114 }
15115#if 0
15116 //send up the stats report
15117 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
15118 pStaEntry->staId, pStaEntry->pContext);
15119#endif
15120}
15121
15122
15123
Jeff Johnson295189b2012-06-20 16:38:30 -070015124eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
15125{
15126 tAniGetPEStatsReq *pMsg;
15127 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053015128 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
15129 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015130 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015131 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053015132 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015133 }
15134 // need to initiate a stats request to PE
15135 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
15136 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
15137 pMsg->staId = staId;
15138 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015139 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015140 if(!HAL_STATUS_SUCCESS(status))
15141 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015142 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070015143 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015144 return status;
15145}
Jeff Johnson295189b2012-06-20 16:38:30 -070015146void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
15147{
15148 tAniGetPEStatsRsp *pSmeStatsRsp;
15149 eHalStatus status = eHAL_STATUS_FAILURE;
15150 tListElem *pEntry = NULL;
15151 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15152 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15153 tANI_U32 tempMask = 0;
15154 tANI_U8 counter = 0;
15155 tANI_U8 *pStats = NULL;
15156 tANI_U32 length = 0;
15157 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015158 v_S7_t rssi = 0, snr = 0;
15159 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015160 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015161 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
15162 if(pSmeStatsRsp->rc)
15163 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015164 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015165 goto post_update;
15166 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015167 tempMask = pSmeStatsRsp->statsMask;
15168 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070015169 /* subtract all statistics from this length, and after processing the entire
15170 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
15171 * in this 'stats' message.
15172 */
15173 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015174 //new stats info from PE, fill up the stats strucutres in PMAC
15175 while(tempMask)
15176 {
15177 if(tempMask & 1)
15178 {
15179 switch(counter)
15180 {
15181 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015182 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015183 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
15184 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015185 pStats += sizeof(tCsrSummaryStatsInfo);
15186 length -= sizeof(tCsrSummaryStatsInfo);
15187 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015188 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015189 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015190 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
15191 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015192 pStats += sizeof(tCsrGlobalClassAStatsInfo);
15193 length -= sizeof(tCsrGlobalClassAStatsInfo);
15194 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015195 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015196 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015197 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
15198 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015199 pStats += sizeof(tCsrGlobalClassBStatsInfo);
15200 length -= sizeof(tCsrGlobalClassBStatsInfo);
15201 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015202 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015203 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015204 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
15205 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015206 pStats += sizeof(tCsrGlobalClassCStatsInfo);
15207 length -= sizeof(tCsrGlobalClassCStatsInfo);
15208 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015209 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015210 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015211 if( CSR_MAX_STA > pSmeStatsRsp->staId )
15212 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015213 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
15214 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015215 }
15216 else
15217 {
15218 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015219 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015220 VOS_ASSERT( 0 );
15221 }
15222 if(!HAL_STATUS_SUCCESS(status))
15223 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015224 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015225 }
15226 pStats += sizeof(tCsrPerStaStatsInfo);
15227 length -= sizeof(tCsrPerStaStatsInfo);
15228 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015229 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015230 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015231 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015232 }
15233 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015234 tempMask >>=1;
15235 counter++;
15236 }
15237 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
15238 if (length != 0)
15239 {
15240 pRssi = (tANI_U32*)pStats;
15241 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015242 pStats += sizeof(tANI_U32);
15243 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015244 }
15245 else
15246 {
15247 /* If riva is not sending rssi, continue to use the hack */
15248 rssi = RSSI_HACK_BMPS;
15249 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015250
Jeff Johnson295189b2012-06-20 16:38:30 -070015251 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015252
15253 if (length != 0)
15254 {
15255 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015256 pStats += sizeof(tANI_U32);
15257 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015258 }
15259 else
15260 {
15261 linkCapacity = 0;
15262 }
15263
15264 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015265
15266 if (length != 0)
15267 {
15268 pSnr = (tANI_U32*)pStats;
15269 snr = (v_S7_t)*pSnr;
15270 }
15271 else
15272 {
15273 snr = SNR_HACK_BMPS;
15274 }
15275
15276 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015277post_update:
15278 //make sure to update the pe stats req list
15279 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
15280 if(pEntry)
15281 {
15282 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
15283 pPeStaEntry->rspPending = FALSE;
15284
15285 }
15286 //check the one timer cases
15287 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
15288 if(pEntry)
15289 {
Jeff Johnson295189b2012-06-20 16:38:30 -070015290 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015291 if(pTempStaEntry->timerExpired)
15292 {
15293 //send up the stats report
15294 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15295 pTempStaEntry->staId, pTempStaEntry->pContext);
15296 //also remove from the client list
15297 csrRoamRemoveStatListEntry(pMac, pEntry);
15298 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015299 }
15300 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015301}
Jeff Johnson295189b2012-06-20 16:38:30 -070015302tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15303{
15304 tListElem *pEntry = NULL;
15305 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015306 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015307 if(!pEntry)
15308 {
15309 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015310 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015311 return NULL;
15312 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015313 while( pEntry )
15314 {
15315 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015316 if(pTempStaEntry->statsMask == statsMask)
15317 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015318 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015319 break;
15320 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015321 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15322 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015323 return pEntry;
15324}
15325
Jeff Johnson295189b2012-06-20 16:38:30 -070015326tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
15327 tANI_BOOLEAN update)
15328{
15329 tListElem *pEntry;
15330 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015331 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015332 if(!pEntry)
15333 {
15334 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015335 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015336 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015337 return NULL;
15338 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015339 while( pEntry )
15340 {
15341 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015342 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
15343 (pTempStaEntry->statsMask == pStaEntry->statsMask))
15344 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015345 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015346 if(update)
15347 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015348 pTempStaEntry->periodicity = pStaEntry->periodicity;
15349 pTempStaEntry->callback = pStaEntry->callback;
15350 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015351 }
15352 break;
15353 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015354 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15355 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015356 return pEntry;
15357}
Jeff Johnson295189b2012-06-20 16:38:30 -070015358tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15359{
15360 tListElem *pEntry;
15361 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015362 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015363 if(!pEntry)
15364 {
15365 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015366 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015367 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015368 return NULL;
15369 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015370 while( pEntry )
15371 {
15372 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015373 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
15374 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015375 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015376 break;
15377 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015378 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15379 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015380 return pEntry;
15381}
Jeff Johnson295189b2012-06-20 16:38:30 -070015382eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
15383 csrRoamLinkQualityIndCallback callback,
15384 void *pContext)
15385{
15386 pMac->roam.linkQualityIndInfo.callback = callback;
15387 pMac->roam.linkQualityIndInfo.context = pContext;
15388 if( NULL == callback )
15389 {
15390 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
15391 }
15392 else
15393 {
15394 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070015395 /* do we need to invoke the callback to notify client of initial value ?? */
15396 }
15397 return eHAL_STATUS_SUCCESS;
15398}
Jeff Johnson295189b2012-06-20 16:38:30 -070015399void csrRoamVccTrigger(tpAniSirGlobal pMac)
15400{
15401 eCsrRoamLinkQualityInd newVccLinkQuality;
15402 tANI_U32 ul_mac_loss = 0;
15403 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015404 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15405 /*-------------------------------------------------------------------------
15406 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015407 Check for a change in link quality and notify client if necessary
15408 -------------------------------------------------------------------------*/
15409 ul_mac_loss_trigger_threshold =
15410 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015411 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015412 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015413 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015414 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15415 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015416 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015417 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15418 }
15419 else
15420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015421 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015422 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15423 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015424 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15425 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015426 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15427 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015428 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015429 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15430 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015431 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015432 newVccLinkQuality );
15433
15434 /* we now invoke the callback once to notify client of initial value */
15435 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15436 pMac->roam.linkQualityIndInfo.context );
15437 //event: EVENT_WLAN_VCC
15438 }
15439 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015440 pMac->roam.vccLinkQuality = newVccLinkQuality;
15441
Jeff Johnson295189b2012-06-20 16:38:30 -070015442}
Jeff Johnson295189b2012-06-20 16:38:30 -070015443VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15444 v_U8_t rssiNotification,
15445 void * context)
15446{
15447 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15448 eCsrRoamLinkQualityInd newVccLinkQuality;
15449 // TODO : Session info unavailable
15450 tANI_U32 sessionId = 0;
15451 VOS_STATUS status = VOS_STATUS_SUCCESS;
15452 /*-------------------------------------------------------------------------
15453 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015454 Check for a change in link quality and notify client if necessary
15455 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015456 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015457 pMac->roam.configParam.vccRssiThreshold);
15458 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15459 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015460 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015461 return VOS_STATUS_SUCCESS;
15462 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015463 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15464 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015465 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015466 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15467 }
15468 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15469 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015470 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015471 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15472 }
15473 else
15474 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015475 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015476 //Set to this so the code below won't do anything
15477 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015478 VOS_ASSERT(0);
15479 }
15480
Jeff Johnson295189b2012-06-20 16:38:30 -070015481 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15482 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015483 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015484 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15485 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015486 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015487 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015488 /* we now invoke the callback once to notify client of initial value */
15489 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15490 pMac->roam.linkQualityIndInfo.context );
15491 //event: EVENT_WLAN_VCC
15492 }
15493 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015494 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015495 return status;
15496}
Jeff Johnson295189b2012-06-20 16:38:30 -070015497tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15498 tDblLinkList *pStaList,
15499 tCsrStatsClientReqInfo *pStaEntry)
15500{
15501 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015502 //if same entity requested for same set of stats with different periodicity &
15503 // callback update it
15504 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15505 {
15506
Kiet Lam64c1b492013-07-12 13:56:44 +053015507 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15508 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015509 {
15510 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015511 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015512 return NULL;
15513 }
15514
Jeff Johnson295189b2012-06-20 16:38:30 -070015515 pNewStaEntry->callback = pStaEntry->callback;
15516 pNewStaEntry->pContext = pStaEntry->pContext;
15517 pNewStaEntry->periodicity = pStaEntry->periodicity;
15518 pNewStaEntry->requesterId = pStaEntry->requesterId;
15519 pNewStaEntry->statsMask = pStaEntry->statsMask;
15520 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15521 pNewStaEntry->pMac = pStaEntry->pMac;
15522 pNewStaEntry->staId = pStaEntry->staId;
15523 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15524
15525 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15526 }
15527 return pNewStaEntry;
15528}
15529
Jeff Johnson295189b2012-06-20 16:38:30 -070015530tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15531 tDblLinkList *pStaList,
15532 tCsrPeStatsReqInfo *pStaEntry)
15533{
15534 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015535 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15536 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015537 {
15538 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015539 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015540 return NULL;
15541 }
15542
Jeff Johnson295189b2012-06-20 16:38:30 -070015543 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15544 pNewStaEntry->numClient = pStaEntry->numClient;
15545 pNewStaEntry->periodicity = pStaEntry->periodicity;
15546 pNewStaEntry->statsMask = pStaEntry->statsMask;
15547 pNewStaEntry->pMac = pStaEntry->pMac;
15548 pNewStaEntry->staId = pStaEntry->staId;
15549 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15550 pNewStaEntry->rspPending = pStaEntry->rspPending;
15551
15552 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015553 return pNewStaEntry;
15554}
Jeff Johnson295189b2012-06-20 16:38:30 -070015555eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15556 tCsrRssiCallback callback,
15557 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15558{
15559 eHalStatus status = eHAL_STATUS_SUCCESS;
15560 vos_msg_t msg;
15561 tANI_U32 sessionId;
15562
15563 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015564 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015565 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15566 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015568 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015569 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015570 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015571 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15572
15573 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15574 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15575 pMsg->sessionId = sessionId;
15576 pMsg->staId = staId;
15577 pMsg->rssiCallback = callback;
15578 pMsg->pDevContext = pContext;
15579 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015580 msg.type = eWNI_SME_GET_RSSI_REQ;
15581 msg.bodyptr = pMsg;
15582 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015583 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15584 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015585 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015586 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015587 status = eHAL_STATUS_FAILURE;
15588 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015589 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015590 return status;
15591}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015592
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015593eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15594 tCsrSnrCallback callback,
15595 tANI_U8 staId, tCsrBssid bssId,
15596 void *pContext)
15597{
15598 eHalStatus status = eHAL_STATUS_SUCCESS;
15599 vos_msg_t msg;
15600 tANI_U32 sessionId;
15601
15602 tAniGetSnrReq *pMsg;
15603
15604 smsLog(pMac, LOG2, FL("called"));
15605
15606 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15607 if (NULL == pMsg )
15608 {
15609 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15610 return status;
15611 }
15612
15613 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15614
15615 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15616 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15617 pMsg->sessionId = sessionId;
15618 pMsg->staId = staId;
15619 pMsg->snrCallback = callback;
15620 pMsg->pDevContext = pContext;
15621 msg.type = eWNI_SME_GET_SNR_REQ;
15622 msg.bodyptr = pMsg;
15623 msg.reserved = 0;
15624
15625 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15626 {
15627 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15628 vos_mem_free((v_VOID_t *)pMsg);
15629 status = eHAL_STATUS_FAILURE;
15630 }
15631
15632 smsLog(pMac, LOG2, FL("returned"));
15633 return status;
15634}
15635
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015636#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015637eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15638 tCsrRssiCallback callback,
15639 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15640{
15641 eHalStatus status = eHAL_STATUS_SUCCESS;
15642 tAniGetRssiReq *pMsg;
15643
Kiet Lam64c1b492013-07-12 13:56:44 +053015644 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15645 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015646 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015647 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015648 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015649 }
15650 // need to initiate a stats request to PE
15651 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15652 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15653 pMsg->staId = staId;
15654 pMsg->rssiCallback = callback;
15655 pMsg->pDevContext = pContext;
15656 pMsg->pVosContext = pVosContext;
15657 status = palSendMBMessage(pMac->hHdd, pMsg );
15658 if(!HAL_STATUS_SUCCESS(status))
15659 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015660 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015661 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015662 status = eHAL_STATUS_FAILURE;
15663 }
15664 return status;
15665}
15666#endif
15667
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015668
15669
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015670#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015671eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15672 tCsrTsmStatsCallback callback,
15673 tANI_U8 staId,
15674 tCsrBssid bssId,
15675 void *pContext,
15676 void* pVosContext,
15677 tANI_U8 tid)
15678{
15679 eHalStatus status = eHAL_STATUS_SUCCESS;
15680 tAniGetTsmStatsReq *pMsg = NULL;
15681
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015682 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15683 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015684 {
15685 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015686 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015687 }
15688 // need to initiate a stats request to PE
15689 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15690 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15691 pMsg->staId = staId;
15692 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015693 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015694 pMsg->tsmStatsCallback = callback;
15695 pMsg->pDevContext = pContext;
15696 pMsg->pVosContext = pVosContext;
15697 status = palSendMBMessage(pMac->hHdd, pMsg );
15698 if(!HAL_STATUS_SUCCESS(status))
15699 {
15700 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15701 //pMsg is freed by palSendMBMessage
15702 status = eHAL_STATUS_FAILURE;
15703 }
15704 return status;
15705}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015706#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015707
15708
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015709/* ---------------------------------------------------------------------------
15710 \fn csrGetTLSTAState
15711 \helper function to get teh TL STA State whenever the function is called.
15712
15713 \param staId - The staID to be passed to the TL
15714 to get the relevant TL STA State
15715 \return the state as tANI_U16
15716 ---------------------------------------------------------------------------*/
15717tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15718{
15719 WLANTL_STAStateType tlSTAState;
15720 tlSTAState = WLANTL_STA_INIT;
15721
15722 //request TL for STA State
15723 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15724 {
15725 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15726 }
15727
15728 return tlSTAState;
15729}
15730
Jeff Johnson295189b2012-06-20 16:38:30 -070015731eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15732 tANI_U32 statsMask,
15733 tCsrStatsCallback callback,
15734 tANI_U32 periodicity, tANI_BOOLEAN cache,
15735 tANI_U8 staId, void *pContext)
15736{
15737 tCsrStatsClientReqInfo staEntry;
15738 tCsrStatsClientReqInfo *pStaEntry = NULL;
15739 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15740 tListElem *pEntry = NULL;
15741 tANI_BOOLEAN found = FALSE;
15742 eHalStatus status = eHAL_STATUS_SUCCESS;
15743 tANI_BOOLEAN insertInClientList = FALSE;
15744 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015745 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015746
15747 if( csrIsAllSessionDisconnected(pMac) )
15748 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015749 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015750 return eHAL_STATUS_FAILURE;
15751 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015752
15753 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15754 {
15755 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15756 return eHAL_STATUS_FAILURE;
15757 }
15758
Jeff Johnson295189b2012-06-20 16:38:30 -070015759 if((!statsMask) && (!callback))
15760 {
15761 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015762 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015763 return eHAL_STATUS_FAILURE;
15764 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015765 //for the search list method for deregister
15766 staEntry.requesterId = requesterId;
15767 staEntry.statsMask = statsMask;
15768 //requester wants to deregister or just an error
15769 if((statsMask) && (!callback))
15770 {
15771 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15772 if(!pEntry)
15773 {
15774 //msg
15775 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015776 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015777 return eHAL_STATUS_FAILURE;
15778 }
15779 else
15780 {
15781 //clean up & return
15782 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015783 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015784 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015785 pStaEntry->pPeStaEntry->numClient--;
15786 //check if we need to delete the entry from peStatsReqList too
15787 if(!pStaEntry->pPeStaEntry->numClient)
15788 {
15789 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15790 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015791 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015792
Jeff Johnson295189b2012-06-20 16:38:30 -070015793 //check if we need to stop the tl stats timer too
15794 pMac->roam.tlStatsReqInfo.numClient--;
15795 if(!pMac->roam.tlStatsReqInfo.numClient)
15796 {
15797 if(pMac->roam.tlStatsReqInfo.timerRunning)
15798 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015799 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15800 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015801 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015802 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015803 return eHAL_STATUS_FAILURE;
15804 }
15805 }
15806 pMac->roam.tlStatsReqInfo.periodicity = 0;
15807 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15808 }
15809 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015810 // Destroy the vos timer...
15811 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15812 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15813 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015814 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015815 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015816 csrRoamRemoveStatListEntry(pMac, pEntry);
15817 pStaEntry = NULL;
15818 return eHAL_STATUS_SUCCESS;
15819 }
15820 }
15821
15822 if(cache && !periodicity)
15823 {
15824 //return the cached stats
15825 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15826 }
15827 else
15828 {
15829 //add the request in the client req list
15830 staEntry.callback = callback;
15831 staEntry.pContext = pContext;
15832 staEntry.periodicity = periodicity;
15833 staEntry.pPeStaEntry = NULL;
15834 staEntry.staId = staId;
15835 staEntry.pMac = pMac;
15836 staEntry.timerExpired = FALSE;
15837
15838
Jeff Johnson295189b2012-06-20 16:38:30 -070015839 //if periodic report requested with non cached result from PE/TL
15840 if(periodicity)
15841 {
15842
15843 //if looking for stats from PE
15844 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15845 {
15846
15847 //check if same request made already & waiting for rsp
15848 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15849 periodicity, &found, staId);
15850 if(!pPeStaEntry)
15851 {
15852 //bail out, maxed out on number of req for PE
15853 return eHAL_STATUS_FAILURE;
15854 }
15855 else
15856 {
15857 staEntry.pPeStaEntry = pPeStaEntry;
15858 }
15859
15860 }
15861 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15862 if(statsMask & (1 << eCsrGlobalClassDStats))
15863 {
15864 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15865 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015866 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015867 }
15868 else
15869 {
15870
15871 //update periodicity
15872 if(pMac->roam.tlStatsReqInfo.periodicity)
15873 {
15874 pMac->roam.tlStatsReqInfo.periodicity =
15875 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15876 }
15877 else
15878 {
15879 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15880 }
15881 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15882 {
15883 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15884 }
15885
15886 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15887 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015888 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015889 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015890 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015891 //req TL for class D stats
15892 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15893 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015894 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015895 }
15896 else
15897 {
15898 //save in SME
15899 csrRoamSaveStatsFromTl(pMac, pTlStats);
15900 }
15901 vos_mem_free(pTlStats);
15902 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015903 }
15904 else
15905 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015906 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015907 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015908
Jeff Johnson295189b2012-06-20 16:38:30 -070015909 if(pMac->roam.tlStatsReqInfo.periodicity)
15910 {
15911 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015912 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15913 pMac->roam.tlStatsReqInfo.periodicity);
15914 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015915 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015916 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015917 return eHAL_STATUS_FAILURE;
15918 }
15919 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15920 }
15921 }
15922 }
15923 pMac->roam.tlStatsReqInfo.numClient++;
15924 }
15925
15926 insertInClientList = TRUE;
15927 }
15928 //if one time report requested with non cached result from PE/TL
15929 else if(!cache && !periodicity)
15930 {
15931 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15932 {
15933 //send down a req
15934 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15935 if(!HAL_STATUS_SUCCESS(status))
15936 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015937 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015938 }
15939 //so that when the stats rsp comes back from PE we respond to upper layer
15940 //right away
15941 staEntry.timerExpired = TRUE;
15942 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015943 }
15944 if(statsMask & (1 << eCsrGlobalClassDStats))
15945 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015946 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015947 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015948 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015949 //req TL for class D stats
15950 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15951 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015952 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015953 }
15954 else
15955 {
15956 //save in SME
15957 csrRoamSaveStatsFromTl(pMac, pTlStats);
15958 }
15959 vos_mem_free(pTlStats);
15960 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015961 }
15962 else
15963 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015964 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015965 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015966
15967 }
15968 //if looking for stats from TL only
15969 if(!insertInClientList)
15970 {
15971 //return the stats
15972 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15973 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015974 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015975 if(insertInClientList)
15976 {
15977 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15978 if(!pStaEntry)
15979 {
15980 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015981 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015982 return eHAL_STATUS_FAILURE;
15983 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015984 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015985 //Init & start timer if needed
15986 if(periodicity)
15987 {
15988 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15989 csrRoamStatsClientTimerHandler, pStaEntry );
15990 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15991 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015992 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015993 return eHAL_STATUS_FAILURE;
15994 }
15995 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15996 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15997 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015998 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015999 return eHAL_STATUS_FAILURE;
16000 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016001 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016002 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016003 }
16004 return eHAL_STATUS_SUCCESS;
16005}
16006
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016007#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16008
16009static tSirRetStatus
16010csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
16011 tANI_U8* pBD,
16012 tANI_U8 type,
16013 tANI_U8 subType,
16014 tSirMacAddr peerAddr,
16015 tSirMacAddr selfMacAddr)
16016{
16017 tSirRetStatus statusCode = eSIR_SUCCESS;
16018 tpSirMacMgmtHdr pMacHdr;
16019
16020 /* Prepare MAC management header */
16021 pMacHdr = (tpSirMacMgmtHdr) (pBD);
16022
16023 /* Prepare FC */
16024 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
16025 pMacHdr->fc.type = type;
16026 pMacHdr->fc.subType = subType;
16027
16028 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053016029 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
16030 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016031
16032 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
16033
16034 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053016035 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
16036 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016037 return statusCode;
16038} /*** csrRoamScanOffloadPopulateMacHeader() ***/
16039
16040static tSirRetStatus
16041csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
16042 tANI_U8 nChannelNum,
16043 tANI_U32 dot11mode,
16044 tSirMacAddr selfMacAddr,
16045 tANI_U8 *pFrame,
16046 tANI_U16 *pusLen)
16047{
16048 tDot11fProbeRequest pr;
16049 tANI_U32 nStatus, nBytes, nPayload;
16050 tSirRetStatus nSirStatus;
16051 /*Bcast tx*/
16052 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
16053 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16054
16055
Kiet Lam64c1b492013-07-12 13:56:44 +053016056 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016057
16058 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
16059
16060 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
16061 {
16062 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
16063 }
16064
16065
16066 if (IS_DOT11_MODE_HT(dot11mode))
16067 {
16068 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
16069 }
16070
16071
16072 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
16073 if ( DOT11F_FAILED( nStatus ) )
16074 {
16075 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16076 "Failed to calculate the packed size f"
16077 "or a Probe Request (0x%08x).\n", nStatus );
16078
16079
16080 nPayload = sizeof( tDot11fProbeRequest );
16081 }
16082 else if ( DOT11F_WARNED( nStatus ) )
16083 {
16084 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16085 "There were warnings while calculating"
16086 "the packed size for a Probe Request ("
16087 "0x%08x).\n", nStatus );
16088 }
16089
16090 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
16091
16092 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053016093 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016094
16095
16096 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016097 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016098
16099 if ( eSIR_SUCCESS != nSirStatus )
16100 {
16101 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16102 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
16103 nSirStatus );
16104 return nSirStatus;
16105 }
16106
16107
16108 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
16109 sizeof( tSirMacMgmtHdr ),
16110 nPayload, &nPayload );
16111 if ( DOT11F_FAILED( nStatus ) )
16112 {
16113 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16114 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
16115 return eSIR_FAILURE;
16116 }
16117 else if ( DOT11F_WARNED( nStatus ) )
16118 {
16119 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070016120 "There were warnings while packing a Probe Request (0x%08x).\n",
16121 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016122 }
16123
16124 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
16125 return eSIR_SUCCESS;
16126}
16127
16128eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
16129{
16130 vos_msg_t msg;
16131 tSirRoamOffloadScanReq *pRequestBuf;
16132 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
16133 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016134 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016135 tANI_U8 *ChannelList = NULL;
16136 tANI_U32 sessionId;
16137 eHalStatus status = eHAL_STATUS_SUCCESS;
16138 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070016139 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016140 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016141 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016142 tSirBssDescription *pBssDesc = NULL;
16143 tDot11fBeaconIEs *pIes = NULL;
16144 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080016145 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016146
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016147 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
16148
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070016149 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016150 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016151 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016152 return eHAL_STATUS_FAILURE;
16153 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016154
16155 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
16156 {
16157 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
16158 return eHAL_STATUS_FAILURE;
16159 }
Abhishek Singh3e915632014-11-01 17:14:50 +053016160
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016161 /*The Dynamic Config Items Update may happen even if the state is in INIT.
16162 * It is important to ensure that the command is passed down to the FW only
16163 * if the Infra Station is in a connected state.A connected station could also be
16164 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
16165 * We also have to ensure that if there is a STOP command we always have to inform Riva,
16166 * irrespective of whichever state we are in.*/
16167 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
16168 (command != ROAM_SCAN_OFFLOAD_STOP))
16169 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053016170 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
16171 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
16172 macTraceGetNeighbourRoamState(
16173 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016174 return eHAL_STATUS_FAILURE;
16175 }
16176
Abhishek Singh3e915632014-11-01 17:14:50 +053016177 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
16178 * Also there are cases where pNeighborRoamInfo->currAPbssid
16179 * is set to 0 during disconnect and so we might return without stopping
16180 * the roam scan. So no need to find the session if command is
16181 * ROAM_SCAN_OFFLOAD_STOP.
16182 */
16183 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016184 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016185 status = csrRoamGetSessionIdFromBSSID(pMac,
16186 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
16187 &sessionId);
16188
16189 if ( !HAL_STATUS_SUCCESS( status ) )
16190 {
16191 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16192 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
16193 return eHAL_STATUS_FAILURE;
16194 }
16195 pSession = CSR_GET_SESSION( pMac, sessionId );
16196 if (NULL == pSession)
16197 {
16198 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
krunal soni587bf012014-02-04 12:35:11 -080016199 "%s:pSession is null", __func__);
Abhishek Singh3e915632014-11-01 17:14:50 +053016200 return eHAL_STATUS_FAILURE;
16201 }
16202 pBssDesc = pSession->pConnectBssDesc;
16203 if (pBssDesc == NULL)
16204 {
16205 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16206 "%s: pBssDesc not found for current session", __func__);
16207 return eHAL_STATUS_FAILURE;
16208 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016209 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016210 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
16211 if (NULL == pRequestBuf)
16212 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016213 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16214 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
16215 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016216 }
16217
Abhishek Singh3e915632014-11-01 17:14:50 +053016218 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
16219 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
16220 * host driver reloads, but Riva still up and running*/
16221 pRequestBuf->Command = command;
16222 if(command == ROAM_SCAN_OFFLOAD_STOP)
16223 {
16224 pRequestBuf->RoamScanOffloadEnabled = 0;
16225 /*For a STOP Command, there is no need to
16226 * go through filling up all the below parameters
16227 * since they are not required for the STOP command*/
16228 goto send_roam_scan_offload_cmd;
16229 }
16230 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016231 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053016232 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
16233 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016234 sizeof(tCsrBssid));
16235 pRequestBuf->ConnectedNetwork.ssId.length =
16236 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
16237 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
16238 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
16239 pRequestBuf->ConnectedNetwork.ssId.length);
16240 pRequestBuf->ConnectedNetwork.authentication =
16241 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
16242 pRequestBuf->ConnectedNetwork.encryption =
16243 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
16244 pRequestBuf->ConnectedNetwork.mcencryption =
16245 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016246 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
16247 {
16248 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016249 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016250 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16251 }
16252 else
16253 {
16254 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
16255 operationChannel = pSession->connectedProfile.operationChannel;
16256
16257 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
16258 {
16259 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16260 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
16261 vos_mem_free(pRequestBuf);
16262 return eHAL_STATUS_FAILURE;
16263 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016264 if(NULL == pIes)
16265 {
16266 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16267 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053016268 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016269 return eHAL_STATUS_FAILURE;
16270 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016271 if (pIes->SuppRates.present)
16272 {
16273 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
16274 /*Check for both basic rates and extended rates.*/
16275 for (i = 0; i < pIes->SuppRates.num_rates; i++)
16276 {
16277 /*Check if the Rate is Mandatory or Not*/
16278 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
16279 && (pIes->SuppRates.rates[i] & 0x80))
16280 {
16281 /*Retrieve the actual data rate*/
16282 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
16283 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16284 if (minRate == 0)
16285 minRate = dataRate;
16286 else
16287 minRate = (minRate < dataRate) ? minRate:dataRate;
16288 }
16289 }
16290
16291 if (pIes->ExtSuppRates.present)
16292 {
16293 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
16294 {
16295 /*Check if the Rate is Mandatory or Not*/
16296 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
16297 && (pIes->ExtSuppRates.rates[i] & 0x80))
16298 {
16299 /*Retrieve the actual data rate*/
16300 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
16301 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16302 if (minRate == 0)
16303 minRate = dataRate;
16304 else
16305 minRate = (minRate < dataRate) ? minRate:dataRate;
16306 }
16307 }
16308 }
16309 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
16310 }
16311 else
16312 {
16313 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16314 "%s: Supp Rates not present in pIes", __func__);
16315 vos_mem_free(pRequestBuf);
16316 return eHAL_STATUS_FAILURE;
16317 }
16318 if (NULL != pIes)
16319 {
16320 vos_mem_free(pIes);
16321 pIes = NULL;
16322 }
16323 switch (minRate)
16324 {
16325 case 1:
16326 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
16327 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
16328 break;
16329 case 2:
16330 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
16331 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
16332 break;
16333 case 5:
16334 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
16335 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
16336 break;
16337 case 6:
16338 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16339 {
16340 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
16341 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
16342 }
16343 else
16344 {
16345 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
16346 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
16347 }
16348 break;
16349 case 11:
16350 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
16351 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
16352 break;
16353 case 12:
16354 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16355 {
16356 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
16357 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
16358 }
16359 else
16360 {
16361 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
16362 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
16363 }
16364 break;
16365 case 24:
16366 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16367 {
16368 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
16369 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
16370 }
16371 else
16372 {
16373 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
16374 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
16375 }
16376 break;
16377 default:
16378 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
16379 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16380 break;
16381 }
16382 }
16383 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16384 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
16385 operationChannel, minRate,
16386 pRequestBuf->RxSensitivityThreshold,
16387 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016388 pRequestBuf->RoamRssiDiff =
16389 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016390 pRequestBuf->StartScanReason = reason;
16391 pRequestBuf->NeighborScanTimerPeriod =
16392 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
16393 pRequestBuf->NeighborRoamScanRefreshPeriod =
16394 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
16395 pRequestBuf->NeighborScanChannelMinTime =
16396 pNeighborRoamInfo->cfgParams.minChannelScanTime;
16397 pRequestBuf->NeighborScanChannelMaxTime =
16398 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
16399 pRequestBuf->EmptyRefreshScanPeriod =
16400 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080016401 /* MAWC feature */
16402 pRequestBuf->MAWCEnabled =
16403 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016404#ifdef FEATURE_WLAN_ESE
16405 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016406#endif
16407 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016408#ifdef FEATURE_WLAN_ESE
16409 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016410 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
16411 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016412 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
16413#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016414 currChannelListInfo->numOfChannels == 0)
16415 {
16416
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016417 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
16418 * Give Preference to INI Channels.*/
16419 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
16420 {
16421 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16422 /*The INI channels need to be filtered with respect to the current
16423 * band that is supported.*/
16424 eBand = pMac->roam.configParam.bandCapability;
16425 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016426 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016427 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16428 "Invalid band, No operation carried out (Band %d)", eBand);
16429 vos_mem_free(pRequestBuf);
16430 return eHAL_STATUS_FAILURE;
16431 }
16432 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16433 {
16434 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16435 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16436 (eCSR_BAND_ALL == eBand))
16437 {
16438 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
16439 csrRoamIsChannelValid(pMac, *ChannelList) &&
16440 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16441 {
16442 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16443 }
16444 }
16445 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016446 }
16447 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16448 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016449 }
16450 else
16451 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016452 ChannelList = pMac->scan.occupiedChannels.channelList;
16453 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16454 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016455 /*Allow DFS channels only if the DFS channel roam flag is enabled */
16456 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16457 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016458 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16459 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016460 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016461 }
16462 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016463 }
16464 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16465 /* If the profile changes as to what it was earlier, inform the FW through
16466 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16467 * for the earlier profile and try to learn them afresh.*/
16468 if (reason == REASON_FLUSH_CHANNEL_LIST)
16469 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16470 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016471 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16472 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16473 else
16474 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016475 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016476 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016477 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016478#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016479 else
16480 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016481 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016482 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016483 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016484 if (currChannelListInfo->numOfChannels != 0)
16485 {
16486 ChannelList = currChannelListInfo->ChannelList;
16487 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016488 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016489 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16490 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016491 {
16492 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16493 }
16494 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016495 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016496 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16497 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16498 }
16499 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016500#endif
Kaushik, Sushant5ed8ab62014-03-05 11:21:11 +053016501 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0])) && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016502 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016503 if (j < sizeof(ChannelCacheStr))
16504 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016505 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16506 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016507 }
16508 else
16509 {
16510 break;
16511 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016512 }
16513 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16514 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16515 pRequestBuf->ChannelCacheType,
16516 pRequestBuf->ConnectedNetwork.ChannelCount,
16517 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016518 num_channels = 0;
16519 ChannelList = NULL;
16520
16521 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016522 host_channels = sizeof(pMac->roam.validChannelList);
16523 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016524 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016525 ChannelList = pMac->roam.validChannelList;
16526 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016527 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016528 else
16529 {
16530 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16531 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016532 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016533 return eHAL_STATUS_FAILURE;
16534 }
16535 for(i=0; i<pMac->roam.numValidChannels; i++)
16536 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016537 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16538 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Srinivas Girigowda56076852013-08-20 14:00:50 -070016539 {
16540 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16541 }
16542 ChannelList++;
16543 }
16544 pRequestBuf->ValidChannelCount = num_channels;
16545
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016546 pRequestBuf->MDID.mdiePresent =
16547 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16548 pRequestBuf->MDID.mobilityDomain =
16549 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016550 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16551
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016552 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016553 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16554 * where RFS is the RF Switching time. It is twice RFS to consider the
16555 * time to go off channel and return to the home channel. */
16556 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16557 {
16558 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16559 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16560 " Hence enforcing home away time to disable (0)",
16561 __func__, pRequestBuf->HomeAwayTime,
16562 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16563 pRequestBuf->HomeAwayTime = 0;
16564 }
16565 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016566
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016567 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16568 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16569 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16570 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16571 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16572
16573 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16574 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016575send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016576 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016577 msg.reserved = 0;
16578 msg.bodyptr = pRequestBuf;
16579 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16580 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016581 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16582 vos_mem_free(pRequestBuf);
16583 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016584 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016585 else
16586 {
16587 if (ROAM_SCAN_OFFLOAD_START == command)
16588 bRoamScanOffloadStarted = VOS_TRUE;
16589 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16590 bRoamScanOffloadStarted = VOS_FALSE;
16591 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016592
16593 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16594 return status;
16595}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016596
16597eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16598{
16599 switch(reason)
16600 {
16601 case 0:
16602 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16603 break;
16604 case REASON_OS_REQUESTED_ROAMING_NOW:
16605 csrNeighborRoamProceedWithHandoffReq(pMac);
16606 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016607 case REASON_INITIAL_FORCED_ROAM_TO_5G:
16608 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
16609 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016610 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016611 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 -070016612 }
16613 return eHAL_STATUS_SUCCESS;
16614}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016615#endif
16616
Jeff Johnson295189b2012-06-20 16:38:30 -070016617tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16618 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16619{
16620 tANI_BOOLEAN found = FALSE;
16621 eHalStatus status = eHAL_STATUS_SUCCESS;
16622 tCsrPeStatsReqInfo staEntry;
16623 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16624 tListElem *pStaEntry = NULL;
16625 VOS_STATUS vosStatus;
16626 tPmcPowerState powerState;
16627 *pFound = FALSE;
16628
16629 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16630 if(pStaEntry)
16631 {
16632 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16633 if(pTempStaEntry->periodicity)
16634 {
16635 pTempStaEntry->periodicity =
16636 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16637 }
16638 else
16639 {
16640 pTempStaEntry->periodicity = periodicity;
16641 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016642 pTempStaEntry->numClient++;
16643 found = TRUE;
16644 }
16645 else
16646 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016647 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016648 staEntry.numClient = 1;
16649 staEntry.periodicity = periodicity;
16650 staEntry.pMac = pMac;
16651 staEntry.rspPending = FALSE;
16652 staEntry.staId = staId;
16653 staEntry.statsMask = statsMask;
16654 staEntry.timerRunning = FALSE;
16655 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16656 if(!pTempStaEntry)
16657 {
16658 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016659 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016660 return NULL;
16661 }
16662 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016663 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16664 if(ePMC_FULL_POWER == powerState)
16665 {
16666 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16667 {
16668 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16669 }
16670 }
16671 else
16672 {
16673 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16674 {
16675 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16676 }
16677 }
16678 if(!pTempStaEntry->timerRunning)
16679 {
16680 //send down a req in case of one time req, for periodic ones wait for timer to expire
16681 if(!pTempStaEntry->rspPending &&
16682 !pTempStaEntry->periodicity)
16683 {
16684 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16685 if(!HAL_STATUS_SUCCESS(status))
16686 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016687 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016688 }
16689 else
16690 {
16691 pTempStaEntry->rspPending = TRUE;
16692 }
16693 }
16694 if(pTempStaEntry->periodicity)
16695 {
16696 if(!found)
16697 {
16698
16699 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16700 csrRoamPeStatsTimerHandler, pTempStaEntry );
16701 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16702 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016703 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016704 return NULL;
16705 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016706 }
16707 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016708 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016709 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16710 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16711 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016712 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016713 return NULL;
16714 }
16715 pTempStaEntry->timerRunning = TRUE;
16716 }
16717 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016718 *pFound = found;
16719 return pTempStaEntry;
16720}
16721
Jeff Johnson295189b2012-06-20 16:38:30 -070016722/*
16723 pStaEntry is no longer invalid upon the return of this function.
16724*/
16725static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16726{
16727 if(pEntry)
16728 {
16729 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16730 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016731 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016732 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016733 }
16734 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016735
16736void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16737{
16738 tListElem *pEntry;
16739 tCsrPeStatsReqInfo *pTempStaEntry;
16740 VOS_STATUS vosStatus;
16741 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016742 if(!pEntry)
16743 {
16744 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016745 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016746 return;
16747 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016748 while( pEntry )
16749 {
16750 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016751 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16752 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016753 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016754 if(pTempStaEntry->timerRunning)
16755 {
16756 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16757 /* If we are not able to stop the timer here, just remove
16758 * the entry from the linked list. Destroy the timer object
16759 * and free the memory in the timer CB
16760 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016761 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016762 {
16763 /* the timer is successfully stopped */
16764 pTempStaEntry->timerRunning = FALSE;
16765
16766 /* Destroy the timer */
16767 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16768 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016770 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016771 }
16772 }
16773 else
16774 {
16775 // the timer could not be stopped. Hence destroy and free the
16776 // memory for the PE stat entry in the timer CB.
16777 pTempStaEntry->timerStopFailed = TRUE;
16778 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016779 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016780
16781 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16782 {
16783 // Only free the memory if we could stop the timer successfully
16784 if(!pTempStaEntry->timerStopFailed)
16785 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016786 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016787 pTempStaEntry = NULL;
16788 }
16789 break;
16790 }
16791
16792 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16793 }
16794 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016795 return;
16796}
16797
16798
Jeff Johnsone7245742012-09-05 17:12:55 -070016799void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016800{
16801
Jeff Johnsone7245742012-09-05 17:12:55 -070016802 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16803 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16804 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16805 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16806 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16807 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16808 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016809 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016810 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16811 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16812 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16813 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16814 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16815 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016816 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016817 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16818 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016819
16820}
16821
Jeff Johnson295189b2012-06-20 16:38:30 -070016822void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16823 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16824{
16825 tANI_U8 stats[500];
16826 tANI_U8 *pStats = NULL;
16827 tANI_U32 tempMask = 0;
16828 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016829 if(!callback)
16830 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016831 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016832 return;
16833 }
16834 if(!statsMask)
16835 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016836 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016837 return;
16838 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016839 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016840 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016841 while(tempMask)
16842 {
16843 if(tempMask & 1)
16844 {
16845 //new stats info from PE, fill up the stats strucutres in PMAC
16846 switch(counter)
16847 {
16848 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016849 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016850 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16851 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016852 pStats += sizeof(tCsrSummaryStatsInfo);
16853 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016854 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016855 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016856 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16857 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016858 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016859 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016860 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016861 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016862 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16863 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016864 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016865 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016866 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016867 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016868 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16869 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016870 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016871 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016872 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016873 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016874 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16875 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016876 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016877 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016878 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016879 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016880 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16881 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016882 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016883 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016884 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016885 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016886 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016887 }
16888 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016889 tempMask >>=1;
16890 counter++;
16891 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016892 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016893}
16894
Jeff Johnson295189b2012-06-20 16:38:30 -070016895eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16896{
16897 tListElem *pEntry = NULL;
16898 tListElem *pPrevEntry = NULL;
16899 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16900 eHalStatus status = eHAL_STATUS_SUCCESS;
16901 VOS_STATUS vosStatus;
16902 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016903 if(!pEntry)
16904 {
16905 //list empty
16906 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016907 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016908 return status;
16909 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016910 while( pEntry )
16911 {
16912 if(pPrevEntry)
16913 {
16914 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16915 //send up the stats report
16916 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16917 pTempStaEntry->staId, pTempStaEntry->pContext);
16918 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16919 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016920 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016921 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16922 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016923 pTempStaEntry->pPeStaEntry->numClient--;
16924 //check if we need to delete the entry from peStatsReqList too
16925 if(!pTempStaEntry->pPeStaEntry->numClient)
16926 {
16927 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16928 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016929 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016930 //check if we need to stop the tl stats timer too
16931 pMac->roam.tlStatsReqInfo.numClient--;
16932 if(!pMac->roam.tlStatsReqInfo.numClient)
16933 {
16934 if(pMac->roam.tlStatsReqInfo.timerRunning)
16935 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016936 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16937 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016938 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016939 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016940 //we will continue
16941 }
16942 }
16943 pMac->roam.tlStatsReqInfo.periodicity = 0;
16944 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16945 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016946 if (pTempStaEntry->periodicity)
16947 {
16948 //While creating StaEntry in csrGetStatistics,
16949 //Initializing and starting timer only when periodicity is set.
16950 //So Stop and Destroy timer only when periodicity is set.
16951
Jeff Johnsone7245742012-09-05 17:12:55 -070016952 vos_timer_stop( &pTempStaEntry->timer );
16953 // Destroy the vos timer...
16954 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16955 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16956 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016957 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016958 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016959 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016960
Jeff Johnson295189b2012-06-20 16:38:30 -070016961
16962 pPrevEntry = pEntry;
16963 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16964 }
16965 //the last one
16966 if(pPrevEntry)
16967 {
16968 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16969 //send up the stats report
16970 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16971 pTempStaEntry->staId, pTempStaEntry->pContext);
16972 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16973 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016974 return status;
16975
16976}
16977
Jeff Johnson295189b2012-06-20 16:38:30 -070016978eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16979 tRequestFullPowerReason *pReason,
16980 tANI_BOOLEAN *pfNeedPower )
16981{
16982 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16983 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16984 tPmcState pmcState;
16985 eHalStatus status = eHAL_STATUS_SUCCESS;
16986 // TODO : Session info unavailable
16987 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016988 if( pfNeedPower )
16989 {
16990 *pfNeedPower = eANI_BOOLEAN_FALSE;
16991 }
16992 //We only handle CSR commands
16993 if( !(eSmeCsrCommandMask & pCommand->command) )
16994 {
16995 return eHAL_STATUS_SUCCESS;
16996 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016997 //Check PMC state first
16998 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016999 switch( pmcState )
17000 {
17001 case REQUEST_IMPS:
17002 case IMPS:
17003 if( eSmeCommandScan == pCommand->command )
17004 {
17005 switch( pCommand->u.scanCmd.reason )
17006 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017007#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17008 case eCsrScanGetLfrResult:
17009#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017010 case eCsrScanGetResult:
17011 case eCsrScanBGScanAbort:
17012 case eCsrScanBGScanEnable:
17013 case eCsrScanGetScanChnInfo:
17014 //Internal process, no need for full power
17015 fNeedFullPower = eANI_BOOLEAN_FALSE;
17016 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017017 default:
17018 //Other scans are real scan, ask for power
17019 fNeedFullPower = eANI_BOOLEAN_TRUE;
17020 break;
17021 } //switch
17022 }
17023 else
17024 {
17025 //ask for power for roam and status change
17026 fNeedFullPower = eANI_BOOLEAN_TRUE;
17027 }
17028 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017029 case REQUEST_BMPS:
17030 case BMPS:
17031 case REQUEST_START_UAPSD:
17032 case UAPSD:
17033 //We treat WOWL same as BMPS
17034 case REQUEST_ENTER_WOWL:
17035 case WOWL:
17036 if( eSmeCommandRoam == pCommand->command )
17037 {
17038 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
17039 tCsrScanResult *pScanResult;
17040 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070017041 switch ( pCommand->u.roamCmd.roamReason )
17042 {
17043 case eCsrForcedDisassoc:
17044 case eCsrForcedDisassocMICFailure:
17045 reason = eSME_LINK_DISCONNECTED_BY_HDD;
17046 fNeedFullPower = eANI_BOOLEAN_TRUE;
17047 break;
17048 case eCsrSmeIssuedDisassocForHandoff:
17049 case eCsrForcedDeauth:
17050 case eCsrHddIssuedReassocToSameAP:
17051 case eCsrSmeIssuedReassocToSameAP:
17052 fNeedFullPower = eANI_BOOLEAN_TRUE;
17053 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017054 case eCsrCapsChange:
17055 fNeedFullPower = eANI_BOOLEAN_TRUE;
17056 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017057 default:
17058 //Check whether the profile is already connected. If so, no need for full power
17059 //Note: IBSS is ignored for now because we don't support powersave in IBSS
17060 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
17061 {
17062 //Only need to check the first one
17063 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
17064 if( pEntry )
17065 {
17066 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
17067#if 0
17068 // TODO : Session Specific info pConnectBssDesc
17069 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
17070 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
17071 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
17072 {
17073 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
17074 // with Authenticating first. To force this, stop the current association (Disassociate) and
17075 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
17076 // a new Association.
17077 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
17078 {
17079 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
17080 {
17081 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
17082 //No need for full power
17083 //Set the flag so the code later can avoid to do the above
17084 //check again.
17085 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
17086 break;
17087 }
17088 }
17089 }
17090#endif
17091 }
17092 }
17093 //If we are here, full power is needed
17094 fNeedFullPower = eANI_BOOLEAN_TRUE;
17095 break;
17096 }
17097 }
17098 else if( eSmeCommandWmStatusChange == pCommand->command )
17099 {
17100 //need full power for all
17101 fNeedFullPower = eANI_BOOLEAN_TRUE;
17102 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
17103 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017104#ifdef FEATURE_WLAN_TDLS
17105 else if( eSmeCommandTdlsAddPeer == pCommand->command )
17106 {
17107 //TDLS link is getting established. need full power
17108 fNeedFullPower = eANI_BOOLEAN_TRUE;
17109 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
17110 }
17111#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017112 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017113 case REQUEST_STOP_UAPSD:
17114 case REQUEST_EXIT_WOWL:
17115 if( eSmeCommandRoam == pCommand->command )
17116 {
17117 fNeedFullPower = eANI_BOOLEAN_TRUE;
17118 switch ( pCommand->u.roamCmd.roamReason )
17119 {
17120 case eCsrForcedDisassoc:
17121 case eCsrForcedDisassocMICFailure:
17122 reason = eSME_LINK_DISCONNECTED_BY_HDD;
17123 break;
17124 default:
17125 break;
17126 }
17127 }
17128 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017129 case STOPPED:
17130 case REQUEST_STANDBY:
17131 case STANDBY:
17132 case LOW_POWER:
17133 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053017134 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
17135 " stopped/standby state %s (%d)" ),
17136 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070017137 status = eHAL_STATUS_FAILURE;
17138 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017139 case FULL_POWER:
17140 case REQUEST_FULL_POWER:
17141 default:
17142 //No need to ask for full power. This has to be FULL_POWER state
17143 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017144 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070017145 if( pReason )
17146 {
17147 *pReason = reason;
17148 }
17149 if( pfNeedPower )
17150 {
17151 *pfNeedPower = fNeedFullPower;
17152 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017153 return ( status );
17154}
17155
Jeff Johnson295189b2012-06-20 16:38:30 -070017156static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
17157{
17158 eHalStatus status = eHAL_STATUS_SUCCESS;
17159 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
17160 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070017161 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070017162 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
17163 {
17164 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
17165 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017166 return ( status );
17167}
17168
Jeff Johnson295189b2012-06-20 16:38:30 -070017169tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
17170{
17171 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070017172 if( pCmd )
17173 {
17174 pMac->roam.sPendingCommands++;
17175 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017176 return ( pCmd );
17177}
17178
Jeff Johnson295189b2012-06-20 16:38:30 -070017179void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
17180{
17181 if (pMac->roam.sPendingCommands > 0)
17182 {
17183 //All command allocated through csrGetCommandBuffer need to
17184 //decrement the pending count when releasing.
17185 pMac->roam.sPendingCommands--;
17186 smeReleaseCommand( pMac, pCommand );
17187 }
17188 else
17189 {
17190 smsLog(pMac, LOGE, FL( "no pending commands"));
17191 VOS_ASSERT(0);
17192 }
17193}
17194
Jeff Johnson295189b2012-06-20 16:38:30 -070017195//Return SUCCESS is the command is queued, failed
17196eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
17197{
17198 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017199 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
17200 {
17201 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
17202 pCommand->u.scanCmd.reason);
17203 return eHAL_STATUS_CSR_WRONG_STATE;
17204 }
17205
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017206 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
17207 {
17208 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
17209 &pCommand->Link, LL_ACCESS_LOCK);
17210 // process the command queue...
17211 smeProcessPendingQueue(pMac);
17212 status = eHAL_STATUS_SUCCESS;
17213 goto end;
17214 }
17215
Jeff Johnson295189b2012-06-20 16:38:30 -070017216 //We can call request full power first before putting the command into pending Q
17217 //because we are holding SME lock at this point.
17218 status = csrRequestFullPower( pMac, pCommand );
17219 if( HAL_STATUS_SUCCESS( status ) )
17220 {
17221 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070017222 //make sure roamCmdPendingList is not empty first
17223 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
17224 if( fNoCmdPending )
17225 {
17226 smePushCommand( pMac, pCommand, fHighPriority );
17227 }
17228 else
17229 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017230 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070017231 //no list lock is needed since SME lock is held
17232 if( !fHighPriority )
17233 {
17234 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17235 }
17236 else {
17237 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17238 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017239 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017240 }
17241 else if( eHAL_STATUS_PMC_PENDING == status )
17242 {
17243 //no list lock is needed since SME lock is held
17244 if( !fHighPriority )
17245 {
17246 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17247 }
17248 else {
17249 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17250 }
17251 //Let caller know the command is queue
17252 status = eHAL_STATUS_SUCCESS;
17253 }
17254 else
17255 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017256 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070017257 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017258 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070017259 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017260end:
Jeff Johnson295189b2012-06-20 16:38:30 -070017261 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070017262}
Jeff Johnson295189b2012-06-20 16:38:30 -070017263eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
17264{
17265 eHalStatus status = eHAL_STATUS_SUCCESS;
17266 tSirUpdateAPWPSIEsReq *pMsg;
17267 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
17268
17269 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17270 if (NULL == pSession)
17271 {
17272 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17273 return eHAL_STATUS_FAILURE;
17274 }
17275
Jeff Johnson295189b2012-06-20 16:38:30 -070017276 do
17277 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017278 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
17279 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17280 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017281 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
17282
17283 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070017284 VOS_ASSERT(pBuf);
17285
Jeff Johnson295189b2012-06-20 16:38:30 -070017286 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017287 // transactionId
17288 *pBuf = 0;
17289 *( pBuf + 1 ) = 0;
17290 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070017291 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017292 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17293 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017294 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017295 //sessionId
17296 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017297 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017298 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070017299 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070017300 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017301 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017302 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017303 return ( status );
17304}
Jeff Johnson295189b2012-06-20 16:38:30 -070017305eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
17306{
17307 eHalStatus status = eHAL_STATUS_SUCCESS;
17308 tSirUpdateAPWPARSNIEsReq *pMsg;
17309 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017310 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17311 if (NULL == pSession)
17312 {
17313 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17314 return eHAL_STATUS_FAILURE;
17315 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017316 do
17317 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017318 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
17319 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17320 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017321 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070017322 pBuf = (tANI_U8 *)&pMsg->transactionId;
17323 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017324 // transactionId
17325 *pBuf = 0;
17326 *( pBuf + 1 ) = 0;
17327 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070017328 VOS_ASSERT(pBuf);
17329
Jeff Johnson295189b2012-06-20 16:38:30 -070017330 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017331 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17332 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017333 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017334 // sessionId
17335 *pBuf++ = (tANI_U8)sessionId;
17336
17337 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017338 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070017339 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070017340 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017341 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017342 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017343 return ( status );
17344}
Jeff Johnson295189b2012-06-20 16:38:30 -070017345
17346#ifdef WLAN_FEATURE_VOWIFI_11R
17347//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
17348eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
17349{
17350 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17351 tpSirFTPreAuthReq pftPreAuthReq;
17352 tANI_U16 auth_req_len = 0;
17353 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017354 auth_req_len = sizeof(tSirFTPreAuthReq);
17355 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053017356 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070017357 {
17358 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
17359 return eHAL_STATUS_RESOURCES;
17360 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017361 // Save the SME Session ID here. We need it while processing the preauth response
17362 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017363 vos_mem_zero(pftPreAuthReq, auth_req_len);
17364
17365 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
17366 sizeof(pBssDescription->length) + pBssDescription->length);
17367
17368 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
17369
17370 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
17371
Kiet Lam64c1b492013-07-12 13:56:44 +053017372 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
17373 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
17374 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
17375 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017376
Jeff Johnson295189b2012-06-20 16:38:30 -070017377#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080017378 if (csrRoamIs11rAssoc(pMac) &&
17379 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070017380 {
17381 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053017382 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
17383 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070017384 }
17385 else
17386#endif
17387 {
17388 pftPreAuthReq->ft_ies_length = 0;
17389 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070017390 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
17391 sizeof(pBssDescription->length) + pBssDescription->length);
17392 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070017393 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
17394}
Jeff Johnson295189b2012-06-20 16:38:30 -070017395/*--------------------------------------------------------------------------
17396 * This will receive and process the FT Pre Auth Rsp from the current
17397 * associated ap.
17398 *
17399 * This will invoke the hdd call back. This is so that hdd can now
17400 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
17401 ------------------------------------------------------------------------*/
17402void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
17403{
17404 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17405 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017406#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017407 tCsrRoamInfo roamInfo;
17408#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017409 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070017410
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017411#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080017412 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017413 if (status != eHAL_STATUS_SUCCESS) {
17414 /*
17415 * Bail out if pre-auth was not even processed.
17416 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017417 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
17418 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017419 return;
17420 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017421#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017422 /* The below function calls/timers should be invoked only if the pre-auth is successful */
17423 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
17424 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070017425 // Implies a success
17426 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017427 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
17428 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053017429 /* No need to notify qos module if this is a non 11r & ESE roam*/
17430 if (csrRoamIs11rAssoc(pMac)
17431#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
17432 || csrRoamIsESEAssoc(pMac)
17433#endif
17434 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070017435 {
17436 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17437 }
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017438#ifdef DEBUG_ROAM_DELAY
17439 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
17440#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017441 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17442 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017443 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
17444 60);
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017445#ifdef DEBUG_ROAM_DELAY
17446 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
17447#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017448 if (eHAL_STATUS_SUCCESS != status)
17449 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017450 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017451 return;
17452 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017453 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017454 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
17455 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070017456 if (csrRoamIs11rAssoc(pMac))
17457 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17458 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
17459
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017460#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17461 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017462 {
17463 /* read TSF */
17464 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
17465
17466 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017467 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017468 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
17469 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017470#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017471#ifdef FEATURE_WLAN_LFR
17472 // If Legacy Fast Roaming is enabled, signal the supplicant
17473 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053017474 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017475 {
17476 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017477 vos_mem_copy((void *)&roamInfo.bssid,
17478 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017479 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17480 }
17481
17482#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017483
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017484 // If its an Open Auth, FT IEs are not provided by supplicant
17485 // Hence populate them here
17486 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
17487 pMac->ft.ftSmeContext.addMDIE = FALSE;
17488 if( csrRoamIs11rAssoc(pMac) &&
17489 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
17490 {
17491 tANI_U16 ft_ies_length;
17492 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
17493
17494 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
17495 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
17496 {
17497 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
17498 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
17499 }
17500
17501 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
17502 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
17503 {
17504 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
17505 }
17506 else
17507 {
17508 // Copy the RIC IEs to reassoc IEs
17509 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
17510 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
17511 pFTPreAuthRsp->ric_ies_length);
17512 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
17513 pMac->ft.ftSmeContext.addMDIE = TRUE;
17514 }
17515 }
17516
Jeff Johnson295189b2012-06-20 16:38:30 -070017517 // Done with it, init it.
17518 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
17519}
17520#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017521
Jeff Johnson295189b2012-06-20 16:38:30 -070017522#ifdef FEATURE_WLAN_BTAMP_UT_RF
17523void csrRoamJoinRetryTimerHandler(void *pv)
17524{
17525 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
17526 tpAniSirGlobal pMac = pInfo->pMac;
17527 tANI_U32 sessionId = pInfo->sessionId;
17528 tCsrRoamSession *pSession;
17529
17530 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17531 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017532 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017533 pSession = CSR_GET_SESSION( pMac, sessionId );
17534 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17535 {
17536 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17537 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017538 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017539 }
17540 }
17541 }
17542}
Jeff Johnson295189b2012-06-20 16:38:30 -070017543eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17544{
17545 eHalStatus status = eHAL_STATUS_FAILURE;
17546 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17547
17548 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17549 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017550 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017551 pSession->maxRetryCount--;
17552 pSession->joinRetryTimerInfo.pMac = pMac;
17553 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017554 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17555 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017556 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017557 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017558 }
17559 }
17560 else
17561 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017562 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017563 pSession->maxRetryCount);
17564 }
17565
17566 return (status);
17567}
Jeff Johnson295189b2012-06-20 16:38:30 -070017568eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17569{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017570 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017571 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17572 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017573 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017574 }
17575
17576 return eHAL_STATUS_SUCCESS;
17577}
17578#endif
17579
17580
17581/*
17582 pBuf points to the beginning of the message
17583 LIM packs disassoc rsp as below,
17584 messageType - 2 bytes
17585 messageLength - 2 bytes
17586 sessionId - 1 byte
17587 transactionId - 2 bytes (tANI_U16)
17588 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17589 peerMacAddr - 6 bytes
17590 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17591*/
17592static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17593{
17594 if(pBuf && pRsp)
17595 {
17596 pBuf += 4; //skip type and length
17597 pRsp->sessionId = *pBuf++;
17598 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17599 pBuf += 2;
17600 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17601 pBuf += 4;
17602 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17603 }
17604}
17605
Jeff Johnsond13512a2012-07-17 11:42:19 -070017606eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17607{
17608 static uNvTables nvTables;
17609 eHalStatus status = eHAL_STATUS_SUCCESS;
17610 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17611
17612 /* read the country code from NV and use it */
17613 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17614 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017615 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17616 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017617 return status;
17618 }
17619 else
17620 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017621 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017622 status = eHAL_STATUS_FAILURE;
17623 return status;
17624 }
17625}
17626
17627eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17628{
Kiet Lam64c1b492013-07-12 13:56:44 +053017629 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017630 return eHAL_STATUS_SUCCESS;
17631}
schang86c22c42013-03-13 18:41:24 -070017632
17633eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17634{
17635 tSirSetTxPowerReq *pMsg = NULL;
17636 eHalStatus status = eHAL_STATUS_SUCCESS;
17637 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17638
17639 if (!pSession)
17640 {
17641 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17642 return eHAL_STATUS_FAILURE;
17643 }
17644
Kiet Lam64c1b492013-07-12 13:56:44 +053017645 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17646 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17647 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17648 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17649 pMsg->length = sizeof(tSirSetTxPowerReq);
17650 pMsg->mwPower = mW;
17651 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17652 sizeof(tSirMacAddr));
17653 status = palSendMBMessage(pMac->hHdd, pMsg);
17654 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017655 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017656 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17657 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017658 }
17659 return status;
17660}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017661
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017662eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17663{
17664 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17665 eHalStatus status = eHAL_STATUS_SUCCESS;
17666 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17667
17668 if (!pSession)
17669 {
17670 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17671 return eHAL_STATUS_FAILURE;
17672 }
17673 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17674 {
17675 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053017676
17677 if( NULL == pMsg )
17678 {
17679 smsLog(pMac, LOGE, FL("PMsg is NULL "));
17680 return eHAL_STATUS_FAILURE;
17681 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017682 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17683 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17684 pMsg->length = sizeof(tANI_U8);
17685 pMsg->seesionId = sessionId;
17686 status = palSendMBMessage(pMac->hHdd, pMsg);
17687 if (!HAL_STATUS_SUCCESS(status))
17688 {
17689 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17690 //pMsg is freed by palSendMBMessage
17691 }
17692 }
17693 else
17694 {
17695 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17696 status = eHAL_STATUS_FAILURE;
17697 }
17698 return status;
17699}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017700/* Returns whether a session is in VOS_STA_MODE...or not */
17701tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17702{
17703 tCsrRoamSession *pSession = NULL;
17704 pSession = CSR_GET_SESSION ( pMac, sessionId );
17705 if(!pSession)
17706 {
17707 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17708 return eANI_BOOLEAN_FALSE;
17709 }
17710 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17711 {
17712 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17713 return eANI_BOOLEAN_FALSE;
17714 }
17715 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17716 {
17717 return eANI_BOOLEAN_FALSE;
17718 }
17719 /* There is a possibility that the above check may fail,because
17720 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17721 * when it is connected.So,we may sneak through the above check even
17722 * if we are not a STA mode INFRA station. So, if we sneak through
17723 * the above condition, we can use the following check if we are
17724 * really in STA Mode.*/
17725
17726 if ( NULL != pSession->pCurRoamProfile )
17727 {
17728 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17729 {
17730 return eANI_BOOLEAN_TRUE;
17731 } else {
17732 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17733 return eANI_BOOLEAN_FALSE;
17734 }
17735 }
17736
17737 return eANI_BOOLEAN_FALSE;
17738}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017739
17740#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17741eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17742 tCsrHandoffRequest *pHandoffInfo)
17743{
17744 eHalStatus status = eHAL_STATUS_SUCCESS;
17745 vos_msg_t msg;
17746
17747 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017748 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17749 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017750 {
17751 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017752 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017753 }
17754 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17755 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17756 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17757 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017758 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017759 pHandoffInfo->bssid,
17760 6);
17761 msg.type = eWNI_SME_HANDOFF_REQ;
17762 msg.bodyptr = pMsg;
17763 msg.reserved = 0;
17764 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17765 {
17766 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017767 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017768 status = eHAL_STATUS_FAILURE;
17769 }
17770 return status;
17771}
17772#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017773
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017774
17775#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017776/* ---------------------------------------------------------------------------
17777 \fn csrSetCCKMIe
17778 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17779 data structure and this IE will be packed inside reassociation request
17780 \param pMac - pMac global structure
17781 \param sessionId - Current session id
17782 \param pCckmIe - pointer to CCKM IE data
17783 \param ccKmIeLen - length of the CCKM IE
17784 \- return Success or failure
17785 -------------------------------------------------------------------------*/
17786VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17787 const tANI_U8 *pCckmIe,
17788 const tANI_U8 ccKmIeLen)
17789{
17790 eHalStatus status = eHAL_STATUS_SUCCESS;
17791 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17792
17793 if (!pSession)
17794 {
17795 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17796 return eHAL_STATUS_FAILURE;
17797 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017798 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017799 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17800 return status;
17801}
17802
17803/* ---------------------------------------------------------------------------
17804 \fn csrRoamReadTSF
17805 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17806 probe response reception from the hand off AP to arrive at the latest TSF value.
17807 \param pMac - pMac global structure
17808 \param pTimestamp - output TSF timestamp
17809 \- return Success or failure
17810 -------------------------------------------------------------------------*/
17811VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17812{
17813 eHalStatus status = eHAL_STATUS_SUCCESS;
17814 tCsrNeighborRoamBSSInfo handoffNode;
17815 tANI_U32 timer_diff = 0;
17816 tANI_U32 timeStamp[2];
17817 tpSirBssDescription pBssDescription = NULL;
17818
17819 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17820 pBssDescription = handoffNode.pBssDescription;
17821
17822 // Get the time diff in milli seconds
17823 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17824 // Convert msec to micro sec timer
17825 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17826
17827 timeStamp[0] = pBssDescription->timeStamp[0];
17828 timeStamp[1] = pBssDescription->timeStamp[1];
17829
17830 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17831
Kiet Lamf2f201e2013-11-16 21:24:16 +053017832 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017833 sizeof (tANI_U32) * 2);
17834 return status;
17835}
17836
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017837#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017838
Agarwal Ashish738843c2014-09-25 12:27:56 +053017839/* ---------------------------------------------------------------------------
17840 \fn csrDisableDfsChannel
17841 \brief This function will call csrApplyChannelPowerCountryInfo to
17842 \ to trim the list on basis of NO_DFS flag.
17843 \param pMac - pMac global structure
17844 \- return void
17845 -------------------------------------------------------------------------*/
17846void csrDisableDfsChannel(tpAniSirGlobal pMac)
17847{
17848 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
17849 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
17850}