blob: 9b87c1692722c36d67bd400df78b3b58fd75f782 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05302 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028/**========================================================================
29
30 \file wlan_hdd_assoc.c
31 \brief WLAN Host Device Driver implementation
Shailender Karmuchia734f332013-04-19 14:02:48 -070032
Jeff Johnson295189b2012-06-20 16:38:30 -070033 ========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070034/**=========================================================================
35 EDIT HISTORY FOR FILE
36
37
38 This section contains comments describing changes made to the module.
39 Notice that changes are listed in reverse chronological order.
40
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070046 -------- --- --------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -070047 05/06/09 Shailender Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070048 ==========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070049
Jeff Johnson295189b2012-06-20 16:38:30 -070050#include "wlan_hdd_includes.h"
51#include <aniGlobal.h>
52#include "dot11f.h"
53#include "wlan_nlink_common.h"
54#include "wlan_btc_svc.h"
55#include "wlan_hdd_power.h"
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +053056#include "wlan_hdd_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070057#include <linux/ieee80211.h>
58#include <linux/wireless.h>
59#include <net/cfg80211.h>
60#include "wlan_hdd_cfg80211.h"
61#include "csrInsideApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include "wlan_hdd_p2p.h"
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053063#include <vos_sched.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080064#include "wlan_hdd_tdls.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "sme_Api.h"
Sushant Kaushikba6764e2014-06-30 19:52:09 +053066#include "wlan_hdd_hostapd.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053067#include "vos_utils.h"
Siddharth Bhalda0d1622015-04-24 15:47:49 +053068#include <wlan_hdd_wext.h>
Mukul Sharma84f27252014-07-14 18:11:42 +053069
Jeff Johnson295189b2012-06-20 16:38:30 -070070v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
71
Shailender Karmuchia734f332013-04-19 14:02:48 -070072struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -070073{
74 u_char ether_addr_octet[6];
75};
76// These are needed to recognize WPA and RSN suite types
77#define HDD_WPA_OUI_SIZE 4
78v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
79v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
80v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
81v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
82v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
83v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080084#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070085v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080086#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070087#define HDD_RSN_OUI_SIZE 4
88v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
89v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
90v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
91v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
92v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
93v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080094#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070095v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080096#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -070097#ifdef WLAN_FEATURE_11W
98v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053099/* RSN-8021X-SHA256 */
100v_U8_t ccpRSNOui08[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 };
Chet Lanctot186b5732013-03-18 10:26:30 -0700101#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700102
Shailender Karmuchia734f332013-04-19 14:02:48 -0700103#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700104// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700105#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
106#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700107#endif
108
109#define BEACON_FRAME_IES_OFFSET 12
110
Chet Lanctot186b5732013-03-18 10:26:30 -0700111#ifdef WLAN_FEATURE_11W
112void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
113 tANI_U32 nFrameLength,
114 tANI_U8* pbFrames,
115 tANI_U8 frameType );
116#endif
117
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800118#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700119static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
120 tANI_U8 state,
121 tANI_U16 measInterval );
122static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800123static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
124static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700125
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800126#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700127
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530128static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
129 tCsrRoamInfo *pRoamInfo,
130 tANI_U32 roamId,
131 eRoamCmdStatus roamStatus,
132 eCsrRoamResult roamResult );
133
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530134v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
135 eConnectionState connState )
136{
137 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530138 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
139 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700140 pHddStaCtx->conn_info.connState = connState;
141}
142
143// returns FALSE if not connected.
144// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
145// returns the connection state. Can specify NULL if you dont' want to get the actual state.
146
Shailender Karmuchia734f332013-04-19 14:02:48 -0700147static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
148 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700149{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700150 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700152
Jeff Johnson295189b2012-06-20 16:38:30 -0700153 // get the connection state.
154 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700155 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700157 eConnectionState_IbssConnected == connState ||
158 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 {
160 fConnected = VOS_TRUE;
161 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700162 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 {
164 fConnected = VOS_FALSE;
165 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700166
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 if ( pConnState )
168 {
169 *pConnState = connState;
170 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700171
Jeff Johnson295189b2012-06-20 16:38:30 -0700172 return( fConnected );
173}
174
175v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
176{
177 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700178}
Jeff Johnson295189b2012-06-20 16:38:30 -0700179
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530180eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
181{
182 v_U8_t staChannel = 0;
183
184 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
185 {
186 staChannel = pHddStaCtx->conn_info.operationChannel;
187 }
188
189 if ( staChannel > 0 && staChannel < 14 )
190 return eCSR_BAND_24;
191 else if (staChannel >= 36 && staChannel <= 165 )
192 return eCSR_BAND_5G;
193 else /* If station is not connected return as eCSR_BAND_ALL */
194 return eCSR_BAND_ALL;
195}
196
197
Jeff Johnson295189b2012-06-20 16:38:30 -0700198//TODO - Not used anyhwere. Can be removed.
199#if 0
200//
201v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
202{
203 v_BOOL_t fConnectedInfra = FALSE;
204 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700205
Jeff Johnson295189b2012-06-20 16:38:30 -0700206 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700207 {
208 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700209 {
210 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700211 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700212 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700213
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 return( fConnectedInfra );
215}
216#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700217
Jeff Johnson295189b2012-06-20 16:38:30 -0700218static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
219{
220 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700221
Jeff Johnson295189b2012-06-20 16:38:30 -0700222 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700223
224 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700225 {
226 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
227 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700228
Jeff Johnson295189b2012-06-20 16:38:30 -0700229 return( fConnected );
230}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700231
Jeff Johnson295189b2012-06-20 16:38:30 -0700232inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
233{
234 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700235
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700237
238 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 {
240 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
241 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700242
Jeff Johnson295189b2012-06-20 16:38:30 -0700243 return( fConnected );
244}
245
246static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
247{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700248 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700249 {
250 case eCSR_BSS_TYPE_INFRASTRUCTURE:
251 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
252 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700253
Jeff Johnson295189b2012-06-20 16:38:30 -0700254 case eCSR_BSS_TYPE_IBSS:
255 case eCSR_BSS_TYPE_START_IBSS:
256 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
257 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700258
259 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700260 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700261 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700262 default:
263 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700264 break;
265 }
266
Jeff Johnson295189b2012-06-20 16:38:30 -0700267}
268
269void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
270{
271 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
272 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700273
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700275
276 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700277 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700278 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700279 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
280 {
281 VOS_ASSERT( pRoamInfo->pBssDesc );
282 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
283
284 // Save the Station ID for this station from the 'Roam Info'.
285 //For IBSS mode, staId is assigned in NEW_PEER_IND
286 //For reassoc, the staID doesn't change and it may be invalid in this structure
287 //so no change here.
288 if( !pRoamInfo->fReassocReq )
289 {
290 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
291 }
292 }
293 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700294 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700295 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700296 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 else
298 {
299 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
300 // or we can't function.
301 VOS_ASSERT( 0 );
302 }
303
304 // notify WMM
305 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
306
307 if( !pRoamInfo->u.pConnectedProfile )
308 {
309 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
310 }
311 else
312 {
313 // Get Multicast Encryption Type
314 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
315 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
316 // Get Unicast Encrytion Type
317 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
318 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
319
320 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
321
322 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
323
324 // Save the ssid for the connection
325 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530326
327 // Save dot11mode in which STA associated to AP
328 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Deepthi Gowriae6a1662015-10-12 12:59:37 +0530329
330 pHddStaCtx->conn_info.rate_flags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700332 }
333
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700335 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
336
Jeff Johnson295189b2012-06-20 16:38:30 -0700337}
338
339#if defined(WLAN_FEATURE_VOWIFI_11R)
340/*
341 * Send the 11R key information to the supplicant.
342 * Only then can the supplicant generate the PMK-R1.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800343 * (BTW, the ESE supplicant also needs the Assoc Resp IEs
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 * for the same purpose.)
345 *
346 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
347 * this contains the R1KHID, R0KHID and the MDID.
348 * For FT, this consists of the Reassoc Rsp FTIEs.
349 * This is the Assoc Response.
350 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700351static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 tCsrRoamInfo *pCsrRoamInfo)
353{
354 union iwreq_data wrqu;
355 char *buff;
356 unsigned int len = 0;
357 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700358
359 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700360 {
361 hddLog(LOGE,
362 "%s: pCsrRoamInfo->nAssocRspLength=%d",
363 __func__, (int)pCsrRoamInfo->nAssocRspLength);
364 return;
365 }
366
Shailender Karmuchia734f332013-04-19 14:02:48 -0700367 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700368 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700369 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700370 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700371 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 return;
373 }
374
375 // pFTAssocRsp needs to point to the IEs
376 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
377 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
378 (unsigned int)pFTAssocRsp[0],
379 (unsigned int)pFTAssocRsp[1]);
380
381 // We need to send the IEs to the supplicant.
382 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700383 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700385 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700386 return;
387 }
388
389 // Send the Assoc Resp, the supplicant needs this for initial Auth.
390 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700391 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700393 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
395
396 kfree(buff);
397}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700398#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700399
400#ifdef WLAN_FEATURE_VOWIFI_11R
401
402/*---------------------------------------------------
403 *
404 * Send the FTIEs, RIC IEs during FT. This is eventually
405 * used to send the FT events to the supplicant
406 *
407 * At the reception of Auth2 we send the RIC followed
408 * by the auth response IEs to the supplicant.
409 * Once both are received in the supplicant, an FT
410 * event is generated to the supplicant.
411 *
412 *---------------------------------------------------
413 */
414void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
415{
Jeff Johnson295189b2012-06-20 16:38:30 -0700416 tANI_U16 auth_resp_len = 0;
417 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700418 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
419
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530420#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700421 struct cfg80211_ft_event_params ftEvent;
422 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
423 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
424 struct net_device *dev = pAdapter->dev;
425#else
426 char *buff;
427 union iwreq_data wrqu;
428 tANI_U16 str_len;
429#endif
430
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530431#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530432 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
433 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700434
Kanchanapally, Vidyullatha31b8d142015-01-30 14:25:18 +0530435 sme_GetRICIEs(pHddCtx->hHal, (u8 *)ricIe,
436 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530437 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700438 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530439 hddLog(LOGW,
440 "%s: RIC IEs is of length 0 not sending RIC Information for now",
441 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700442 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700443
444 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530445 ftEvent.ric_ies_len = ric_ies_length;
446 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700447
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530448 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800449 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700450
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530451 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700452 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530453 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700454 return;
455 }
456
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530457 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530458
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530459 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700460
461 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
462 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
463
Jeff Johnson59a121e2013-11-30 09:46:08 -0800464 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
465 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
466 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530467 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800468 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
469 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
470 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700471
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530472 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700473
474#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530475 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700476 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530477 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530479 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 return;
481 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530482 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700483
Shailender Karmuchia734f332013-04-19 14:02:48 -0700484 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530486 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800487 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530488 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530490 hddLog(LOGW,
491 "%s: RIC IEs is of length 0 not sending RIC Information for now",
492 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 }
494 else
495 {
496 wrqu.data.length = str_len + ric_ies_length;
497 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
498 }
499
500 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530501 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530503 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
504 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700505
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530506 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530508 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Bhargav Shah8b5b2f72015-07-14 11:53:46 +0530509 kfree(buff);
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 return;
511 }
512
513 wrqu.data.length = str_len + auth_resp_len;
514 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
515
516 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700517#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700518}
519
520#endif /* WLAN_FEATURE_VOWIFI_11R */
521
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800522#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700523
524/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800525 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 * (This keeps the supplicant "up to date" on the current channel.)
527 *
528 * The current (new AP) channel information is passed in.
529 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700530static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 tCsrRoamInfo *pCsrRoamInfo)
532{
533 union iwreq_data wrqu;
534 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700535
Shailender Karmuchia734f332013-04-19 14:02:48 -0700536
537 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 {
539 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800540 "%s: pCsrRoamInfo->pBssDesc=%p",
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 __func__, descriptor);
542 return;
543 }
544
545 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -0800546 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 memset(&wrqu, '\0', sizeof(wrqu));
548 wrqu.freq.m = descriptor->channelId;
549 wrqu.freq.e = 0;
550 wrqu.freq.i = 0;
551 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
552}
553
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800554#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700555
556void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
557{
558 union iwreq_data wrqu;
559 u8 *pBeaconIes;
560 u8 currentLen = 0;
561 char *buff;
562 int totalIeLen = 0, currentOffset = 0, strLen;
563
564 memset(&wrqu, '\0', sizeof(wrqu));
565
566 if (0 == pCsrRoamInfo->nBeaconLength)
567 {
568 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
569 return;
570 }
571 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700572 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700574 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700575 return;
576 }
577
578 // pBeaconIes needs to point to the IEs
579 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
580 (unsigned int)pBeaconIes[0],
581 (unsigned int)pBeaconIes[1]);
582 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700583
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 // We need to send the IEs to the supplicant.
585 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700586 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700588 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 return;
590 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700591 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700592
593 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
594 currentLen = strLen + 1;
595
596 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
597 do
598 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700599 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 * max size and send it to supplicant. Changes are done in supplicant to handle this */
601 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
602 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
603 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
604 currentOffset += currentLen;
605 totalIeLen -= currentLen;
606 wrqu.data.length = strLen + 1 + currentLen;
607 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700608 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700609 else
610 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
611
612 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
613 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
614 } while (totalIeLen > 0);
615
616 kfree(buff);
617}
618
619static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
620{
621 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
622 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
623 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
624 union iwreq_data wrqu;
625 int we_event;
626 char *msg;
627 int type = -1;
628
Shailender Karmuchia734f332013-04-19 14:02:48 -0700629#if defined (WLAN_FEATURE_VOWIFI_11R)
630 // Added to find the auth type on the fly at run time
631 // rather than with cfg to see if FT is enabled
632 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
634#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700635
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700637 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700639
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
641 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530642 /* In case of roaming ; We are not doing disconnect.
643 * If disconnect is not being done for roam; We will not
644 * decrease count for Active sessions. We should not increase active
645 * active session in case of roaming.
646 */
Padma, Santhosh Kumar87ba40f2014-11-26 19:40:15 +0530647 if((pHddStaCtx->ft_carrier_on == FALSE) && !pCsrRoamInfo->fReassocReq)
Agarwal Ashish51325b52014-06-16 16:50:49 +0530648 {
649 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
650 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700651 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
652 type = WLAN_STA_ASSOC_DONE_IND;
653
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700654#ifdef WLAN_FEATURE_P2P_DEBUG
655 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
656 {
657 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
658 {
659 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
660 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
661 "Connecting state to Connected State for 8-way "
662 "Handshake");
663 }
664 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
665 {
666 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
667 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
668 "Connecting state to P2P Client Connection Completed");
669 }
670 }
671#endif
SaidiReddy Yenugaa8b32f92016-07-27 19:29:18 +0530672 hddLog(VOS_TRACE_LEVEL_INFO, MAC_ADDRESS_STR " connected to "
Sushant Kaushikdc3184b2015-10-09 12:00:21 +0530673 MAC_ADDRESS_STR,
Arif Hussain77d044f2014-01-03 19:56:04 -0800674 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
Kiet Lam34947452014-01-21 23:23:40 -0800675 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700676 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
677
Bhargav Shahd0715912015-10-01 18:17:37 +0530678 hdd_manage_delack_timer(pHddCtx);
679
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
681 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
682 * and fFTEnable is TRUE */
683#ifdef WLAN_FEATURE_VOWIFI_11R
684 // Send FT Keys to the supplicant when FT is enabled
685 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700686 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800687#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700688 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
689 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
690#endif
691 )
692 {
693 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
694 }
695#endif
696 }
697 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
698 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530699 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -0700700 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700701 type = WLAN_STA_ASSOC_DONE_IND;
Deepthi Gowric7591cc2015-12-28 15:43:17 +0530702
703 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
704 "wlan: new IBSS connection to " MAC_ADDRESS_STR,
705 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700706 }
707 else /* Not Associated */
708 {
Deepthi Gowric7591cc2015-12-28 15:43:17 +0530709 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
710 "wlan: disconnected");
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 type = WLAN_STA_DISASSOC_DONE_IND;
712 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
Bhargav Shahd0715912015-10-01 18:17:37 +0530713
714 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700716 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700717
718 msg = NULL;
719 /*During the WLAN uninitialization,supplicant is stopped before the
720 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530721 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 {
723 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800724#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700725 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700726 {
727 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
728 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
730 }
731#endif
732 }
733 send_btc_nlink_msg(type, 0);
734}
735
736void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
737{
738 // Remove staId, bssId and peerMacAddress
739 pHddStaCtx->conn_info.staId [ 0 ] = 0;
740 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
741 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
742
743 // Clear all security settings
744 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
745 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
746 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
747
748 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700749 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700750
751 // Set not-connected state
752 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700753
754 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
755}
Katya Nigam47528772015-02-11 12:24:49 +0530756
757VOS_STATUS hdd_ibss_deinit_tx_rx_sta ( hdd_adapter_t *pAdapter, v_U8_t STAId )
758{
Katya Nigam1fd24402015-02-16 14:52:19 +0530759 v_U8_t ac;
760 /**Track whether OS TX queue has been disabled.*/
761 v_BOOL_t txSuspended[NUM_TX_QUEUES];
762 v_U8_t tlAC;
Katya Nigam47528772015-02-11 12:24:49 +0530763 v_U8_t i;
764 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
765 hdd_ibss_peer_info_t *pPeerInfo;
766
767 if( NULL == pHddStaCtx )
768 {
769 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
770 "%s: HDD station context NULL ",__func__);
771 return VOS_STATUS_E_FAILURE;
772 }
Katya Nigam1fd24402015-02-16 14:52:19 +0530773
Katya Nigam47528772015-02-11 12:24:49 +0530774 pPeerInfo = &pHddStaCtx->ibss_peer_info;
775 if (FALSE == pPeerInfo->ibssStaInfo[STAId].isUsed)
776 {
777 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
778 "%s: Deinit station not inited %d", __func__, STAId );
779 return VOS_STATUS_E_FAILURE;
780 }
781
782 hdd_flush_ibss_tx_queues(pAdapter, STAId);
Katya Nigam1fd24402015-02-16 14:52:19 +0530783
784 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
785 {
786 tlAC = hdd_QdiscAcToTlAC[ac];
787 txSuspended[ac] = pPeerInfo->ibssStaInfo[STAId].txSuspended[tlAC];
788 }
789
Katya Nigam47528772015-02-11 12:24:49 +0530790 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
791
Katya Nigam1fd24402015-02-16 14:52:19 +0530792 /* re-init hdd list, since netdev can still open adapter until
793 * driver gets unloaded
794 */
795 for (i = 0; i < NUM_TX_QUEUES; i ++)
796 {
797 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i],
798 HDD_TX_QUEUE_MAX_LEN);
799 }
800
801 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
802 {
803 if (txSuspended[ac])
804 {
805 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
806 "%s: TX queue re-enabled", __func__);
807 netif_wake_subqueue(pAdapter->dev, ac);
808 }
809 }
Katya Nigam47528772015-02-11 12:24:49 +0530810 return VOS_STATUS_SUCCESS;
811}
812
813static VOS_STATUS hdd_ibss_DeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
814{
815 VOS_STATUS vosStatus;
816
817 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
818 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
819 {
820 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
821 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
822 "Status= %d [0x%08X]",
823 __func__, staId, vosStatus, vosStatus );
824 }
825
826 vosStatus = hdd_ibss_deinit_tx_rx_sta ( pAdapter, staId );
827 if( VOS_STATUS_E_FAILURE == vosStatus )
828 {
829 VOS_TRACE ( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
830 "hdd_ibss_deinit_tx_rx_sta() failed for staID %d. "
831 "Status = %d [0x%08X]",
832 staId, vosStatus, vosStatus );
833 }
834
835 return( vosStatus );
836}
837
838VOS_STATUS hdd_ibss_init_tx_rx_sta( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA)
839{
840 v_U8_t i = 0;
841 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
842 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
843
844 if (pPeerInfo->ibssStaInfo[STAId].isUsed)
845 {
846 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
847 "%s: Reinit station %d", __func__, STAId );
848 return VOS_STATUS_E_FAILURE;
849 }
850
851 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
852 for (i = 0; i < NUM_TX_QUEUES; i ++)
853 {
854 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i], HDD_TX_QUEUE_MAX_LEN);
855 }
856
857 pPeerInfo->ibssStaInfo[STAId].isUsed = VOS_TRUE;
858 pPeerInfo->ibssStaInfo[STAId].isDeauthInProgress = VOS_FALSE;
859 vos_copy_macaddr( &pPeerInfo->ibssStaInfo[STAId].macAddrSTA, pmacAddrSTA);
860
861 return VOS_STATUS_SUCCESS;
862}
863
864static VOS_STATUS hdd_ibss_RegisterSTA( hdd_adapter_t *pAdapter,
865 tCsrRoamInfo *pRoamInfo,
866 v_U8_t staId,
867 v_MACADDR_t *pPeerMacAddress,
868 tSirBssDescription *pBssDesc )
869{
870 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
871 WLAN_STADescType staDesc = {0};
872 eCsrEncryptionType connectedCipherAlgo;
873 v_BOOL_t fConnected;
874 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
875 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
876 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
877
878 if ( pPeerInfo->ibssStaInfo[staId].isUsed )
879 {
880 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
881 "clean up old entry for STA %d", staId);
882 hdd_ibss_DeregisterSTA( pAdapter, staId );
883 }
884
885 staDesc.ucSTAId = staId;
886 staDesc.wSTAType = WLAN_STA_IBSS;
887
888 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
889 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
890 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
891 // pass when making an Infrastructure connection.
892 vos_mem_copy(staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes));
893 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId, 6 );
894 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
895
896 if (hdd_wmm_is_active(pAdapter))
897 {
898 staDesc.ucQosEnabled = 1;
899 }
900 else
901 {
902 staDesc.ucQosEnabled = 0;
903 }
904 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
905 "HDD SOFTAP register TL QoS_enabled=%d",
906 staDesc.ucQosEnabled );
907
908 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
909 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
910 {
911 staDesc.ucProtectedFrame = 1;
912 }
913 else
914 {
915 staDesc.ucProtectedFrame = 0;
916
917 }
918
919 hdd_ibss_init_tx_rx_sta(pAdapter, staId, &staDesc.vSTAMACAddress);
920
921 // UMA is Not ready yet, Xlation will be done by TL
922 staDesc.ucSwFrameTXXlation = 1;
923 staDesc.ucSwFrameRXXlation = 1;
924 staDesc.ucAddRmvLLC = 1;
925 // Initialize signatures and state
926 staDesc.ucUcastSig = pRoamInfo->ucastSig;
927 staDesc.ucBcastSig = pRoamInfo->bcastSig;
928 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED;
929
930 staDesc.ucIsReplayCheckValid = VOS_FALSE;
931
932 // Register the Station with TL.
933 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
934 hdd_rx_packet_cbk,
935 hdd_tx_complete_cbk,
936 hdd_ibss_tx_fetch_packet_cbk, &staDesc,
937 pBssDesc->rssi );
938 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
939 {
940 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
941 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
942 vosStatus, vosStatus );
943 return vosStatus;
944 }
945
946 //Timer value should be in milliseconds
947 if ( pHddCtx->cfg_ini->dynSplitscan &&
948 ( VOS_TIMER_STATE_RUNNING !=
949 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
950 {
951 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
952 pHddCtx->cfg_ini->trafficMntrTmrForSplitScan);
953 }
954
955 pPeerInfo->ibssStaInfo[staId].ucSTAId = staId;
956 pPeerInfo->ibssStaInfo[staId].isQosEnabled = staDesc.ucQosEnabled;
957
958 vosStatus = WLANTL_ChangeSTAState( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId,
959 WLANTL_STA_AUTHENTICATED );
960
961 pPeerInfo->ibssStaInfo[staId].tlSTAState = WLANTL_STA_AUTHENTICATED;
962 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
963
964 return( vosStatus );
965}
966
Jeff Johnson295189b2012-06-20 16:38:30 -0700967/* TODO Revist this function. and data path */
968static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
969{
970 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700971
Katya Nigam47528772015-02-11 12:24:49 +0530972 hdd_disconnect_tx_rx(pAdapter);
Ravi Joshif9520d62013-10-18 04:11:46 -0700973
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
975 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
976 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530977 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700979 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700980 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 }
982 return( vosStatus );
983}
984
985
986static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
987 tANI_U32 roamId, eRoamCmdStatus roamStatus,
988 eCsrRoamResult roamResult )
989{
990 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700991 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 struct net_device *dev = pAdapter->dev;
993 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
994 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700995 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530996 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700997
998 // Sanity check
999 if(dev == NULL)
1000 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05301001 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001002 "%s: net_dev is released return", __func__);
1003 return eHAL_STATUS_FAILURE;
1004 }
1005
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301007 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 netif_tx_disable(dev);
1009 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +05301010 //TxTimeoutCount need to reset in case of disconnect handler
1011 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001012
Jeff Johnsone7245742012-09-05 17:12:55 -07001013 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301014 /* If only STA mode is on */
1015 if((pHddCtx->concurrency_mode <= 1) &&
1016 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
1017 {
1018 pHddCtx->isAmpAllowed = VOS_TRUE;
1019 }
1020
Agarwal Ashish47d18112014-08-04 19:55:07 +05301021 /* Need to apply spin lock before decreasing active sessions
1022 * as there can be chance for double decrement if context switch
1023 * Calls wlan_hdd_disconnect.
1024 */
1025
1026 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh087de602015-10-21 17:18:55 +05301027
1028 /* HDD has initiated disconnect, do not send disconnect indication
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301029 * to kernel. Sending disconnected event to kernel for userspace
1030 * initiated disconnect will be handled by diconnect handler call
1031 * to cfg80211_disconnected
Abhishek Singh087de602015-10-21 17:18:55 +05301032 */
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301033 if ((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
1034 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301035 {
1036 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1037 FL(" HDD has initiated a disconnect, no need to send"
1038 " disconnect indication to kernel"));
1039 sendDisconInd = FALSE;
1040 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301041 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -07001042 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301043 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singh087de602015-10-21 17:18:55 +05301044 FL("Set HDD connState to eConnectionState_Disconnecting from %d "),
Agarwal Ashish47d18112014-08-04 19:55:07 +05301045 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301046 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
1047 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 }
Agarwal Ashish47d18112014-08-04 19:55:07 +05301049 spin_unlock_bh(&pAdapter->lock_for_active_session);
1050
Jeff Johnson295189b2012-06-20 16:38:30 -07001051 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -07001052
1053 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07001054
1055 // indicate 'disconnect' status to wpa_supplicant...
1056 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 /* indicate disconnected event to nl80211 */
1058 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
1059 {
1060 /*During the WLAN uninitialization,supplicant is stopped before the
1061 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301062 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 {
Sushant Kaushik0b343422015-05-25 17:15:55 +05301064 if (sendDisconInd)
1065 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1066 "%s: sent disconnected event to nl80211",
1067 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001068#ifdef WLAN_FEATURE_P2P_DEBUG
1069 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1070 {
1071 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
1072 {
1073 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
1074 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
1075 "and moved to disconnected state");
1076 }
1077 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
1078 {
1079 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
1080 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
1081 "and moved to inactive state");
1082 }
1083 }
1084#endif
Sushant Kaushikbad61892015-07-10 16:43:28 +05301085 if ((roamStatus == eCSR_ROAM_LOSTLINK) &&
1086 !pRoamInfo->reasonCode)
1087 wlan_hdd_get_frame_logs(pAdapter,
1088 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301089 /*Only send indication to kernel if not initiated by kernel*/
1090 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301092 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
1093 if ( eCSR_ROAM_LOSTLINK == roamStatus )
1094 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301095 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
1096 pRoamInfo->reasonCode);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301097 }
1098 else
1099 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301100 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301101 WLAN_REASON_UNSPECIFIED);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301104
1105 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1106 {
1107 hddLog(LOG1,
1108 FL("P2P client is getting removed and we are tryig to re-enable TDLS"));
1109 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301110 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301111
Jeff Johnson295189b2012-06-20 16:38:30 -07001112 //If the Device Mode is Station
1113 // and the P2P Client is Connected
1114 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001115
1116 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001117 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001118 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 {
1120 //Enable BMPS only of other Session is P2P Client
1121 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001122 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001123
1124 if (NULL != pVosContext)
1125 {
1126 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1127
1128 if(NULL != pHddCtx)
1129 {
1130 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301131 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1132 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301134 if (pHddCtx->hdd_wlan_suspended)
1135 {
1136 hdd_set_pwrparams(pHddCtx);
1137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 }
1141 }
1142 }
1143 }
1144 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001145
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301146 hdd_wmm_adapter_clear(pAdapter);
Kapil Guptae6867482016-06-26 13:31:37 +05301147 /* Clear PER based roam stats */
1148#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1149 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
1150 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
1151 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
1152 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
1153 sme_unset_per_roam_rxconfig(pHddCtx->hHal);
1154#endif
Mukul Sharmac159c432014-01-15 15:42:46 +05301155#if defined(WLAN_FEATURE_VOWIFI_11R)
1156 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1157#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301158
1159 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1160 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301161 v_U8_t i;
1162
Katya Nigam63ce1772014-09-26 15:53:49 +05301163 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301164 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301165 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1166 {
1167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301168 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1169 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301170 sta_id, status, status );
1171
1172 status = eHAL_STATUS_FAILURE;
1173 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301174 pHddCtx->sta_to_adapter[sta_id] = NULL;
1175
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301176 /*Clear all the peer sta register with TL.*/
1177 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1178 {
1179 if (0 != pHddStaCtx->conn_info.staId[i])
1180 {
1181 sta_id = pHddStaCtx->conn_info.staId[i];
1182
1183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1184 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301185 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301186 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1187 {
1188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1189 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1190 "Status= %d [0x%x]"),
1191 sta_id, status, status );
1192 status = eHAL_STATUS_FAILURE;
1193 }
1194
Nirav Shah7e3c8132015-06-22 23:51:42 +05301195 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1196 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1197 if (vstatus != VOS_STATUS_SUCCESS) {
1198 hddLog(VOS_TRACE_LEVEL_ERROR,
1199 FL("Not able to remove staid hash %d"),
1200 sta_id);
1201 status = eHAL_STATUS_FAILURE;
1202 } else {
1203 hddLog(VOS_TRACE_LEVEL_INFO,
1204 FL("ibss station removed sta_id %d mac:"
1205 MAC_ADDRESS_STR), sta_id,
1206 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1207 }
1208
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301209 /*set the staid and peer mac as 0, all other reset are
1210 * done in hdd_connRemoveConnectInfo.
1211 */
1212 pHddStaCtx->conn_info.staId[i]= 0;
1213 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1214
1215 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1216 pHddCtx->sta_to_adapter[sta_id] = NULL;
1217 }
1218 }
1219
Katya Nigam63ce1772014-09-26 15:53:49 +05301220 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301221 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301223 sta_id = pHddStaCtx->conn_info.staId[0];
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05301224 /* clear scan cache for Link Lost */
1225 if (pRoamInfo && !pRoamInfo->reasonCode &&
1226 (eCSR_ROAM_LOSTLINK == roamStatus)) {
1227 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1228 pHddStaCtx->conn_info.bssId);
1229 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1230 pHddStaCtx->conn_info.bssId);
1231 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301232
1233 //We should clear all sta register with TL, for now, only one.
1234 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1235 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1236 {
1237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1238 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1239 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001240 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001241
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301242 status = eHAL_STATUS_FAILURE;
1243 }
1244
1245 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301247
1248#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1249 if (VOS_STATUS_SUCCESS !=
1250 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1251 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1252 {
1253 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1254 "WLANTL_ClearInterfaceStats Failed", __func__);
1255 }
1256 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1257 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1258 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1259 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1260#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1261
Jeff Johnson295189b2012-06-20 16:38:30 -07001262 // Clear saved connection information in HDD
1263 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +05301264 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1265 "%s: Set HDD connState to eConnectionState_NotConnected",
1266 __func__);
1267 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301268#ifdef WLAN_FEATURE_GTK_OFFLOAD
1269 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1270 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1271 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301272 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1273 sizeof (tSirGtkOffloadParams));
1274 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301275 }
1276#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001277
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001278#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001279 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1280 {
1281 wlan_hdd_tdls_disconnection_callback(pAdapter);
1282 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001283#endif
1284
Jeff Johnson295189b2012-06-20 16:38:30 -07001285 //Unblock anyone waiting for disconnect to complete
1286 complete(&pAdapter->disconnect_comp_var);
1287 return( status );
1288}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301289
1290static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
1291 v_U8_t staId)
1292{
1293 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1294 v_SINT_t i;
1295 v_SIZE_t size;
1296 VOS_STATUS status;
1297 v_BOOL_t granted = VOS_FALSE;
1298
1299 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1300 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
1301 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
1302 {
1303 //Indicate to TL that there is pending data if a queue is non empty
1304 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
1305 {
1306 size = 0;
1307 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
1308 if (size > 0)
1309 {
1310 if (i != WLANTL_AC_HIGH_PRIO)
1311 {
1312 if (VOS_FALSE ==
1313 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
1314 {
1315 hdd_wmm_acquire_access(pAdapter,
1316 (WLANTL_ACEnumType)i, &granted);
1317 pAdapter->psbChanged |= (1 << i);
1318 }
1319 else
1320 granted = VOS_TRUE;
1321 }
1322
1323 if (granted || (i == WLANTL_AC_HIGH_PRIO))
1324 {
1325 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
1326 staId, (WLANTL_ACEnumType)i);
1327 if (!VOS_IS_STATUS_SUCCESS(status))
1328 {
1329 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1330 "%s: Failure in indicating pkt to TL for QID=%d",
1331 __func__, i);
1332 }
1333 }
1334 }
1335 }
1336 }
1337}
1338
Jeff Johnson295189b2012-06-20 16:38:30 -07001339static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
1340 tCsrRoamInfo *pRoamInfo,
1341 v_U8_t staId,
1342 v_MACADDR_t *pPeerMacAddress,
1343 tSirBssDescription *pBssDesc )
1344{
1345 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1346 WLAN_STADescType staDesc = {0};
1347 eCsrEncryptionType connectedCipherAlgo;
1348 v_BOOL_t fConnected;
1349 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1350 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001351 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001352
1353 if ( NULL == pBssDesc)
1354 {
1355 return VOS_STATUS_E_FAILURE;
1356 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 // Get the Station ID from the one saved during the assocation.
1358 staDesc.ucSTAId = staId;
1359
Katya Nigam47528772015-02-11 12:24:49 +05301360 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001361
Katya Nigam47528772015-02-11 12:24:49 +05301362 // grab the bssid from the connection info in the adapter structure and hand that
1363 // over to TL when registering.
1364 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
1365 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001366
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1368
1369 // set the QoS field appropriately
1370 if (hdd_wmm_is_active(pAdapter))
1371 {
1372 staDesc.ucQosEnabled = 1;
1373 }
1374 else
1375 {
1376 staDesc.ucQosEnabled = 0;
1377 }
1378
1379 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1380 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1381 {
1382 staDesc.ucProtectedFrame = 1;
1383 }
1384 else
1385 {
1386 staDesc.ucProtectedFrame = 0;
1387
1388 }
1389
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001390#ifdef FEATURE_WLAN_ESE
1391 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1392#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001393
1394#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1395 /* check whether replay check is valid for the station or not */
1396 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1397 {
1398 /* Encryption mode is either TKIP or AES
1399 and replay check is valid for only these
1400 two encryption modes */
1401 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1402 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1403 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1404 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001405
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 else
1407 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001408 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001410 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001411 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1412 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1413 }
1414#endif
1415
1416#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001417 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 if (pAdapter->wapi_info.fIsWapiSta)
1419 {
1420 staDesc.ucIsWapiSta = 1;
1421 }
1422 else
1423 {
1424 staDesc.ucIsWapiSta = 0;
1425 }
1426#endif /* FEATURE_WLAN_WAPI */
1427
1428 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1429 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1430
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 // UMA is Not ready yet, Xlation will be done by TL
1432 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 staDesc.ucSwFrameRXXlation = 1;
1434 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001435 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 staDesc.ucQosEnabled );
1437 // Initialize signatures and state
1438 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1439 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1440 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1441 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001442 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001443 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "%s: HDD register TL ucInitState=%d", __func__, staDesc.ucInitState );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001444 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1445 hdd_rx_packet_cbk,
1446 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001447 hdd_tx_fetch_packet_cbk, &staDesc,
1448 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001449
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1451 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001452 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001453 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001454 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001455 return vosStatus;
1456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001457
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001458 if ( cfg_param->dynSplitscan &&
1459 ( VOS_TIMER_STATE_RUNNING !=
1460 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1461 {
1462 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1463 cfg_param->trafficMntrTmrForSplitScan);
1464 }
1465
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301466 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1467 // then go to 'authenticated'. For all other authentication types
1468 // (those that donot require upper layer authentication) we can put
1469 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001470 if (staDesc.wSTAType != WLAN_STA_IBSS)
1471 VOS_ASSERT( fConnected );
1472
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301473 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001474 {
1475 // Connections that do not need Upper layer auth, transition TL directly
1476 // to 'Authenticated' state.
1477 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1478 WLANTL_STA_AUTHENTICATED );
1479
1480 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301481
1482 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001483 }
1484 else
1485 {
1486 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301487 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1488 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001489 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301490 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001491 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 return( vosStatus );
1494}
1495
Jeff Johnson295189b2012-06-20 16:38:30 -07001496static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1497 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1498{
1499 unsigned int len = 0;
1500 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001501 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001502 tANI_U32 rspRsnLength = 0;
1503 struct ieee80211_channel *chan;
1504
Agarwal Ashish51325b52014-06-16 16:50:49 +05301505 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001506 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001507 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001508 }
1509
Agarwal Ashish51325b52014-06-16 16:50:49 +05301510 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001511 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1512 goto done;
1513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001514
Agarwal Ashish51325b52014-06-16 16:50:49 +05301515 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001516 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1517 goto done;
1518 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001519
1520 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1521 pCsrRoamInfo->nAssocReqLength);
1522 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001523 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001524
1525 //pFTAssocRsp needs to point to the IEs
1526 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001527 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001528 (unsigned int)pFTAssocRsp[0],
1529 (unsigned int)pFTAssocRsp[1]);
1530
1531 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001532 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001534 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001535 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001536
1537 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1538 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1539 reqRsnIe, reqRsnLength,
1540 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001541
1542done:
1543 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001544}
Jeff Johnson295189b2012-06-20 16:38:30 -07001545
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301546void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1547{
1548 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1549 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1550 tCsrRoamInfo roamInfo;
1551 roamInfo.fAuthRequired = FALSE;
1552 vos_mem_copy(roamInfo.bssid,
1553 pHddStaCtx->roam_info.bssid,
1554 WNI_CFG_BSSID_LEN);
1555 vos_mem_copy(roamInfo.peerMac,
1556 pHddStaCtx->roam_info.peerMac,
1557 WNI_CFG_BSSID_LEN);
1558
1559 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1560 &roamInfo,
1561 pHddStaCtx->roam_info.roamId,
1562 pHddStaCtx->roam_info.roamStatus,
1563 eCSR_ROAM_RESULT_AUTHENTICATED);
1564 if (halStatus != eHAL_STATUS_SUCCESS)
1565 {
1566 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1567 }
1568 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1569}
1570
Shailender Karmuchia734f332013-04-19 14:02:48 -07001571static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1572 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001573 eCsrRoamResult roamResult )
1574{
1575 struct net_device *dev = pAdapter->dev;
1576 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1577 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301578 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05301579 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001580 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1581 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001582#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 int ft_carrier_on = FALSE;
1584#endif
1585 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301586 v_BOOL_t hddDisconInProgress = FALSE;
1587
1588 /* HDD has initiated disconnect, do not send connect result indication
1589 * to kernel as it will be handled by __cfg80211_disconnect.
1590 */
Agarwal Ashishc089cec2015-08-10 13:10:04 +05301591 if (((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
1592 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)) &&
1593 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1594 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301595 {
1596 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1597 FL(" Disconnect from HDD in progress "));
1598 hddDisconInProgress = TRUE;
1599 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001600
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1602 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301603 if ( !hddDisconInProgress )
1604 {
1605 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301606 "%s: Set HDD connState to eConnectionState_Associated",
1607 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301608 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1609 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001610
c_hpothu44ff4e02014-05-08 00:13:57 +05301611 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 // Save the connection info from CSR...
1613 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
Kapil Guptae6867482016-06-26 13:31:37 +05301614
1615#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1616 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
1617 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
1618 !hddDisconInProgress &&
1619 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
1620 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
1621 sme_set_per_roam_rxconfig(pHddCtx->hHal,
1622 pHddStaCtx->conn_info.staId[0],
1623 pHddCtx->cfg_ini->rateDownThreshold,
1624 pHddCtx->cfg_ini->rateUpThreshold,
1625 pHddCtx->cfg_ini->PERroamTriggerPercent,
1626 pHddCtx->cfg_ini->PERroamRxPktsThreshold,
1627 pHddCtx->cfg_ini->waitPeriodForNextPERScan);
1628#endif
1629
Jeff Johnson295189b2012-06-20 16:38:30 -07001630#ifdef FEATURE_WLAN_WAPI
1631 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1632 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1633 {
1634 pAdapter->wapi_info.fIsWapiSta = 1;
1635 }
1636 else
1637 {
1638 pAdapter->wapi_info.fIsWapiSta = 0;
1639 }
1640#endif /* FEATURE_WLAN_WAPI */
1641
1642 // indicate 'connect' status to userspace
1643 hdd_SendAssociationEvent(dev,pRoamInfo);
1644
1645
Shailender Karmuchia734f332013-04-19 14:02:48 -07001646 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001647 INIT_COMPLETION(pAdapter->linkup_event_var);
1648
1649 /*
1650 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1651 packet to go up to the application, device activation has to be ensured for proper queue mapping by the
Shailender Karmuchia734f332013-04-19 14:02:48 -07001652 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 know that the device is getting activated properly.
1654 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001655#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05301656 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07001657 {
1658#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001659 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001660 pAdapter->isLinkUpSvcNeeded = TRUE;
1661
Shailender Karmuchia734f332013-04-19 14:02:48 -07001662 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 pAdapter->isLinkUpSvcNeeded = TRUE;
1664
1665 // Switch on the Carrier to activate the device
1666 netif_carrier_on(dev);
1667
1668 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1669 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1670 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001671 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 {
1673 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1674 }
1675
1676 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1677 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001678#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001679 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001680 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001683 }
1684#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301685 /* Check for STAID */
1686 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1687 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1688 else
1689 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001690
1691 //For reassoc, the station is already registered, all we need is to change the state
1692 //of the STA in TL.
1693 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05301694 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 if( !pRoamInfo->fReassocReq )
1696 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001697 struct cfg80211_bss *bss;
1698#ifdef WLAN_FEATURE_VOWIFI_11R
1699 u8 *pFTAssocRsp = NULL;
1700 unsigned int assocRsplen = 0;
1701 u8 *pFTAssocReq = NULL;
1702 unsigned int assocReqlen = 0;
1703 struct ieee80211_channel *chan;
1704#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001707
1708 /* add bss_id to cfg80211 data base */
1709 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1710 if (NULL == bss)
1711 {
Abhishek Singh7ca68f32016-06-28 10:23:10 +05301712 hddLog(LOGE,
1713 FL("Not able to create BSS entry"));
Katya Nigam346d4e92014-09-02 16:16:12 +05301714 netif_carrier_off(dev);
Abhishek Singh7ca68f32016-06-28 10:23:10 +05301715 if (!hddDisconInProgress) {
1716 /*
1717 * Here driver was not able to update cfg80211 database
1718 * this can happen if connected channel is not valid,
1719 * i.e reg domain was changed during connection.
1720 * Queue disconnect for the session if disconnect is
1721 * not in progress.
1722 */
1723 hddLog(LOGE, FL("Disconnecting..."));
1724 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1725 pAdapter->sessionId,
1726 eCSR_DISCONNECT_REASON_UNSPECIFIED);
1727 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 return eHAL_STATUS_FAILURE;
1729 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001730#ifdef WLAN_FEATURE_VOWIFI_11R
1731 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001732 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001734
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001735 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001736 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001737 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001738 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001739 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001740 // pFTAssocRsp needs to point to the IEs
1741 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1742 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1743 (unsigned int)pFTAssocRsp[0],
1744 (unsigned int)pFTAssocRsp[1]);
1745 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001746 }
1747 else
1748 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001749 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1750 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001751 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001752
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001753 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001754 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001755 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001756 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001757 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001758 if(!ft_carrier_on)
1759 {
1760 // pFTAssocReq needs to point to the IEs
1761 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1762 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1763 (unsigned int)pFTAssocReq[0],
1764 (unsigned int)pFTAssocReq[1]);
1765 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1766 }
1767 else
1768 {
1769 /* This should contain only the FTIEs */
1770 assocReqlen = pRoamInfo->nAssocReqLength;
1771 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001772 }
1773 else
1774 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001775 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1776 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001777 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001778
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001779 if(ft_carrier_on)
1780 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301781 if ( !hddDisconInProgress )
1782 {
1783 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001784 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301785 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001786 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301787 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001788 assocRsplen);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05301789 if (pHddCtx->cfg_ini &&
1790 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301791 {
1792 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1793 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301794 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001795 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1796 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301797 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301798 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1799 {
1800 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1801 pRoamInfo->fAuthRequired = FALSE;
1802
1803 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1804 pRoamInfo->bssid,
1805 HDD_MAC_ADDR_LEN);
1806 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1807 pRoamInfo->peerMac,
1808 HDD_MAC_ADDR_LEN);
1809 pHddStaCtx->roam_info.roamId = roamId;
1810 pHddStaCtx->roam_info.roamStatus = roamStatus;
1811 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1812 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001813 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301814 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001815 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001816 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001817 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001818 cfg80211_connect_result(dev, pRoamInfo->bssid,
1819 pFTAssocReq, assocReqlen,
1820 pFTAssocRsp, assocRsplen,
1821 WLAN_STATUS_SUCCESS,
1822 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001823 }
1824 }
1825 else
1826#endif
1827 {
1828 /* wpa supplicant expecting WPA/RSN IE in connect result */
1829 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1830 pAdapter->sessionId,
1831 &reqRsnLength,
1832 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001833
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001834 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1835 pAdapter->sessionId,
1836 &rspRsnLength,
1837 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301838 if ( !hddDisconInProgress )
1839 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001840#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301841 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301842 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301843 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05301844 if (pHddCtx->cfg_ini &&
1845 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301846 {
1847 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1848 }
Mukul Sharma84f27252014-07-14 18:11:42 +05301849 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301850 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001851#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001852
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301853 {
1854 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301855 "%s: sending connect indication to nl80211:"
1856 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301857 " result:%d and Status:%d",
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301858 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1859 roamResult, roamStatus);
1860
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301861 /* inform connect result to nl80211 */
1862 cfg80211_connect_result(dev, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001863 reqRsnIe, reqRsnLength,
1864 rspRsnIe, rspRsnLength,
1865 WLAN_STATUS_SUCCESS,
1866 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301867 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001868 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001869 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301870 if ( !hddDisconInProgress )
1871 {
1872 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001873#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301874 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001875#endif
1876 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301877 // Register the Station with TL after associated...
1878 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 pRoamInfo,
1880 pHddStaCtx->conn_info.staId[ 0 ],
1881 NULL,
1882 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301883 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 }
1885 else
1886 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001887 /* wpa supplicant expecting WPA/RSN IE in connect result */
1888 /* in case of reassociation also need to indicate it to supplicant */
1889 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1890 pAdapter->sessionId,
1891 &reqRsnLength,
1892 reqRsnIe);
1893
1894 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301896 if( pRoamInfo->fAuthRequired )
1897 {
1898 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1899 pHddStaCtx->conn_info.staId[ 0 ],
1900 WLANTL_STA_CONNECTED );
1901 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1902 }
1903 else
1904 {
1905 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1906 "%s: staId: %d Changing TL state to AUTHENTICATED",
1907 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1908 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1909 pHddStaCtx->conn_info.staId[ 0 ],
1910 WLANTL_STA_AUTHENTICATED );
1911 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301912 hdd_postTLPacketPendingInd(pAdapter,
1913 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301914 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 }
1916
1917 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1918 {
1919 // perform any WMM-related association processing
1920 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1921 }
1922 else
1923 {
1924 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001925 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 vosStatus, vosStatus );
1927 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001928#ifdef WLAN_FEATURE_11W
1929 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1930 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1931#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301932
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05301934 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301935 {
1936 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05301937 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301938 }
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05301939 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301940 {
1941 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1942 }
Padma, Santhosh Kumar38cef182016-02-18 12:22:51 +05301943#ifdef FEATURE_WLAN_TDLS
1944 wlan_hdd_tdls_connection_callback(pAdapter);
1945#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001946 }
1947 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001948 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1950
1951 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001952 if (pRoamInfo)
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301953 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1954 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
1955 MAC_ADDR_ARRAY(pRoamInfo->bssid), roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001956 else
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301957 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1958 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
Arif Hussain24bafea2013-11-15 15:10:03 -08001959 MAC_ADDR_ARRAY(pWextState->req_bssId),
1960 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001961
Sachin Ahuja674c5112015-10-14 13:16:49 +05301962 if (( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
1963 ((roamResult != eCSR_ROAM_RESULT_ASSOCIATED) &&
1964 (eCSR_ROAM_ASSOCIATION_COMPLETION == roamStatus)))
Abhishek Singh611295e2015-07-09 11:11:54 +05301965 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05301966 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
1967
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05301968 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
1969 (pRoamInfo &&
1970 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
1971 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
1972 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode)))) {
1973 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1974 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
1975 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1976 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
1977 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05301978 /* Set connection state to eConnectionState_NotConnected only when CSR
1979 * has completed operation - with a ASSOCIATION_FAILURE status
1980 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301981 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301982 {
1983 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1984 "%s: Set HDD connState to eConnectionState_NotConnected",
1985 __func__);
1986 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1987 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05301988 if((pHddCtx->concurrency_mode <= 1) &&
1989 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07001990 {
1991 pHddCtx->isAmpAllowed = VOS_TRUE;
1992 }
1993
1994 //If the Device Mode is Station
1995 // and the P2P Client is Connected
1996 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001997
1998 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001999 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07002000 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
2001 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05302002 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07002003 {
2004 //Enable BMPS only of other Session is P2P Client
2005 hdd_context_t *pHddCtx = NULL;
2006 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
2007
2008 if (NULL != pVosContext)
2009 {
2010 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
2011
2012 if(NULL != pHddCtx)
2013 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302014 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05302015 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
2016 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302017 {
2018 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002019 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302020 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002021 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302022 hdd_enable_bmps_imps(pHddCtx);
2023 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 }
2025 }
2026 }
2027
James Zmudafbf5ffc2013-03-25 12:45:35 -07002028 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08002029 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302030 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07002031 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05302032
2033 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2034 {
2035 hddLog(LOG1,
2036 FL("Assoication Failure for P2P client and we are trying to re-enable TDLS"));
2037 wlan_hdd_tdls_reenable(pHddCtx);
2038 }
2039
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302040 if (pRoamInfo)
2041 hddLog(VOS_TRACE_LEVEL_ERROR,
2042 "%s: send connect failure to nl80211:"
2043 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302044 " result:%d and Status:%d reasonCode %d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302045 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302046 roamResult, roamStatus, pRoamInfo->reasonCode);
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302047 else
2048 hddLog(VOS_TRACE_LEVEL_ERROR,
2049 "%s: connect failed:"
2050 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302051 " result:%d and Status:%d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302052 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
2053 roamResult, roamStatus);
2054
James Zmudafbf5ffc2013-03-25 12:45:35 -07002055 /* inform association failure event to nl80211 */
2056 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
2057 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002058 if (pRoamInfo)
2059 cfg80211_connect_result ( dev, pRoamInfo->bssid,
2060 NULL, 0, NULL, 0,
2061 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
2062 GFP_KERNEL );
2063 else
2064 cfg80211_connect_result ( dev, pWextState->req_bssId,
2065 NULL, 0, NULL, 0,
2066 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
2067 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07002068 }
2069 else
2070 {
Gao Wu6ca73b32016-05-09 14:35:49 +08002071 if (pRoamInfo)
2072 cfg80211_connect_result ( dev, pRoamInfo->bssid,
2073 NULL, 0, NULL, 0,
2074 pRoamInfo->reasonCode ?
2075 pRoamInfo->reasonCode :
2076 WLAN_STATUS_UNSPECIFIED_FAILURE,
2077 GFP_KERNEL );
2078 else
2079 cfg80211_connect_result ( dev, pWextState->req_bssId,
2080 NULL, 0, NULL, 0,
2081 WLAN_STATUS_UNSPECIFIED_FAILURE,
2082 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07002083 }
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302084 /*Clear the roam profile*/
2085 hdd_clearRoamProfileIe( pAdapter );
Jeff Johnsone7245742012-09-05 17:12:55 -07002086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002087
Kumar Anand82c009f2014-05-29 00:29:42 -07002088 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002089
c_hpothu24f40982014-04-18 18:00:36 +05302090 if (pRoamInfo)
2091 {
2092 WLANTL_AssocFailed(pRoamInfo->staId);
2093 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302094
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302095 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002096 netif_tx_disable(dev);
2097 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002098
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 }
2100
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302101 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302102 {
2103 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2104 if (pHostapdAdapter != NULL)
2105 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302106 /* Restart SAP if its operating channel is different
2107 * from AP channel.
2108 */
2109 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2110 (int)pRoamInfo->pBssDesc->channelId)
2111 {
2112 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2113 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2114 (int)pRoamInfo->pBssDesc->channelId);
Deepthi Gowric9c777d2014-12-10 16:17:11 +05302115 hdd_hostapd_stop(pHostapdAdapter->dev);
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302116 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302117 }
2118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 return eHAL_STATUS_SUCCESS;
2120}
2121
2122/**============================================================================
2123 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002124 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002125 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002126
Jeff Johnson295189b2012-06-20 16:38:30 -07002127 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002128static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2129 tCsrRoamInfo *pRoamInfo,
2130 tANI_U32 roamId,
2131 eRoamCmdStatus roamStatus,
2132 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002133{
Katya Nigam47528772015-02-11 12:24:49 +05302134 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2135 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2136 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302137 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302138
Jeff Johnson81c17882013-05-03 09:53:35 -07002139 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2140 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2141
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 switch( roamResult )
2143 {
2144 // both IBSS Started and IBSS Join should come in here.
2145 case eCSR_ROAM_RESULT_IBSS_STARTED:
2146 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002147 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002148 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002149 if (NULL == pRoamInfo)
2150 {
2151 VOS_ASSERT(0);
2152 return;
2153 }
2154
2155 /* When IBSS Started comes from CSR, we need to move
2156 * connection state to IBSS Disconnected (meaning no peers
2157 * are in the IBSS).
2158 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302159 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2160 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2161 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002162 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2163 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302164 /*notify wmm */
2165 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002166 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002167
Jeff Johnson81c17882013-05-03 09:53:35 -07002168 if (pRoamInfo->pBssDesc)
2169 {
Anand N Sunkadfec40682015-07-29 09:51:17 +05302170#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2171 struct ieee80211_channel *chan;
2172 int chan_no;
2173 unsigned int freq;
2174#endif
Katya Nigam47528772015-02-11 12:24:49 +05302175 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2176 IBSS_BROADCAST_STAID,
2177 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002178
2179 /* we created the IBSS, notify supplicant */
2180 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2181 MAC_ADDRESS_STR,
2182 __func__, pAdapter->dev->name,
2183 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2184
2185 /* we must first give cfg80211 the BSS information */
2186 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2187 if (NULL == bss)
2188 {
2189 hddLog(VOS_TRACE_LEVEL_ERROR,
2190 "%s: %s: unable to create IBSS entry",
2191 __func__, pAdapter->dev->name);
2192 return;
2193 }
Abhishek Singh00b71972016-01-07 10:51:04 +05302194#ifdef WLAN_FEATURE_RMC
2195 netif_carrier_on(pAdapter->dev);
2196 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
2197 netif_tx_start_all_queues(pAdapter->dev);
2198#endif
Anand N Sunkadfec40682015-07-29 09:51:17 +05302199#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2200 chan_no = pRoamInfo->pBssDesc->channelId;
Jeff Johnson81c17882013-05-03 09:53:35 -07002201
Anand N Sunkadfec40682015-07-29 09:51:17 +05302202 if (chan_no <= 14)
2203 freq = ieee80211_channel_to_frequency(chan_no,
2204 IEEE80211_BAND_2GHZ);
2205 else
2206 freq = ieee80211_channel_to_frequency(chan_no,
2207 IEEE80211_BAND_5GHZ);
2208
2209 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
2210
2211 if (chan)
2212 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
2213 chan, GFP_KERNEL);
2214 else
2215 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
2216 pAdapter->dev->name,
2217 (int)pRoamInfo->pBssDesc->channelId);
2218#else
Jeff Johnson81c17882013-05-03 09:53:35 -07002219 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302220#endif
Yue Maf49ba872013-08-19 12:04:25 -07002221 cfg80211_put_bss(
2222#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2223 pHddCtx->wiphy,
2224#endif
2225 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07002226 }
Katya Nigam47528772015-02-11 12:24:49 +05302227 else
2228 {
2229 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2230 "%s: NULL Bss Desc",__func__);
2231 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05302232
2233 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
2234 * in IBSS_COALESCED will remove the BC key.
2235 */
2236 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
2237 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
2238 == pHddStaCtx->ibss_enc_key.encType
2239 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
2240 == pHddStaCtx->ibss_enc_key.encType
2241 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2242 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
2243 {
2244 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2245 VOS_STATUS vosStatus;
2246
2247 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2248
2249 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2250 grpmacaddr, WNI_CFG_BSSID_LEN);
2251 hddLog(VOS_TRACE_LEVEL_INFO,
2252 FL(" SET GTK in case of COALESCED"));
2253 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2254 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2255 if ( VOS_STATUS_SUCCESS != vosStatus )
2256 {
2257 hddLog(VOS_TRACE_LEVEL_ERROR,
2258 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
2259 }
2260 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002261 break;
2262 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002263
Jeff Johnson295189b2012-06-20 16:38:30 -07002264 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
2265 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002266 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
2267 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07002268 break;
2269 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002270
Jeff Johnson295189b2012-06-20 16:38:30 -07002271 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07002272 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
2273 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07002274 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002275 }
2276
Jeff Johnson81c17882013-05-03 09:53:35 -07002277 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002278}
2279
2280/**============================================================================
2281 *
2282 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
2283 This information is passed to iwconfig later. The peer that joined
2284 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002285 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002286 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002287
Jeff Johnson295189b2012-06-20 16:38:30 -07002288 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05302289static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07002290{
2291 int fSuccess = FALSE;
2292 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302293 VOS_STATUS status;
2294 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002295
Jeff Johnson295189b2012-06-20 16:38:30 -07002296 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2297 {
2298 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
2299 {
2300 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002301
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002303
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 fSuccess = TRUE;
2305 break;
2306 }
2307 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002308
Nirav Shah7e3c8132015-06-22 23:51:42 +05302309 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
2310 if (status != VOS_STATUS_SUCCESS) {
2311 hddLog(VOS_TRACE_LEVEL_ERROR,
2312 FL("Not able to add staid hash %d"), staId);
2313 return FALSE;
2314 }
2315
2316 hddLog(VOS_TRACE_LEVEL_INFO,
2317 FL("New station added sta_id %d mac:"
2318 MAC_ADDRESS_STR), staId,
2319 MAC_ADDR_ARRAY(peerMacAddress->bytes));
2320
Shailender Karmuchia734f332013-04-19 14:02:48 -07002321 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07002322}
2323/**============================================================================
2324 *
2325 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002326 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002328
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07002330static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07002331{
2332 int fSuccess = FALSE;
2333 int idx = 0;
2334 v_U8_t valid_idx = 0;
2335 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07002336 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002337 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05302338 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002339
Jeff Johnson295189b2012-06-20 16:38:30 -07002340 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2341 {
2342 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
2343 {
2344 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302345 status = hdd_sta_id_hash_remove_entry(pAdapter,
2346 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
2347 if (status != VOS_STATUS_SUCCESS) {
2348 hddLog(VOS_TRACE_LEVEL_ERROR,
2349 FL("Not able to remove staid hash %d"), staId );
2350 fSuccess = FALSE;
2351 } else {
2352 hddLog(VOS_TRACE_LEVEL_INFO,
2353 FL("station removed sta_id %d mac:"
2354 MAC_ADDRESS_STR), staId,
2355 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07002356
Nirav Shah7e3c8132015-06-22 23:51:42 +05302357 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002358
Nirav Shah7e3c8132015-06-22 23:51:42 +05302359 fSuccess = TRUE;
2360 // Note the deleted Index, if its 0 we need special handling
2361 del_idx = idx;
2362 empty_slots++;
2363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002364 }
2365 else
2366 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002367 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 {
2369 valid_idx = idx;
2370 }
Ravi Joshi8a934352013-09-25 16:46:58 -07002371 else
2372 {
2373 // Found an empty slot
2374 empty_slots++;
2375 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 }
2377 }
2378
Ravi Joshi8a934352013-09-25 16:46:58 -07002379 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
2380 {
2381 // Last peer departed, set the IBSS state appropriately
2382 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002383 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07002384 "Last IBSS Peer Departed!!!" );
2385 }
2386
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 // Find next active staId, to have a valid sta trigger for TL.
2388 if (fSuccess == TRUE)
2389 {
2390 if (del_idx == 0)
2391 {
2392 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
2393 {
2394 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
2395 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
2396 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
2397
2398 pHddStaCtx->conn_info.staId[valid_idx] = 0;
2399 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
2400 }
2401 }
2402 }
2403 return( fSuccess );
2404}
2405
2406/**============================================================================
2407 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002408 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07002409 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002410
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 ===========================================================================*/
2412static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
2413{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002414 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05302415 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2416 "%s: IBSS Connect Indication from SME!!! "
2417 "Set HDD connState to eConnectionState_IbssConnected",
2418 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
2420 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
2421
2422 // Save the connection info from CSR...
2423 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
2424
2425 // Send the bssid address to the wext.
2426 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002427 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002428 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2429 if (NULL == bss)
2430 {
2431 hddLog(VOS_TRACE_LEVEL_ERROR,
2432 "%s: %s: unable to create IBSS entry",
2433 __func__, pAdapter->dev->name);
2434 return eHAL_STATUS_FAILURE;
2435 }
Yue Maf49ba872013-08-19 12:04:25 -07002436 cfg80211_put_bss(
2437#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2438 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
2439#endif
2440 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07002441
2442 return( eHAL_STATUS_SUCCESS );
2443}
Mukul Sharmad2589a52014-04-23 21:06:25 +05302444
2445/**============================================================================
2446 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002448
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002450static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2451 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 eCsrRoamResult roamResult )
2453{
2454 eCsrEncryptionType connectedCipherAlgo;
2455 v_BOOL_t fConnected = FALSE;
2456 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2457 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302458 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302460 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002462
2463 if (NULL == pRoamInfo)
2464 {
2465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2466 return eHAL_STATUS_FAILURE;
2467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002468 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002469 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 // not require upper layer authentication) we can put TL directly into 'authenticated'
2471 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2473 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2474 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002475
Jeff Johnson295189b2012-06-20 16:38:30 -07002476 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2477 if( fConnected )
2478 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002479 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2480 {
2481 v_U8_t staId;
2482
2483 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2484
2485 if ( 0 == memcmp( pRoamInfo->peerMac,
2486 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2487 {
2488 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2489 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05302490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2491 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002492 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2493 }
2494 else
2495 {
2496 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2497 (v_MACADDR_t*)pRoamInfo->peerMac,
2498 &staId);
2499 if ( VOS_STATUS_SUCCESS == vosStatus )
2500 {
2501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2502 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2503 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2504 staId);
2505 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2506 }
2507 }
2508 }
2509 else
2510 {
Bhargav Shaha805ef22015-07-29 17:31:38 +05302511 WLANTL_GetSTAState(pHddCtx->pvosContext,
2512 pHddStaCtx->conn_info.staId[0],
2513 &prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302514 // TODO: Considering getting a state machine in HDD later.
2515 // This routine is invoked twice. 1)set PTK 2)set GTK.
2516 // The folloing if statement will be TRUE when setting GTK.
2517 // At this time we don't handle the state in detail.
2518 // Related CR: 174048 - TL not in authenticated state
2519 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2520 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2521 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302522
2523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2524 "for StaId=%d. Changing TL state to AUTHENTICATED from"
2525 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302526
2527 // Connections that do not need Upper layer authentication,
2528 // transition TL to 'Authenticated' state after the keys are set.
2529 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2530 pHddStaCtx->conn_info.staId[ 0 ],
2531 WLANTL_STA_AUTHENTICATED );
2532
2533 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302534
2535 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2536 hdd_postTLPacketPendingInd(pAdapter,
2537 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05302538 //Need to call offload because when roaming happen at that time fwr
2539 //clean offload info as part of the DelBss
2540 // No need to configure offload if host was not suspended
2541 spin_lock(&pHddCtx->filter_lock);
2542 if(pHddCtx->hdd_wlan_suspended)
2543 {
2544 spin_unlock(&pHddCtx->filter_lock);
2545 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2546 }
2547 else
2548 {
2549 spin_unlock(&pHddCtx->filter_lock);
2550 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302551 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2552 {
2553 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2554 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302555 }
2556 else
2557 {
2558 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2559 pHddStaCtx->conn_info.staId[ 0 ]);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302560
2561 /* In case of OSEN move TL to 'Authenticated' after PTK is set */
2562 if (pWextState->roamProfile.bOSENAssociation == VOS_TRUE)
2563 {
2564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "PTK set"
2565 " for StaId=%d. Due to OSEN, Changing TL state to"
2566 "AUTHENTICATED from state:%d",
2567 pHddStaCtx->conn_info.staId[0], prevTLState);
2568
2569 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2570 pHddStaCtx->conn_info.staId[ 0 ],
2571 WLANTL_STA_AUTHENTICATED );
2572
2573 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
2574
2575 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2576 hdd_postTLPacketPendingInd(pAdapter,
2577 pHddStaCtx->conn_info.staId[0]);
2578 }
2579
2580
2581
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302582 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2583 {
2584 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2585 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302586 }
2587
2588 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302591 else
2592 {
2593 // possible disassoc after issuing set key and waiting set key complete
2594 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2595 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002596
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 EXIT();
2598 return( eHAL_STATUS_SUCCESS );
2599}
2600/**============================================================================
2601 *
2602 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2603 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002604static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002606{
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2608
2609 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2610 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2611 {
2612 struct iw_michaelmicfailure msg;
2613 union iwreq_data wreq;
2614 memset(&msg, '\0', sizeof(msg));
2615 msg.src_addr.sa_family = ARPHRD_ETHER;
2616 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002617 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2618 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002619
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2621 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002622 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 msg.flags = IW_MICFAILURE_PAIRWISE;
2624 memset(&wreq, 0, sizeof(wreq));
2625 wreq.data.length = sizeof(msg);
2626 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002628 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2630 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2631 NL80211_KEYTYPE_GROUP :
2632 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002633 pRoamInfo->u.pMICFailureInfo->keyId,
2634 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002635 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002636
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002638
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 return( eHAL_STATUS_SUCCESS );
2640}
2641
2642/**============================================================================
2643 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002644 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002646
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002648static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2649 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 eCsrRoamResult roamResult )
2651{
2652 VOS_STATUS vosStatus;
2653
2654 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2655 switch( roamResult )
2656 {
2657 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2658 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002659 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05302660 struct station_info *staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002661
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302662 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2663 "IBSS New Peer indication from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002664 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2665 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002667
Jeff Johnson295189b2012-06-20 16:38:30 -07002668 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2669
Shailender Karmuchia734f332013-04-19 14:02:48 -07002670 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2671 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2672 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2673
2674 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05302675 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002676 pRoamInfo,
2677 pRoamInfo->staId,
2678 (v_MACADDR_t *)pRoamInfo->peerMac,
2679 pRoamInfo->pBssDesc );
2680 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2681 {
2682 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002683 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 vosStatus, vosStatus );
2685 }
Abhishek Singhdecf1b62016-02-09 11:53:58 +05302686 if (!roamSaveIbssStation(pAdapter,
2687 pRoamInfo->staId,
2688 (v_MACADDR_t *)pRoamInfo->peerMac))
2689 {
2690 hddLog(LOGW, FL("Not Able to add sta in sta hash"));
2691 break;
2692 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002693 pHddStaCtx->ibss_sta_generation++;
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05302694
2695 staInfo = vos_mem_malloc(sizeof(*staInfo));
2696 if (staInfo == NULL) {
2697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2698 "memory allocation for station_info failed");
2699 return eHAL_STATUS_FAILED_ALLOC;
2700 }
2701
2702 memset(staInfo, 0, sizeof(*staInfo));
2703 staInfo->filled = 0;
2704 staInfo->generation = pHddStaCtx->ibss_sta_generation;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002705
2706 cfg80211_new_sta(pAdapter->dev,
2707 (const u8 *)pRoamInfo->peerMac,
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05302708 staInfo, GFP_KERNEL);
2709 vos_mem_free(staInfo);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002710
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002711 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2712 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2713 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2714 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2715 {
2716 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302717
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002718 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2719 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2720
2721 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002722 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002723 pHddStaCtx->ibss_enc_key.encType);
2724
2725 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2726 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2727
2728 if ( VOS_STATUS_SUCCESS != vosStatus )
2729 {
2730 hddLog(VOS_TRACE_LEVEL_ERROR,
2731 "%s: sme_RoamSetKey failed, returned %d",
2732 __func__, vosStatus);
2733 return VOS_STATUS_E_FAILURE;
2734 }
2735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302737 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002738 netif_tx_start_all_queues(pAdapter->dev);
2739 break;
2740 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002741
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2743 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002744
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002746
Jeff Johnson295189b2012-06-20 16:38:30 -07002747 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002748 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002749 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2750 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002751 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002752
Ravi Joshicc57ed42013-10-12 16:31:25 -07002753 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 {
2755 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2756 "IBSS peer departed by cannot find peer in our registration table with TL" );
2757 }
2758
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302759 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2760 "IBSS Peer Departed from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002761 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2762 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2763 pRoamInfo->staId );
2764
Katya Nigam47528772015-02-11 12:24:49 +05302765 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002766
2767 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002768 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002769
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002770 cfg80211_del_sta(pAdapter->dev,
2771 (const u8 *)&pRoamInfo->peerMac,
2772 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002773 break;
2774 }
2775 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2776 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002777 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2778 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002779 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302780 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 netif_tx_disable(pAdapter->dev);
2782 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302783 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2784 "%s: Set HDD connState to eConnectionState_NotConnected",
2785 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002787
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 // Send the bssid address to the wext.
2789 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2790 // clean up data path
2791 hdd_disconnect_tx_rx(pAdapter);
2792 break;
2793 }
2794 default:
2795 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002796
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002798
Jeff Johnson295189b2012-06-20 16:38:30 -07002799 return( eHAL_STATUS_SUCCESS );
2800}
2801
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002802#ifdef FEATURE_WLAN_TDLS
2803/**============================================================================
2804 *
2805 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2806 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2807 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002808
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002809 ===========================================================================*/
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05302810VOS_STATUS hdd_roamRegisterTDLSSTA(hdd_adapter_t *pAdapter,
2811#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
2812 const tANI_U8 *peerMac,
2813#else
2814 tANI_U8 *peerMac,
2815#endif
2816 tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002817{
2818 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002819 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002820 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2821 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002822 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2823 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002824 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2825 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002826
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002827 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2828 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002829 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002830 "%s not connected. ignored", __func__);
2831 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002832 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002833
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002834 /*
2835 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2836 * be peer MAC, here we are wokrking on direct Link
2837 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002838 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002839
2840 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002841
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002842 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002843 sizeof(tSirMacAddr) );
2844
2845 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2846 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2847
2848 /* set the QoS field appropriately ..*/
2849 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2850 : (staDesc.ucQosEnabled = 0) ;
2851
2852 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002853 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002854
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002855 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002856
2857 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002858 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002859
Shailender Karmuchia734f332013-04-19 14:02:48 -07002860 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002861 * UMA is ready we inform TL to do frame translation.
2862 */
2863 staDesc.ucSwFrameTXXlation = 1;
2864 staDesc.ucSwFrameRXXlation = 1;
2865 staDesc.ucAddRmvLLC = 1;
2866
2867 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002868 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002869
2870 /* tdls Direct Link do not need bcastSig */
2871 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002872
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002873#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2874 if(staDesc.ucProtectedFrame)
2875 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2876 else
2877 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2878#endif
2879
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302880 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002881
Shailender Karmuchia734f332013-04-19 14:02:48 -07002882 /* Register the Station with TL... */
2883 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2884 hdd_rx_packet_cbk,
2885 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002886 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002887
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002888 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2889 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002890 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002891 "%s: WLANTL_RegisterSTAClient() failed to register. "
2892 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002893 return vosStatus;
2894 }
2895
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002896 if ( cfg_param->dynSplitscan &&
2897 ( VOS_TIMER_STATE_RUNNING !=
2898 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2899 {
2900 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2901 cfg_param->trafficMntrTmrForSplitScan);
2902 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002903 return( vosStatus );
2904}
2905
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05302906VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002907{
2908 VOS_STATUS vosStatus;
2909 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2910 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2911 {
2912 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2913 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002914 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002915 __func__, staId, vosStatus, vosStatus );
2916 }
2917 return( vosStatus );
2918}
2919
2920
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002921/*
2922 * HDD interface between SME and TL to ensure TDLS client registration with
2923 * TL in case of new TDLS client is added and deregistration at the time
2924 * TDLS client is deleted.
2925 */
2926
Shailender Karmuchia734f332013-04-19 14:02:48 -07002927eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2928 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002929 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002930 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002931 eCsrRoamResult roamResult)
2932{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002933 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002934 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002935 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002936
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002938 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2939 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2940 "ADD_TDLS_PEER" :
2941 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2942 "DEL_TDLS_PEER" :
2943 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2944 "DEL_TDLS_PEER_IND" :
2945 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2946 "DEL_ALL_TDLS_PEER_IND" :
2947 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2948 "UPDATE_TDLS_PEER" :
2949 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05302950 "LINK_ESTABLISH_REQ_RSP" :
2951 roamResult == eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP ?
2952 "CHANNEL_SWITCH_REQ_RSP" : "UNKNOWN",
Arif Hussain24bafea2013-11-15 15:10:03 -08002953 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002954 switch( roamResult )
2955 {
2956 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2957 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002958 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2959 {
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05302960 hddTdlsPeer_t *curr_peer;
2961
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002963 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05302964 wlan_hdd_tdls_check_bmps(pAdapter);
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05302965
2966 mutex_lock(&pHddCtx->tdls_lock);
2967 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
2968 pRoamInfo->peerMac, FALSE);
2969 if (NULL != curr_peer)
2970 curr_peer->link_status = eTDLS_LINK_TEARING;
2971 else
2972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2973 "%s %d curr_peer is Null", __func__,__LINE__);
2974 mutex_unlock(&pHddCtx->tdls_lock);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002975 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002976 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002977 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002978
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002979 /* check if there is available index for this new TDLS STA */
2980 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2981 {
2982 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2983 {
2984 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2985 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2986
2987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002988 ("TDLS: STA IDX at %d is %d "
2989 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002990 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002991 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002992
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002993 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002994 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2995 status = eHAL_STATUS_SUCCESS ;
2996 break ;
2997 }
2998 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002999 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003000 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003001 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003002 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3003 "wlan_hdd_tdls_set_sta_id() failed");
3004 return VOS_FALSE;
3005 }
3006
3007 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303008 /* store the ucast signature , if required for further reference. */
3009
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003010 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303011 /* start TDLS client registration with TL */
3012 status = hdd_roamRegisterTDLSSTA( pAdapter,
3013 pRoamInfo->peerMac,
3014 pRoamInfo->staId,
3015 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303016 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003017 }
3018 else
3019 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003020 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07003022 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003023 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003024 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003025 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003026 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003027 break ;
3028 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003029 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3030 {
3031 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3032 {
3033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3034 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3035 }
3036 /* store the ucast signature which will be used later when
3037 * registering to TL
3038 */
3039 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3040 complete(&pAdapter->tdls_add_station_comp);
3041 break;
3042 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303043 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3044 {
3045 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3046 {
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303047 hddTdlsPeer_t *curr_peer;
3048
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3050 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303051
3052 mutex_lock(&pHddCtx->tdls_lock);
3053 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3054 pRoamInfo->peerMac, FALSE);
3055 if (curr_peer)
3056 curr_peer->link_status = eTDLS_LINK_TEARING;
3057 else
3058 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3059 "%s %d curr_peer is Null",__func__,__LINE__);
3060 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303061 }
3062 complete(&pAdapter->tdls_link_establish_req_comp);
3063 break;
3064 }
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303065 case eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP:
3066 {
3067 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3069 "%s: Channel switch request failed. %d", __func__,
3070 pRoamInfo->statusCode);
3071 else
3072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3073 "%s: Channel switch request Success", __func__);
3074 break;
3075 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003076 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003077 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003078 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003079 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003080 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003081 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3082 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003083 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003085 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3086
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303087 mutex_lock(&pHddCtx->tdls_lock);
3088 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3089 pRoamInfo->peerMac, FALSE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303090 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003091 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3093 " Current status for peer" MAC_ADDRESS_STR "is %d",
3094 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303095 if (TDLS_IS_CONNECTED(curr_peer) ||
3096 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303097 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303098 mutex_unlock(&pHddCtx->tdls_lock);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303099 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3100 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303101 else
3102 mutex_unlock(&pHddCtx->tdls_lock);
3103
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303104 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003105 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303106 else
3107 mutex_unlock(&pHddCtx->tdls_lock);
3108
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303109 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003110 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303111 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003112
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003113 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3114 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3115 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003116 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003117 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003118 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003119 break ;
3120 }
3121 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003122 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003123 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003124 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003125 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3126 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003127 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003128 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3129 "%s: Sending teardown to supplicant with reason code %u",
3130 __func__, pRoamInfo->reasonCode);
3131
3132#ifdef CONFIG_TDLS_IMPLICIT
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303133 mutex_lock(&pHddCtx->tdls_lock);
3134 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac,
3135 FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003136 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Abhishek Singh96568922016-01-05 15:28:12 +05303137 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3138 curr_peer->peerMac);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303139 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003140#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003141 status = eHAL_STATUS_SUCCESS ;
3142 break ;
3143 }
3144 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3145 {
3146 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003147 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003148 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003149 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3150 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003151 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003153 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003154 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003155 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303156
3157 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003158 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303159 mutex_unlock(&pHddCtx->tdls_lock);
3160
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003161 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3162 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003163
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003164 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003165 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003166 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3167 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003168
3169 status = eHAL_STATUS_SUCCESS ;
3170 }
3171 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303172 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003173 break ;
3174 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003175 default:
3176 {
3177 break ;
3178 }
3179 }
3180
3181 return status ;
3182}
3183#endif
3184
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05303185void iw_full_power_cbfn (void *pContext, eHalStatus status)
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003186{
3187 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3188 hdd_context_t *pHddCtx = NULL;
3189 int ret;
3190
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303191 ENTER();
3192
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003193 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3194 {
3195 hddLog(VOS_TRACE_LEVEL_ERROR,
3196 "%s: Bad param, pAdapter [%p]",
3197 __func__, pAdapter);
3198 return;
3199 }
3200
3201 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3202 ret = wlan_hdd_validate_context(pHddCtx);
3203 if (0 != ret)
3204 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003205 return;
3206 }
3207
3208 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3209 {
3210 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3211 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303212
3213 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003214}
3215
Shailender Karmuchia734f332013-04-19 14:02:48 -07003216eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3218{
3219 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
3220 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303221 hdd_wext_state_t *pWextState = NULL;
3222 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003223 VOS_STATUS status = VOS_STATUS_SUCCESS;
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05303224 struct cfg80211_bss *bss_status;
Amar Singhal49fdfd52013-08-13 13:25:12 -07003225 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003226
3227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003228 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003229 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003230
3231 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303232 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003233 {
3234 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303235 "invalid adapter or adapter has invalid magic");
3236 return eHAL_STATUS_FAILURE;
3237 }
3238
3239 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3240 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3241
3242 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3243 {
3244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3245 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003246 return eHAL_STATUS_FAILURE;
3247 }
3248
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05303249 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
3250 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 switch( roamStatus )
3252 {
3253 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki41d95e22015-08-28 12:51:32 +05303254 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
3255 complete(&pAdapter->session_open_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003257
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003258#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
3259 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003260 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07003261 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07003262 * interface down */
3263 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303264 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
3265 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05303266 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003267 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3268 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
3269 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3271 }
3272 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05303273 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 break;
3275
3276 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003277 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07003279 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 // eCSR_ROAM_SHOULD_ROAM will be received.
3281 // Where in we will not mark the link down
3282 // Also we want to stop tx at this point when we will be
3283 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003284 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003285 {
3286 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303287 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303289 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3290 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3291 {
3292 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
3293 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003294 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303295 * Deregister this STA with TL, but do not flush the packets
3296 * for this STA from wmm_tx_queue. Since there is no valid STA
3297 * for these packets they will not be transmitted. Eventually
3298 * after the reassociation is successful, these packets will be
3299 * transmitted after registering STA with TL again. This ensures
3300 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003301 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303302 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
3303 pHddStaCtx->conn_info.staId[0]);
3304 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003305 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3307 FL("WLANTL_ClearSTAClient failed for staID %d."
3308 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
3309 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003310 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003311 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003312 }
3313 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003314 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003315 break;
3316#endif
3317
3318 case eCSR_ROAM_SHOULD_ROAM:
3319 // Dont need to do anything
3320 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 struct net_device *dev = pAdapter->dev;
3322 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3323 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303324 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003326#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003327 if (pHddStaCtx->ft_carrier_on == FALSE)
3328 {
3329#endif
3330 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003331#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 }
3333#endif
3334
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003335#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 //We should clear all sta register with TL, for now, only one.
3337 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
3338 if ( !VOS_IS_STATUS_SUCCESS(status ) )
3339 {
3340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3341 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
3342 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003343 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003345#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 }
3347 break;
3348 case eCSR_ROAM_LOSTLINK:
3349 case eCSR_ROAM_DISASSOCIATED:
3350 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3352 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05303353 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003354 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3355 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07003356 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3357 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303358 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07003359 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08003360
3361 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
3362 pHddCtx->configuredMcastBcastFilter =
3363 pHddCtx->sus_res_mcastbcast_filter;
3364 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
3365 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303366
Amar Singhald53568e2013-09-26 11:03:45 -07003367 hddLog(VOS_TRACE_LEVEL_INFO,
3368 "offload: disassociation happening, restoring configuredMcastBcastFilter");
3369 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
3370 pHddCtx->configuredMcastBcastFilter);
3371 hddLog(VOS_TRACE_LEVEL_INFO,
3372 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3374 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003375#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303376 /* Call to clear any MC Addr List filter applied after
3377 * successful connection.
3378 */
3379 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003380#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 }
3382 break;
3383 case eCSR_ROAM_IBSS_LEAVE:
3384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3385 "****eCSR_ROAM_IBSS_LEAVE****");
3386 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3387 break;
3388 case eCSR_ROAM_ASSOCIATION_COMPLETION:
3389 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3390 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303391 // To Do - address probable memory leak with WEP encryption upon successful association
3392 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07003393 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303394 //Clear saved connection information in HDD
3395 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303397 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003398
3399 break;
3400 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003401 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 pRoamInfo, roamId, roamStatus, roamResult );
3403 break;
3404 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07003405 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
3406 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003407 break;
3408
3409 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
3410 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003411 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003412
3413 case eCSR_ROAM_MIC_ERROR_IND:
3414 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3415 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05303416 case eCSR_ROAM_LOST_LINK_PARAMS_IND:
3417 {
3418 /*
3419 * The RSSI will be subtracted from 100 as FW is sending the RSSI by
3420 * adding the 100 value.
3421 */
3422 pAdapter->rssi_on_disconnect = pRoamInfo->u.pLostLinkParams->rssi - 100;
3423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3424 "%s : Rssi on Disconnect : %d",
3425 __func__, pAdapter->rssi_on_disconnect);
3426 break;
3427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003429 {
3430 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3431
3432 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003433 (TRUE == pHddCtx->hdd_wlan_suspended) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05303434 ((eCSR_ROAM_RESULT_NONE == roamResult)||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05303435 (pRoamInfo && pRoamInfo->is11rAssoc)))
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003436 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003437 /* Send DTIM period to the FW; only if the wlan is already
3438 in suspend. This is the case with roaming (reassoc),
3439 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
3440 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
3441 before the ENTER_BMPS_REQ ensures Listen Interval is
3442 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003443 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003444
3445 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003446 if due to unexpected scenario, if we are in BMPS,
3447 then trigger Exit and Enter BMPS to take DTIM period
3448 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003449 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
3450 {
3451 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
3452
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003453 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3454 iw_full_power_cbfn, pAdapter,
3455 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003456 }
3457 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303458
3459 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303460 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
3461 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05303462 ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05303463 (pRoamInfo && pRoamInfo->is11rAssoc)))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303464 {
3465 hddLog( LOG1, FL("Device in full power."
3466 "Stop and start traffic timer for roaming"));
3467 pmcStopTrafficTimer(pHddCtx->hHal);
3468 if (pmcStartTrafficTimer(pHddCtx->hHal,
3469 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
3470 {
3471 hddLog(LOGP, FL("Cannot start traffic timer"));
3472 }
3473 }
3474
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003475 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05303476 if ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05303477 (pRoamInfo && pRoamInfo->is11rAssoc))
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303478 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003480 break;
3481#ifdef WLAN_FEATURE_VOWIFI_11R
3482 case eCSR_ROAM_FT_RESPONSE:
3483 hdd_SendFTEvent(pAdapter);
3484 break;
3485#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07003486#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003487 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003488 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07003489 {
3490 /* Notify the supplicant of a new candidate */
3491 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
3492 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003493 break;
3494#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003495
Yue Maef608272013-04-08 23:09:17 -07003496#ifdef FEATURE_WLAN_LFR_METRICS
3497 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
3498 /* This event is to notify pre-auth initiation */
3499 if (VOS_STATUS_SUCCESS !=
3500 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
3501 {
3502 halStatus = eHAL_STATUS_FAILURE;
3503 }
3504 break;
3505 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
3506 /* This event will notify pre-auth completion in case of success */
3507 if (VOS_STATUS_SUCCESS !=
3508 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3509 pRoamInfo, 1))
3510 {
3511 halStatus = eHAL_STATUS_FAILURE;
3512 }
3513 break;
3514 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
3515 /* This event will notify pre-auth completion in case of failure. */
3516 if (VOS_STATUS_SUCCESS !=
3517 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3518 pRoamInfo, 0))
3519 {
3520 halStatus = eHAL_STATUS_FAILURE;
3521 }
3522 break;
3523 case eCSR_ROAM_HANDOVER_SUCCESS:
3524 /* This event is to notify handover success.
3525 It will be only invoked on success */
3526 if (VOS_STATUS_SUCCESS !=
3527 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
3528 {
3529 halStatus = eHAL_STATUS_FAILURE;
3530 }
3531 break;
3532#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003533 case eCSR_ROAM_REMAIN_CHAN_READY:
3534 hdd_remainChanReadyHandler( pAdapter );
3535 break;
3536 case eCSR_ROAM_SEND_ACTION_CNF:
3537 hdd_sendActionCnf( pAdapter,
3538 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
3539 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003540#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08003541 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003542 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08003543 roamId, roamStatus, roamResult );
3544 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003545 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
3546 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
3547 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003548#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003549#ifdef WLAN_FEATURE_11W
3550 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
3551 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
3552 pRoamInfo->pbFrames,
3553 pRoamInfo->frameType);
3554 break;
3555#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003556#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003557 case eCSR_ROAM_TSM_IE_IND:
3558 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
3559 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
3560 break;
3561
3562 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
3563 {
3564 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
3565 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
3566 {
3567 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
3568 }
3569 break;
3570 }
3571
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003572 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003573 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003574 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003575 break;
3576 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003577
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003578 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003579 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003580 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003581 break;
3582 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003583#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05303584 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
3585 {
3586 pAdapter->maxRateFlags = roamResult;
3587 break;
3588 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05303589 case eCSR_ROAM_UPDATE_SCAN_RESULT:
3590 if (pRoamInfo && pRoamInfo->pBssDesc) {
3591 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
3592 pRoamInfo->pBssDesc);
3593 if (bss_status)
3594 cfg80211_put_bss(
3595#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
3596 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
3597#endif
3598 bss_status);
3599 else
3600 hddLog(LOG1, FL("UPDATE_SCAN_RESULT returned NULL"));
3601 }
3602 break;
Girish Gowlia95daca2015-02-04 20:31:31 +05303603 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 break;
3605 }
3606 return( halStatus );
3607}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003608eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003609{
3610 eCsrAuthType auth_type;
3611 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003612 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003613 {
3614 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003615 } else
3616 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003617 {
3618 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003619 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003620#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003621 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 {
3623 // Check for 11r FT Authentication with PSK
3624 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003625 } else
3626 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003627 {
3628 // Check for 11R FT Authentication with 802.1X
3629 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003630 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003631#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003632#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003633 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 {
3635 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3636 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003637#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003638#ifdef WLAN_FEATURE_11W
3639 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3640 {
3641 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3642 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303643 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
3644 {
3645 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3646 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003647#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003648 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3650 }
3651 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003652}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003653
Shailender Karmuchia734f332013-04-19 14:02:48 -07003654eCsrAuthType
3655hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003656{
3657 eCsrAuthType auth_type;
3658 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003659 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003660 {
3661 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003662 } else
3663 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 {
3665 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003666 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003667#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003668 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 {
3670 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003671 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003672#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003673 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3675 }
3676 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3677 return auth_type;
3678}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003679
Shailender Karmuchia734f332013-04-19 14:02:48 -07003680eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003681hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003682{
3683 eCsrEncryptionType cipher_type;
3684 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003685 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 {
3687 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003688 }
3689 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003690 {
3691 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003692 }
3693 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 {
3695 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003696 }
3697 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003698 {
3699 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003700 }
3701 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3702 {
3703 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3704 }
3705 else
3706 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3708 }
3709 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3710 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003711}
Jeff Johnson295189b2012-06-20 16:38:30 -07003712/* To find if the MAC address is NULL */
3713static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3714{
3715 int i;
3716 for (i = 0; i < length; i++)
3717 {
3718 if (0x00 != (macAddr[i]))
3719 {
3720 return FALSE;
3721 }
3722 }
3723 return TRUE;
3724} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003725
Shailender Karmuchia734f332013-04-19 14:02:48 -07003726eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003727hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003728{
3729 eCsrEncryptionType cipher_type;
3730 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003731 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 {
3733 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003734 } else
3735 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 {
3737 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003738 } else
3739 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 {
3741 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003742 } else
3743 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 {
3745 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003746 } else
3747 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003749 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3750 } else
3751 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3753 }
3754 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3755 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003756}
Jeff Johnson295189b2012-06-20 16:38:30 -07003757
Shailender Karmuchia734f332013-04-19 14:02:48 -07003758static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3759 struct ether_addr *pBssid,
3760 eCsrEncryptionType *pEncryptType,
3761 eCsrEncryptionType *mcEncryptType,
3762 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003763#ifdef WLAN_FEATURE_11W
3764 u_int8_t *pMfpRequired,
3765 u_int8_t *pMfpCapable,
3766#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003767 u_int16_t gen_ie_len,
3768 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003769{
3770 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003771 eHalStatus result;
3772 tDot11fIERSN dot11RSNIE;
3773 tDot11fIEWPA dot11WPAIE;
3774 tANI_U32 i;
3775 tANI_U8 *pRsnIe;
3776 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003778 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003779
3780 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3781 flag to 0 */
3782 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3783 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3784
Jeff Johnson295189b2012-06-20 16:38:30 -07003785 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003786 if ( gen_ie[0] == DOT11F_EID_RSN)
3787 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003789 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3791 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303792 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3793 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 return -EINVAL;
3795 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003796 // Skip past the EID byte and length byte
3797 pRsnIe = gen_ie + 2;
3798 RSNIeLen = gen_ie_len - 2;
3799 // Unpack the RSN IE
3800 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3801 pRsnIe,
3802 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003804 // Copy out the encryption and authentication types
3805 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003806 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003807 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003808 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003809 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 but probably I suspect we can do something different*/
3811 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003812 // Just translate the FIRST one
3813 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3814 //dot11RSNIE.pwise_cipher_suite_count
3815 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3816 //dot11RSNIE.gp_cipher_suite_count
3817 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003818#ifdef WLAN_FEATURE_11W
3819 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3820 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3821#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003822 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003823 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003825 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003826 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303827 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 break;
3829 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003830 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303832 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003833 break;
3834 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003835 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 // For right now, I assume setASSOCIATE() has passed in the bssid.
3837 vos_mem_copy(PMKIDCache[i].BSSID,
3838 pBssid, ETHER_ADDR_LEN);
3839 vos_mem_copy(PMKIDCache[i].PMKID,
3840 dot11RSNIE.pmkid[i],
3841 CSR_RSN_PMKID_SIZE);
3842 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003843
3844 if (updatePMKCache)
3845 {
3846 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003847 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003848 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003849 // Finally set the PMKSA ID Cache in CSR
3850 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3851 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303852 dot11RSNIE.pmkid_count,
3853 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07003854 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 }
3856 else if (gen_ie[0] == DOT11F_EID_WPA)
3857 {
3858 // Validity checks
3859 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3860 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3861 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303862 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3863 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 return -EINVAL;
3865 }
3866 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003867 pRsnIe = gen_ie + 2 + 4;
3868 RSNIeLen = gen_ie_len - (2 + 4);
3869 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003870 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3871 pRsnIe,
3872 RSNIeLen,
3873 &dot11WPAIE);
3874 // Copy out the encryption and authentication types
3875 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003876 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003878 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 //dot11WPAIE.auth_suite_count
3880 // Just translate the FIRST one
3881 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3882 //dot11WPAIE.unicast_cipher_count
3883 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3884 //dot11WPAIE.unicast_cipher_count
3885 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3886 }
3887 else
3888 {
3889 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003890 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 }
3892 return 0;
3893}
3894int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3895{
3896 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3897 v_U32_t status = 0;
3898 eCsrEncryptionType RSNEncryptType;
3899 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003900#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303901 u_int8_t RSNMfpRequired = 0;
3902 u_int8_t RSNMfpCapable = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07003903#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 struct ether_addr bSsid; // MAC address of assoc peer
3905 // MAC address of assoc peer
3906 // But, this routine is only called when we are NOT associated.
3907 vos_mem_copy(bSsid.ether_addr_octet,
3908 pWextState->roamProfile.BSSIDs.bssid,
3909 sizeof(bSsid.ether_addr_octet));
3910 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3911 {
3912 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003913 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 else
3915 {
3916 return 0;
3917 }
3918 // The actual processing may eventually be more extensive than this.
3919 // Right now, just consume any PMKIDs that are sent in by the app.
3920 status = hdd_ProcessGENIE(pAdapter,
3921 &bSsid, // MAC address of assoc peer
3922 &RSNEncryptType,
3923 &mcRSNEncryptType,
3924 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003925#ifdef WLAN_FEATURE_11W
3926 &RSNMfpRequired,
3927 &RSNMfpCapable,
3928#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 pWextState->WPARSNIE[1]+2,
3930 pWextState->WPARSNIE);
3931 if (status == 0)
3932 {
3933 // Now copy over all the security attributes you have parsed out
3934 pWextState->roamProfile.EncryptionType.numEntries = 1;
3935 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003936
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3938 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003939
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003940 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3941 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3942 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3943 {
3944 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3945 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3946 either AES/TKIP based on group cipher configuration
3947 mentioned in the wpa_supplicant.conf.*/
3948
3949 /*Set the unicast cipher same as multicast cipher*/
3950 pWextState->roamProfile.EncryptionType.encryptionType[0]
3951 = mcRSNEncryptType;
3952 }
3953
Chet Lanctot186b5732013-03-18 10:26:30 -07003954#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303955 hddLog( LOG1, FL("RSNMfpRequired = %d, RSNMfpCapable = %d"),
3956 RSNMfpRequired, RSNMfpCapable);
Chet Lanctot186b5732013-03-18 10:26:30 -07003957 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3958 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3959#endif
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303960 hddLog( LOG1,
3961 FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
3962 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003963 }
3964 return 0;
3965}
3966int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3967{
3968 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3969 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3970 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3971 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003972
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003974 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003975
Jeff Johnson295189b2012-06-20 16:38:30 -07003976 switch( pHddStaCtx->conn_info.authType)
3977 {
3978 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003979#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003980 case eCSR_AUTH_TYPE_CCKM_WPA:
3981 case eCSR_AUTH_TYPE_CCKM_RSN:
3982#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003983 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3984
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003986 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003987 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003988
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003989#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003990 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3991 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3992 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003993 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003994 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3995 } else
3996 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003997 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003998 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003999 } else
4000#endif
4001 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4002 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004003 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
4004 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4006 == IW_AUTH_KEY_MGMT_PSK) {
4007 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004008 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004011 }
4012 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004013#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004014 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
4015 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4016 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004017 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004018 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004020 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004021 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004022 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004023 } else
4024#endif
4025
4026#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004027 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
4028 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004030 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07004031 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004032 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4034 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004035 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07004036 } else
4037#endif
4038
Chet Lanctot186b5732013-03-18 10:26:30 -07004039#ifdef WLAN_FEATURE_11W
4040 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
4041 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4042 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304043 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
4044 pRoamProfile->AuthType.authType[0] =
4045 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4046 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004047#endif
4048
Shailender Karmuchia734f332013-04-19 14:02:48 -07004049 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004051 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
4052 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4054 == IW_AUTH_KEY_MGMT_PSK) {
4055 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004056 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004060 break;
4061
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004063
4064 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 break;
4066 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004067
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004068#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08004069 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004070#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
4072 break;
4073 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004074
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004076 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004077
Jeff Johnson295189b2012-06-20 16:38:30 -07004078 EXIT();
4079 return 0;
4080}
4081
4082/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004083
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304084 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07004086 to the CSR roam profile.
4087
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 \param - dev - Pointer to the net device.
4089 - info - Pointer to the iw_request_info.
4090 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004091 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004093
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 --------------------------------------------------------------------------*/
4095
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304096int __iw_set_essid(struct net_device *dev,
4097 struct iw_request_info *info,
4098 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004099{
4100 v_U32_t status = 0;
4101 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304102 hdd_adapter_t *pAdapter;
4103 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 v_U32_t roamId;
4105 tCsrRoamProfile *pRoamProfile;
4106 eMib_dot11DesiredBssType connectedBssType;
4107 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304108 tHalHandle hHal;
4109 hdd_station_ctx_t *pHddStaCtx;
4110 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004111
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304113 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4114 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304117 "%s: Adapter is NULL",__func__);
4118 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 }
4120
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304121 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4122 ret = wlan_hdd_validate_context(pHddCtx);
4123 if (0 != ret)
4124 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304125 return ret;
4126 }
4127
4128 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4129 if (NULL == hHal)
4130 {
4131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4132 "%s: Hal Context is NULL",__func__);
4133 return -EINVAL;
4134 }
4135 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4136 if (NULL == pHddStaCtx)
4137 {
4138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4139 "%s: STA Context is NULL",__func__);
4140 return -EINVAL;
4141 }
4142 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4143 if (NULL == pWextState)
4144 {
4145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4146 "%s: pWextState is NULL",__func__);
4147 return -EINVAL;
4148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
4150 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
4151 return -EBUSY;
4152 }
4153 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
4154 return -EINVAL;
4155 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004156 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 {
4158 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
4159 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
4160 {
4161 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004162 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4164 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
4165
4166 if(VOS_STATUS_SUCCESS == vosStatus)
4167 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
4168 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4169 }
4170 }
4171 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004172 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 {
4174 return -EINVAL;
4175 }
4176 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004177 /** when cfg80211 defined, wpa_supplicant wext driver uses
4178 zero-length, null-string ssid for force disconnection.
4179 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 driver MUST return success */
4181 if ( 0 == wrqu->essid.length ) {
4182 return 0;
4183 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004184
4185 status = hdd_wmm_get_uapsd_mask(pAdapter,
4186 &pWextState->roamProfile.uapsd_mask);
4187 if (VOS_STATUS_SUCCESS != status)
4188 {
4189 pWextState->roamProfile.uapsd_mask = 0;
4190 }
4191 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004192
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004194
4195 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
4197 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
4198 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004199
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 //set gen ie
4201 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
4202
4203 //set auth
4204 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
4205 }
4206#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004207 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 if (pAdapter->wapi_info.nWapiMode)
4209 {
4210 switch (pAdapter->wapi_info.wapiAuthMode)
4211 {
4212 case WAPI_AUTH_MODE_PSK:
4213 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004214 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 pRoamProfile->AuthType.numEntries = 1;
4216 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4217 break;
4218 }
4219 case WAPI_AUTH_MODE_CERT:
4220 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004221 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 pRoamProfile->AuthType.numEntries = 1;
4223 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4224 break;
4225 }
4226 } // End of switch
4227 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
4228 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
4229 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004230 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004231 pRoamProfile->EncryptionType.numEntries = 1;
4232 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4233 pRoamProfile->mcEncryptionType.numEntries = 1;
4234 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4235 }
4236 }
4237#endif /* FEATURE_WLAN_WAPI */
4238 /* if previous genIE is not NULL, update AssocIE */
4239 if (0 != pWextState->genIE.length)
4240 {
4241 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
4242 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
4243 pWextState->genIE.length);
4244 pWextState->assocAddIE.length = pWextState->genIE.length;
4245 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
4246 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
4247
4248 /* clear previous genIE after use it */
4249 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
4250 }
4251
4252 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
4253 pWextState->roamProfile.bWPSAssociation = FALSE;
4254
4255 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
4256 pWextState->roamProfile.nAddIEAssocLength))
4257 pWextState->roamProfile.bWPSAssociation = TRUE;
4258
4259
4260 // Disable auto BMPS entry by PMC until DHCP is done
4261 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
4262
Shailender Karmuchia734f332013-04-19 14:02:48 -07004263 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004264 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004265
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004266 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
4267 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004268 hdd_select_cbmode(pAdapter,
4269 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
4270 }
Agarwal Ashish40f9b872015-09-01 16:17:35 +05304271 /*
4272 * Change conn_state to connecting before sme_RoamConnect(),
4273 * because sme_RoamConnect() has a direct path to call
4274 * hdd_smeRoamCallback(), which will change the conn_state
4275 * If direct path, conn_state will be accordingly changed
4276 * to NotConnected or Associated by either
4277 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
4278 * in sme_RoamCallback()
4279 * if sme_RomConnect is to be queued,
4280 * Connecting state will remain until it is completed.
4281 *
4282 * If connection state is not changed,
4283 * connection state will remain in eConnectionState_NotConnected state.
4284 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
4285 * if conn state is eConnectionState_NotConnected.
4286 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
4287 * informed of connect result indication which is an issue.
4288 */
4289 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
4290 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
4291 {
4292 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4293 FL("Set HDD connState to eConnectionState_Connecting"));
4294 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
4295 eConnectionState_Connecting);
4296 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004297 status = sme_RoamConnect( hHal,pAdapter->sessionId,
4298 &(pWextState->roamProfile), &roamId);
Agarwal Ashish40f9b872015-09-01 16:17:35 +05304299
4300 if ((eHAL_STATUS_SUCCESS != status) &&
4301 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
4302 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4303 {
4304 hddLog(VOS_TRACE_LEVEL_ERROR,
4305 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
4306 pAdapter->sessionId, status);
4307 /* change back to NotAssociated */
4308 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
4309 eConnectionState_NotConnected);
4310 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004311 pRoamProfile->ChannelInfo.ChannelList = NULL;
4312 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004313
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004314 EXIT();
4315 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004316}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004317
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304318int iw_set_essid(struct net_device *dev,
4319 struct iw_request_info *info,
4320 union iwreq_data *wrqu, char *extra)
4321{
4322 int ret;
4323
4324 vos_ssr_protect(__func__);
4325 ret = __iw_set_essid(dev, info, wrqu, extra);
4326 vos_ssr_unprotect(__func__);
4327
4328 return ret;
4329}
4330
Jeff Johnson295189b2012-06-20 16:38:30 -07004331/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004332
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304333 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004335
Jeff Johnson295189b2012-06-20 16:38:30 -07004336 \param - dev - Pointer to the net device.
4337 - info - Pointer to the iw_request_info.
4338 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004339 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004341
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304343int __iw_get_essid(struct net_device *dev,
4344 struct iw_request_info *info,
4345 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004346{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304347 hdd_adapter_t *pAdapter;
4348 hdd_context_t *pHddCtx;
4349 hdd_wext_state_t *wextBuf;
4350 hdd_station_ctx_t *pHddStaCtx;
4351 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304352
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 ENTER();
4354
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304355 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4356 if (NULL == pAdapter)
4357 {
4358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4359 "%s: Adapter is NULL",__func__);
4360 return -EINVAL;
4361 }
4362
4363 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4364 ret = wlan_hdd_validate_context(pHddCtx);
4365 if (0 != ret)
4366 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304367 return ret;
4368 }
4369
4370 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4371 if (NULL == pHddStaCtx)
4372 {
4373 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4374 "%s: STA Context is NULL",__func__);
4375 return -EINVAL;
4376 }
4377
4378 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4379 if (NULL == wextBuf)
4380 {
4381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4382 "%s: wextBuf is NULL",__func__);
4383 return -EINVAL;
4384 }
4385
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
4387 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
4388 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
4389 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
4390 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
4391 {
4392 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
4393 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
4394 dwrq->flags = 1;
4395 } else {
4396 memset(extra, 0, dwrq->length);
4397 dwrq->length = 0;
4398 dwrq->flags = 0;
4399 }
4400 EXIT();
4401 return 0;
4402}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304403
4404int iw_get_essid(struct net_device *dev,
4405 struct iw_request_info *info,
4406 struct iw_point *dwrq, char *extra)
4407{
4408 int ret;
4409
4410 vos_ssr_protect(__func__);
4411 ret = __iw_get_essid(dev, info, dwrq, extra);
4412 vos_ssr_unprotect(__func__);
4413
4414 return ret;
4415}
Jeff Johnson295189b2012-06-20 16:38:30 -07004416/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004417
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304418 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004419 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004420
Jeff Johnson295189b2012-06-20 16:38:30 -07004421 \param - dev - Pointer to the net device.
4422 - info - Pointer to the iw_request_info.
4423 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004424 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004426
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304428int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
4429 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004430{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304431 hdd_adapter_t *pAdapter;
4432 hdd_context_t *pHddCtx;
4433 hdd_wext_state_t *pWextState;
4434 hdd_station_ctx_t *pHddStaCtx;
4435 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004436 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304438 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004439
Jeff Johnson295189b2012-06-20 16:38:30 -07004440 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004441
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304442 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4443 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004444 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4446 "%s: Adapter is NULL",__func__);
4447 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004448 }
4449
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304450 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4451 ret = wlan_hdd_validate_context(pHddCtx);
4452 if (0 != ret)
4453 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304454 return ret;
4455 }
4456
4457 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4458 if (NULL == pHddStaCtx)
4459 {
4460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4461 "%s: STA Context is NULL",__func__);
4462 return -EINVAL;
4463 }
4464
4465 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4466 if (NULL == pWextState)
4467 {
4468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4469 "%s: pWextState is NULL",__func__);
4470 return -EINVAL;
4471 }
4472
4473 pRoamProfile = &pWextState->roamProfile;
4474
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 switch(wrqu->param.flags & IW_AUTH_INDEX)
4476 {
4477 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004478
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004480
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004482
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 case IW_AUTH_CIPHER_PAIRWISE:
4484 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004485 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4489 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
4492 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004493 }
4494
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004496
4497 if( (IW_AUTH_KEY_MGMT_802_1X
4498 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
4500 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004501 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 else
4503 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004504 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4505 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004507
4508 if( ( IW_AUTH_KEY_MGMT_802_1X
4509 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4511 /*Dynamic WEP key*/
4512 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4513 else
4514 /*Static WEP key*/
4515 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004516
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 }
4518 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004519
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004521 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 return -EINVAL;
4523 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004524
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 pRoamProfile->EncryptionType.numEntries = 1;
4526 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 break;
4529 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004530 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
4532 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4533 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004534
Jeff Johnson295189b2012-06-20 16:38:30 -07004535 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4536 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
4537 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004538
4539 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
4541 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004542
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004544
4545 if( ( IW_AUTH_KEY_MGMT_802_1X
4546 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
4547 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4548
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004550
4551 else
4552 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004554
4555 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
4556 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004558 if( ( IW_AUTH_KEY_MGMT_802_1X
4559 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4561 {
4562 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4563 }
4564 else
4565 {
4566 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4567 }
4568 }
4569 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004570
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004572 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 return -EINVAL;
4574 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004575
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 pRoamProfile->mcEncryptionType.numEntries = 1;
4577 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
4578 }
4579 break;
4580
4581 case IW_AUTH_80211_AUTH_ALG:
4582 {
4583 /*Save the auth algo here and set auth type to SME Roam profile
4584 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004585 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004587
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
4589 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
4590
4591 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
4592 /*Not supported*/
4593 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4594 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4595 }
4596 break;
4597
4598 case IW_AUTH_KEY_MGMT:
4599 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004600#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004601#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
4602 /*Check for CCKM AKM type */
4603 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004604 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
4605 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004606 /* Set the CCKM bit in authKeyMgmt */
4607 /* Right now, this breaks all ref to authKeyMgmt because our
4608 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 */
4610 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
4611 /*Set the key management to 802.1X*/
4612 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004613 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4615 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
4616 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
4617 /*Save the key management*/
4618 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
4619 //pWextState->authKeyMgmt = wrqu->param.value;
4620 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4621 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4622 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
4623 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
4624 /*Save the key management anyway*/
4625 pWextState->authKeyMgmt = wrqu->param.value;
4626 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
4627 /*Save the key management*/
4628 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
4629 //pWextState->authKeyMgmt = wrqu->param.value;
4630 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4631 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4632 }
4633#else
4634 /*Save the key management*/
4635 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004636#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004637 }
4638 break;
4639
4640 case IW_AUTH_TKIP_COUNTERMEASURES:
4641 {
4642 if(wrqu->param.value) {
4643 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4644 "Counter Measure started %d", wrqu->param.value);
4645 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
4646 }
4647 else {
4648 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4649 "Counter Measure stopped=%d", wrqu->param.value);
4650 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4651 }
4652 }
4653 break;
4654 case IW_AUTH_DROP_UNENCRYPTED:
4655 case IW_AUTH_WPA_ENABLED:
4656 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
4657 case IW_AUTH_ROAMING_CONTROL:
4658 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004659
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004661
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004662 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004663 wrqu->param.flags & IW_AUTH_INDEX);
4664 break;
4665 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004666
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 EXIT();
4668 return 0;
4669}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304670
4671int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
4672 union iwreq_data *wrqu, char *extra)
4673{
4674 int ret;
4675
4676 vos_ssr_protect(__func__);
4677 ret = __iw_set_auth(dev, info, wrqu, extra);
4678 vos_ssr_unprotect(__func__);
4679
4680 return ret;
4681}
4682
Jeff Johnson295189b2012-06-20 16:38:30 -07004683/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004684
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304685 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004686 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004687
Jeff Johnson295189b2012-06-20 16:38:30 -07004688 \param - dev - Pointer to the net device.
4689 - info - Pointer to the iw_request_info.
4690 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004691 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004693
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304695int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4696 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004697{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304698 hdd_adapter_t* pAdapter;
4699 hdd_wext_state_t *pWextState;
4700 tCsrRoamProfile *pRoamProfile;
4701 hdd_context_t *pHddCtx;
4702 int ret = 0;
4703
Jeff Johnson295189b2012-06-20 16:38:30 -07004704 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004705
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304706 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4707 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004708 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4710 "%s: Adapter is NULL",__func__);
4711 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004712 }
4713
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304714 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4715 ret = wlan_hdd_validate_context(pHddCtx);
4716 if (0 != ret)
4717 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304718 return ret;
4719 }
4720
4721 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4722 if (NULL == pWextState)
4723 {
4724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4725 "%s: pWextState is NULL",__func__);
4726 return -EINVAL;
4727 }
4728 pRoamProfile = &pWextState->roamProfile;
4729
Jeff Johnson295189b2012-06-20 16:38:30 -07004730 switch(pRoamProfile->negotiatedAuthType)
4731 {
4732 case eCSR_AUTH_TYPE_WPA_NONE:
4733 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4734 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
4735 break;
4736 case eCSR_AUTH_TYPE_WPA:
4737 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4738 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
4739 break;
4740#ifdef WLAN_FEATURE_VOWIFI_11R
4741 case eCSR_AUTH_TYPE_FT_RSN:
4742#endif
4743 case eCSR_AUTH_TYPE_RSN:
4744 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4745 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
4746 break;
4747 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4748 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4749 break;
4750 case eCSR_AUTH_TYPE_SHARED_KEY:
4751 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
4752 break;
4753 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004754 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004755 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4756 break;
4757 case eCSR_AUTH_TYPE_AUTOSWITCH:
4758 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4759 break;
4760 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304761 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4763 return -EIO;
4764#ifdef WLAN_FEATURE_VOWIFI_11R
4765 case eCSR_AUTH_TYPE_FT_RSN_PSK:
4766#endif
4767 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07004768#ifdef WLAN_FEATURE_11W
4769 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05304770 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07004771#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05304772 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004773 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4774 return -EIO;
4775 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304776 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4778 return -EIO;
4779 }
4780 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
4781 {
4782 switch(pRoamProfile->negotiatedUCEncryptionType)
4783 {
4784 case eCSR_ENCRYPT_TYPE_NONE:
4785 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4786 break;
4787 case eCSR_ENCRYPT_TYPE_WEP40:
4788 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4789 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4790 break;
4791 case eCSR_ENCRYPT_TYPE_TKIP:
4792 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4793 break;
4794 case eCSR_ENCRYPT_TYPE_WEP104:
4795 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4796 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4797 break;
4798 case eCSR_ENCRYPT_TYPE_AES:
4799 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4800 break;
4801 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304802 hddLog(LOG1, "%s called with unknown auth type %d ",
4803 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004804 return -EIO;
4805 }
4806 }
4807
Shailender Karmuchia734f332013-04-19 14:02:48 -07004808 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004809 {
4810 switch(pRoamProfile->negotiatedMCEncryptionType)
4811 {
4812 case eCSR_ENCRYPT_TYPE_NONE:
4813 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4814 break;
4815 case eCSR_ENCRYPT_TYPE_WEP40:
4816 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4817 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4818 break;
4819 case eCSR_ENCRYPT_TYPE_TKIP:
4820 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4821 break;
4822 case eCSR_ENCRYPT_TYPE_WEP104:
4823 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4824 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4825 break;
4826 case eCSR_ENCRYPT_TYPE_AES:
4827 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4828 break;
4829 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304830 hddLog(LOG1, "%s called with unknown auth type %d ",
4831 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004832 return -EIO;
4833 }
4834 }
4835
4836 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004837 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004838 EXIT();
4839 return 0;
4840}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304841
4842int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4843 union iwreq_data *wrqu,char *extra)
4844{
4845 int ret;
4846
4847 vos_ssr_protect(__func__);
4848 ret = __iw_get_auth(dev, info, wrqu, extra);
4849 vos_ssr_unprotect(__func__);
4850
4851 return ret;
4852}
4853
Jeff Johnson295189b2012-06-20 16:38:30 -07004854/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004855
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304856 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07004857 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004859
Jeff Johnson295189b2012-06-20 16:38:30 -07004860 \param - dev - Pointer to the net device.
4861 - info - Pointer to the iw_request_info.
4862 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004863 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004865
Jeff Johnson295189b2012-06-20 16:38:30 -07004866 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304867int __iw_set_ap_address(struct net_device *dev,
4868 struct iw_request_info *info,
4869 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004870{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304871 hdd_station_ctx_t *pHddStaCtx;
4872 hdd_adapter_t *pAdapter;
4873 hdd_context_t *pHddCtx;
4874 v_U8_t *pMacAddress = NULL;
4875 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304876
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304878
4879 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4880 if (NULL == pAdapter)
4881 {
4882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4883 "%s: Adapter is NULL", __func__);
4884 return -EINVAL;
4885 }
4886 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4887 ret = wlan_hdd_validate_context(pHddCtx);
4888 if (0 != ret)
4889 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304890 return ret;
4891 }
4892 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4893 if (NULL == pHddStaCtx)
4894 {
4895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4896 "%s: pHddStaCtx is NULL", __func__);
4897 return -EINVAL;
4898 }
4899
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004901 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4902 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07004904
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304905 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004906 return 0;
4907}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304908
4909int iw_set_ap_address(struct net_device *dev,
4910 struct iw_request_info *info,
4911 union iwreq_data *wrqu, char *extra)
4912{
4913 int ret;
4914
4915 vos_ssr_protect(__func__);
4916 ret = __iw_set_ap_address(dev, info, wrqu, extra);
4917 vos_ssr_unprotect(__func__);
4918
4919 return ret;
4920}
4921
Jeff Johnson295189b2012-06-20 16:38:30 -07004922/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004923
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304924 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 This function returns the BSSID to the wpa_supplicant
4926 \param - dev - Pointer to the net device.
4927 - info - Pointer to the iw_request_info.
4928 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004929 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004930 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004931
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304933int __iw_get_ap_address(struct net_device *dev,
4934 struct iw_request_info *info,
4935 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004936{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304937 hdd_station_ctx_t *pHddStaCtx;
4938 hdd_adapter_t *pAdapter;
4939 hdd_context_t *pHddCtx;
4940 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304941
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 ENTER();
4943
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304944 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4945 if (NULL == pAdapter)
4946 {
4947 hddLog(VOS_TRACE_LEVEL_ERROR,
4948 "%s: Adapter is NULL", __func__);
4949 return -EINVAL;
4950 }
4951 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4952 ret = wlan_hdd_validate_context(pHddCtx);
4953 if (0 != ret)
4954 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304955 return ret;
4956 }
4957 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4958 if (NULL == pHddStaCtx)
4959 {
4960 hddLog(VOS_TRACE_LEVEL_ERROR,
4961 "%s: pHddStaCtx is NULL", __func__);
4962 return -EINVAL;
4963 }
4964
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4966 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4967 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004968 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 }
4970 else
4971 {
4972 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4973 }
4974 EXIT();
4975 return 0;
4976}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004977
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304978int iw_get_ap_address(struct net_device *dev,
4979 struct iw_request_info *info,
4980 union iwreq_data *wrqu, char *extra)
4981{
4982 int ret;
4983
4984 vos_ssr_protect(__func__);
4985 ret = __iw_get_ap_address(dev, info, wrqu, extra);
4986 vos_ssr_unprotect(__func__);
4987
4988 return ret;
4989}
4990
Chet Lanctot186b5732013-03-18 10:26:30 -07004991#ifdef WLAN_FEATURE_11W
4992/**---------------------------------------------------------------------------
4993
4994 \brief hdd_indicateUnprotMgmtFrame -
4995 This function forwards the unprotected management frame to the supplicant
4996 \param - pAdapter - Pointer to HDD adapter
4997 - nFrameLength - Length of the unprotected frame being passed
4998 - pbFrames - Pointer to the frame buffer
4999 - frameType - 802.11 frame type
5000 \return - nothing
5001
5002 --------------------------------------------------------------------------*/
5003void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
5004 tANI_U32 nFrameLength,
5005 tANI_U8* pbFrames,
5006 tANI_U8 frameType )
5007{
5008 tANI_U8 type = 0;
5009 tANI_U8 subType = 0;
5010
5011 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
5012 __func__, frameType, nFrameLength);
5013
5014 /* Sanity Checks */
5015 if (NULL == pAdapter)
5016 {
5017 hddLog( LOGE, FL("pAdapter is NULL"));
5018 return;
5019 }
5020
5021 if (NULL == pAdapter->dev)
5022 {
5023 hddLog( LOGE, FL("pAdapter->dev is NULL"));
5024 return;
5025 }
5026
5027 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
5028 {
5029 hddLog( LOGE, FL("pAdapter has invalid magic"));
5030 return;
5031 }
5032
5033 if( !nFrameLength )
5034 {
5035 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
5036 return;
5037 }
5038
5039 if (NULL == pbFrames) {
5040 hddLog( LOGE, FL("pbFrames is NULL"));
5041 return;
5042 }
5043
5044 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
5045 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
5046
5047 /* Get pAdapter from Destination mac address of the frame */
5048 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
5049 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305050#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5051 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5052#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005053 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305054#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005055 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
5056 }
5057 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
5058 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305059#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5060 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5061#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005062 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305063#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005064 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
5065 }
5066 else
5067 {
5068 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
5069 return;
5070 }
5071}
5072#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005073
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005074#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005075void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
5076 tANI_U8 state,
5077 tANI_U16 measInterval )
5078{
5079 union iwreq_data wrqu;
5080 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005081 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005082
5083 if (NULL == pAdapter)
5084 return;
5085
5086 // create the event
5087 memset(&wrqu, '\0', sizeof(wrqu));
5088 memset(buf, '\0', sizeof(buf));
5089
5090 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
5091 tid, state, measInterval);
5092
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005093 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005094
5095 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005096 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005097 // send the event
5098 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5099}
5100
5101void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
5102{
5103 union iwreq_data wrqu;
5104 char buf[IW_CUSTOM_MAX + 1];
5105 char *pos = buf;
5106 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5107
5108 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5109 return;
5110
5111 // create the event
5112 memset(&wrqu, '\0', sizeof(wrqu));
5113 memset(buf, '\0', sizeof(buf));
5114
5115 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305116 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
5117 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
5118 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
5119 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005120
5121 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
5122 pos += nBytes;
5123 freeBytes -= nBytes;
5124
5125 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
5126 pos += WNI_CFG_BSSID_LEN;
5127 freeBytes -= WNI_CFG_BSSID_LEN;
5128
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005129 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
5130 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005131
5132 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005133 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005134
5135 // send the event
5136 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5137}
5138
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005139void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005140{
5141 union iwreq_data wrqu;
5142 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005143 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005144
5145 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5146 return;
5147
5148 // create the event
5149 memset(&wrqu, '\0', sizeof(wrqu));
5150 memset(buf, '\0', sizeof(buf));
5151
5152 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
5153
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005154 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005155
5156 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005157 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005158
5159 // send the event
5160 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5161}
5162
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005163void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
5164 const tANI_U16 measurementToken,
5165 const tANI_BOOLEAN flag,
5166 const tANI_U8 numBss)
5167{
5168 union iwreq_data wrqu;
5169 char buf[IW_CUSTOM_MAX];
5170 char *pos = buf;
5171 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5172
5173 memset(&wrqu, '\0', sizeof(wrqu));
5174 memset(buf, '\0', sizeof(buf));
5175
5176 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
5177 numBss);
5178
5179 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
5180 flag, numBss);
5181
5182 wrqu.data.pointer = buf;
5183 wrqu.data.length = nBytes;
5184 // send the event
5185 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5186}
5187
5188
5189static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005190 const tCsrRoamInfo *pRoamInfo)
5191{
5192 union iwreq_data wrqu;
5193 char buf[IW_CUSTOM_MAX + 1];
5194 char *pos = buf;
5195 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5196 tANI_U8 i = 0, len = 0;
5197 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
5198 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005199 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
5200 tANI_U8 ieLenByte = 1;
5201 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
5202#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005203
5204 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5205 return;
5206
5207 /* Custom event can pass maximum of 256 bytes of data,
5208 based on the IE len we need to identify how many BSS info can
5209 be filled in to custom event data */
5210 /*
5211 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
5212 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
5213 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
5214 */
5215
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005216 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005217 {
5218 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
5219 /* If the measurement is none and no scan results found,
5220 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005221 hdd_indicateEseBcnReportNoResults(pAdapter,
5222 pRoamInfo->pEseBcnReportRsp->measurementToken,
5223 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005224 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005225 }
5226 else
5227 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005228 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005229 {
5230 memset(&wrqu, '\0', sizeof(wrqu));
5231 memset(buf, '\0', sizeof(buf));
5232 tot_bcn_ieLen = 0;
5233 sendBss = 0;
5234 pos = buf;
5235 freeBytes = IW_CUSTOM_MAX;
5236
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005237 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005238 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005239 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
5240 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005241 {
5242 break;
5243 }
5244 tot_bcn_ieLen += len;
5245 sendBss++;
5246 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
5247 "IeLength(%d) Length of Ie(%d) totLen(%d)",
5248 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005249 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005250 tot_bcn_ieLen);
5251 }
5252
5253 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
5254 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005255 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5256 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005257
5258 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005259 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5260 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005261 pos += nBytes;
5262 freeBytes -= nBytes;
5263
5264 /* Copy total Beacon report data length */
5265 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
5266 pos += sizeof(tot_bcn_ieLen);
5267 freeBytes -= sizeof(tot_bcn_ieLen);
5268
5269 for (i = 0; i < sendBss; i++)
5270 {
5271 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305272 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
5273 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005274 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005275 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
5276 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
5277 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
5278 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
5279 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
5280 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
5281 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
5282 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
5283 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
5284 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
5285 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
5286 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
5287 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
5288 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
5289 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
5290 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005291
5292 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005293 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
5294 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005295 pos += len;
5296 freeBytes -= len;
5297
5298 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005299 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005300 vos_mem_copy(pos, (char*)&len, sizeof(len));
5301 pos += sizeof(len);
5302 freeBytes -= sizeof(len);
5303
5304 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005305 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005306 pos += len;
5307 freeBytes -= len;
5308 }
5309
5310 wrqu.data.pointer = buf;
5311 wrqu.data.length = strlen(buf);
5312
5313 // send the event
5314 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5315 lastSent += sendBss;
5316 }
5317 }
5318}
5319
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005320#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005321