blob: c6554c90c2548cbd71e470df14a6fb459e6ca6a0 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302 * Copyright (c) 2012-2015 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
Sushant Kaushikdc3184b2015-10-09 12:00:21 +0530672 hddLog(VOS_TRACE_LEVEL_ERROR, MAC_ADDRESS_STR " connected to "
673 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;
Arif Hussain24bafea2013-11-15 15:10:03 -0800702 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR"\n",
703 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700704 }
705 else /* Not Associated */
706 {
707 pr_info("wlan: disconnected\n");
708 type = WLAN_STA_DISASSOC_DONE_IND;
709 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
Bhargav Shahd0715912015-10-01 18:17:37 +0530710
711 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700712 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700713 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700714
715 msg = NULL;
716 /*During the WLAN uninitialization,supplicant is stopped before the
717 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530718 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 {
720 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800721#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700723 {
724 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
725 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
727 }
728#endif
729 }
730 send_btc_nlink_msg(type, 0);
731}
732
733void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
734{
735 // Remove staId, bssId and peerMacAddress
736 pHddStaCtx->conn_info.staId [ 0 ] = 0;
737 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
738 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
739
740 // Clear all security settings
741 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
742 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
743 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
744
745 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700746 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700747
748 // Set not-connected state
749 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700750
751 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
752}
Katya Nigam47528772015-02-11 12:24:49 +0530753
754VOS_STATUS hdd_ibss_deinit_tx_rx_sta ( hdd_adapter_t *pAdapter, v_U8_t STAId )
755{
Katya Nigam1fd24402015-02-16 14:52:19 +0530756 v_U8_t ac;
757 /**Track whether OS TX queue has been disabled.*/
758 v_BOOL_t txSuspended[NUM_TX_QUEUES];
759 v_U8_t tlAC;
Katya Nigam47528772015-02-11 12:24:49 +0530760 v_U8_t i;
761 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
762 hdd_ibss_peer_info_t *pPeerInfo;
763
764 if( NULL == pHddStaCtx )
765 {
766 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
767 "%s: HDD station context NULL ",__func__);
768 return VOS_STATUS_E_FAILURE;
769 }
Katya Nigam1fd24402015-02-16 14:52:19 +0530770
Katya Nigam47528772015-02-11 12:24:49 +0530771 pPeerInfo = &pHddStaCtx->ibss_peer_info;
772 if (FALSE == pPeerInfo->ibssStaInfo[STAId].isUsed)
773 {
774 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
775 "%s: Deinit station not inited %d", __func__, STAId );
776 return VOS_STATUS_E_FAILURE;
777 }
778
779 hdd_flush_ibss_tx_queues(pAdapter, STAId);
Katya Nigam1fd24402015-02-16 14:52:19 +0530780
781 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
782 {
783 tlAC = hdd_QdiscAcToTlAC[ac];
784 txSuspended[ac] = pPeerInfo->ibssStaInfo[STAId].txSuspended[tlAC];
785 }
786
Katya Nigam47528772015-02-11 12:24:49 +0530787 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
788
Katya Nigam1fd24402015-02-16 14:52:19 +0530789 /* re-init hdd list, since netdev can still open adapter until
790 * driver gets unloaded
791 */
792 for (i = 0; i < NUM_TX_QUEUES; i ++)
793 {
794 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i],
795 HDD_TX_QUEUE_MAX_LEN);
796 }
797
798 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
799 {
800 if (txSuspended[ac])
801 {
802 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
803 "%s: TX queue re-enabled", __func__);
804 netif_wake_subqueue(pAdapter->dev, ac);
805 }
806 }
Katya Nigam47528772015-02-11 12:24:49 +0530807 return VOS_STATUS_SUCCESS;
808}
809
810static VOS_STATUS hdd_ibss_DeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
811{
812 VOS_STATUS vosStatus;
813
814 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
815 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
816 {
817 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
818 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
819 "Status= %d [0x%08X]",
820 __func__, staId, vosStatus, vosStatus );
821 }
822
823 vosStatus = hdd_ibss_deinit_tx_rx_sta ( pAdapter, staId );
824 if( VOS_STATUS_E_FAILURE == vosStatus )
825 {
826 VOS_TRACE ( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
827 "hdd_ibss_deinit_tx_rx_sta() failed for staID %d. "
828 "Status = %d [0x%08X]",
829 staId, vosStatus, vosStatus );
830 }
831
832 return( vosStatus );
833}
834
835VOS_STATUS hdd_ibss_init_tx_rx_sta( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA)
836{
837 v_U8_t i = 0;
838 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
839 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
840
841 if (pPeerInfo->ibssStaInfo[STAId].isUsed)
842 {
843 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
844 "%s: Reinit station %d", __func__, STAId );
845 return VOS_STATUS_E_FAILURE;
846 }
847
848 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
849 for (i = 0; i < NUM_TX_QUEUES; i ++)
850 {
851 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i], HDD_TX_QUEUE_MAX_LEN);
852 }
853
854 pPeerInfo->ibssStaInfo[STAId].isUsed = VOS_TRUE;
855 pPeerInfo->ibssStaInfo[STAId].isDeauthInProgress = VOS_FALSE;
856 vos_copy_macaddr( &pPeerInfo->ibssStaInfo[STAId].macAddrSTA, pmacAddrSTA);
857
858 return VOS_STATUS_SUCCESS;
859}
860
861static VOS_STATUS hdd_ibss_RegisterSTA( hdd_adapter_t *pAdapter,
862 tCsrRoamInfo *pRoamInfo,
863 v_U8_t staId,
864 v_MACADDR_t *pPeerMacAddress,
865 tSirBssDescription *pBssDesc )
866{
867 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
868 WLAN_STADescType staDesc = {0};
869 eCsrEncryptionType connectedCipherAlgo;
870 v_BOOL_t fConnected;
871 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
872 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
873 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
874
875 if ( pPeerInfo->ibssStaInfo[staId].isUsed )
876 {
877 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
878 "clean up old entry for STA %d", staId);
879 hdd_ibss_DeregisterSTA( pAdapter, staId );
880 }
881
882 staDesc.ucSTAId = staId;
883 staDesc.wSTAType = WLAN_STA_IBSS;
884
885 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
886 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
887 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
888 // pass when making an Infrastructure connection.
889 vos_mem_copy(staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes));
890 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId, 6 );
891 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
892
893 if (hdd_wmm_is_active(pAdapter))
894 {
895 staDesc.ucQosEnabled = 1;
896 }
897 else
898 {
899 staDesc.ucQosEnabled = 0;
900 }
901 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
902 "HDD SOFTAP register TL QoS_enabled=%d",
903 staDesc.ucQosEnabled );
904
905 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
906 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
907 {
908 staDesc.ucProtectedFrame = 1;
909 }
910 else
911 {
912 staDesc.ucProtectedFrame = 0;
913
914 }
915
916 hdd_ibss_init_tx_rx_sta(pAdapter, staId, &staDesc.vSTAMACAddress);
917
918 // UMA is Not ready yet, Xlation will be done by TL
919 staDesc.ucSwFrameTXXlation = 1;
920 staDesc.ucSwFrameRXXlation = 1;
921 staDesc.ucAddRmvLLC = 1;
922 // Initialize signatures and state
923 staDesc.ucUcastSig = pRoamInfo->ucastSig;
924 staDesc.ucBcastSig = pRoamInfo->bcastSig;
925 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED;
926
927 staDesc.ucIsReplayCheckValid = VOS_FALSE;
928
929 // Register the Station with TL.
930 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
931 hdd_rx_packet_cbk,
932 hdd_tx_complete_cbk,
933 hdd_ibss_tx_fetch_packet_cbk, &staDesc,
934 pBssDesc->rssi );
935 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
936 {
937 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
938 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
939 vosStatus, vosStatus );
940 return vosStatus;
941 }
942
943 //Timer value should be in milliseconds
944 if ( pHddCtx->cfg_ini->dynSplitscan &&
945 ( VOS_TIMER_STATE_RUNNING !=
946 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
947 {
948 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
949 pHddCtx->cfg_ini->trafficMntrTmrForSplitScan);
950 }
951
952 pPeerInfo->ibssStaInfo[staId].ucSTAId = staId;
953 pPeerInfo->ibssStaInfo[staId].isQosEnabled = staDesc.ucQosEnabled;
954
955 vosStatus = WLANTL_ChangeSTAState( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId,
956 WLANTL_STA_AUTHENTICATED );
957
958 pPeerInfo->ibssStaInfo[staId].tlSTAState = WLANTL_STA_AUTHENTICATED;
959 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
960
961 return( vosStatus );
962}
963
Jeff Johnson295189b2012-06-20 16:38:30 -0700964/* TODO Revist this function. and data path */
965static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
966{
967 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700968
Katya Nigam47528772015-02-11 12:24:49 +0530969 hdd_disconnect_tx_rx(pAdapter);
Ravi Joshif9520d62013-10-18 04:11:46 -0700970
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
972 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
973 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530974 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700976 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700977 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 }
979 return( vosStatus );
980}
981
982
983static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
984 tANI_U32 roamId, eRoamCmdStatus roamStatus,
985 eCsrRoamResult roamResult )
986{
987 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700988 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700989 struct net_device *dev = pAdapter->dev;
990 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
991 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700992 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530993 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700994
995 // Sanity check
996 if(dev == NULL)
997 {
Agarwal Ashish971c2882013-10-30 20:11:12 +0530998 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700999 "%s: net_dev is released return", __func__);
1000 return eHAL_STATUS_FAILURE;
1001 }
1002
Jeff Johnson295189b2012-06-20 16:38:30 -07001003 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301004 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001005 netif_tx_disable(dev);
1006 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +05301007 //TxTimeoutCount need to reset in case of disconnect handler
1008 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001009
Jeff Johnsone7245742012-09-05 17:12:55 -07001010 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301011 /* If only STA mode is on */
1012 if((pHddCtx->concurrency_mode <= 1) &&
1013 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
1014 {
1015 pHddCtx->isAmpAllowed = VOS_TRUE;
1016 }
1017
Agarwal Ashish47d18112014-08-04 19:55:07 +05301018 /* Need to apply spin lock before decreasing active sessions
1019 * as there can be chance for double decrement if context switch
1020 * Calls wlan_hdd_disconnect.
1021 */
1022
1023 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh087de602015-10-21 17:18:55 +05301024
1025 /* HDD has initiated disconnect, do not send disconnect indication
1026 * to kernel. Sending disconnected event to kernel for userspaces
1027 * initiated disconnect will be handled by hdd_DisConnectHandler call
1028 * to cfg80211_disconnected.
1029 */
1030 if ((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
1031 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301032 {
1033 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1034 FL(" HDD has initiated a disconnect, no need to send"
1035 " disconnect indication to kernel"));
1036 sendDisconInd = FALSE;
1037 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301038 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301040 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singh087de602015-10-21 17:18:55 +05301041 FL("Set HDD connState to eConnectionState_Disconnecting from %d "),
Agarwal Ashish47d18112014-08-04 19:55:07 +05301042 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301043 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
1044 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 }
Agarwal Ashish47d18112014-08-04 19:55:07 +05301046 spin_unlock_bh(&pAdapter->lock_for_active_session);
1047
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -07001049
1050 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07001051
1052 // indicate 'disconnect' status to wpa_supplicant...
1053 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001054 /* indicate disconnected event to nl80211 */
1055 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
1056 {
1057 /*During the WLAN uninitialization,supplicant is stopped before the
1058 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301059 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001060 {
Sushant Kaushik0b343422015-05-25 17:15:55 +05301061 if (sendDisconInd)
1062 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1063 "%s: sent disconnected event to nl80211",
1064 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001065#ifdef WLAN_FEATURE_P2P_DEBUG
1066 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1067 {
1068 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
1069 {
1070 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
1071 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
1072 "and moved to disconnected state");
1073 }
1074 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
1075 {
1076 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
1077 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
1078 "and moved to inactive state");
1079 }
1080 }
1081#endif
Sushant Kaushikbad61892015-07-10 16:43:28 +05301082 if ((roamStatus == eCSR_ROAM_LOSTLINK) &&
1083 !pRoamInfo->reasonCode)
1084 wlan_hdd_get_frame_logs(pAdapter,
1085 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301086 /*Only send indication to kernel if not initiated by kernel*/
1087 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301089 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
1090 if ( eCSR_ROAM_LOSTLINK == roamStatus )
1091 {
1092 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
1093 }
1094 else
1095 {
1096 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
1097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001098 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301099
1100 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1101 {
1102 hddLog(LOG1,
1103 FL("P2P client is getting removed and we are tryig to re-enable TDLS"));
1104 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301105 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301106
Jeff Johnson295189b2012-06-20 16:38:30 -07001107 //If the Device Mode is Station
1108 // and the P2P Client is Connected
1109 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001110
1111 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001112 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001113 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 {
1115 //Enable BMPS only of other Session is P2P Client
1116 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001117 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001118
1119 if (NULL != pVosContext)
1120 {
1121 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1122
1123 if(NULL != pHddCtx)
1124 {
1125 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301126 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1127 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301129 if (pHddCtx->hdd_wlan_suspended)
1130 {
1131 hdd_set_pwrparams(pHddCtx);
1132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001135 }
1136 }
1137 }
1138 }
1139 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001140
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301141 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +05301142#if defined(WLAN_FEATURE_VOWIFI_11R)
1143 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1144#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301145
1146 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1147 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301148 v_U8_t i;
1149
Katya Nigam63ce1772014-09-26 15:53:49 +05301150 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301151 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301152 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1153 {
1154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301155 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1156 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301157 sta_id, status, status );
1158
1159 status = eHAL_STATUS_FAILURE;
1160 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301161 pHddCtx->sta_to_adapter[sta_id] = NULL;
1162
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301163 /*Clear all the peer sta register with TL.*/
1164 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1165 {
1166 if (0 != pHddStaCtx->conn_info.staId[i])
1167 {
1168 sta_id = pHddStaCtx->conn_info.staId[i];
1169
1170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1171 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301172 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301173 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1174 {
1175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1176 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1177 "Status= %d [0x%x]"),
1178 sta_id, status, status );
1179 status = eHAL_STATUS_FAILURE;
1180 }
1181
Nirav Shah7e3c8132015-06-22 23:51:42 +05301182 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1183 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1184 if (vstatus != VOS_STATUS_SUCCESS) {
1185 hddLog(VOS_TRACE_LEVEL_ERROR,
1186 FL("Not able to remove staid hash %d"),
1187 sta_id);
1188 status = eHAL_STATUS_FAILURE;
1189 } else {
1190 hddLog(VOS_TRACE_LEVEL_INFO,
1191 FL("ibss station removed sta_id %d mac:"
1192 MAC_ADDRESS_STR), sta_id,
1193 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1194 }
1195
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301196 /*set the staid and peer mac as 0, all other reset are
1197 * done in hdd_connRemoveConnectInfo.
1198 */
1199 pHddStaCtx->conn_info.staId[i]= 0;
1200 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1201
1202 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1203 pHddCtx->sta_to_adapter[sta_id] = NULL;
1204 }
1205 }
1206
Katya Nigam63ce1772014-09-26 15:53:49 +05301207 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301208 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001209 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301210 sta_id = pHddStaCtx->conn_info.staId[0];
1211
1212 //We should clear all sta register with TL, for now, only one.
1213 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1214 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1215 {
1216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1217 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1218 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001219 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001220
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301221 status = eHAL_STATUS_FAILURE;
1222 }
1223
1224 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301226
1227#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1228 if (VOS_STATUS_SUCCESS !=
1229 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1230 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1231 {
1232 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1233 "WLANTL_ClearInterfaceStats Failed", __func__);
1234 }
1235 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1236 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1237 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1238 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1239#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1240
Jeff Johnson295189b2012-06-20 16:38:30 -07001241 // Clear saved connection information in HDD
1242 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +05301243 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1244 "%s: Set HDD connState to eConnectionState_NotConnected",
1245 __func__);
1246 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301247#ifdef WLAN_FEATURE_GTK_OFFLOAD
1248 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1249 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1250 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301251 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1252 sizeof (tSirGtkOffloadParams));
1253 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301254 }
1255#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001256
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001257#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001258 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1259 {
1260 wlan_hdd_tdls_disconnection_callback(pAdapter);
1261 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001262#endif
1263
Jeff Johnson295189b2012-06-20 16:38:30 -07001264 //Unblock anyone waiting for disconnect to complete
1265 complete(&pAdapter->disconnect_comp_var);
1266 return( status );
1267}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301268
1269static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
1270 v_U8_t staId)
1271{
1272 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1273 v_SINT_t i;
1274 v_SIZE_t size;
1275 VOS_STATUS status;
1276 v_BOOL_t granted = VOS_FALSE;
1277
1278 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1279 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
1280 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
1281 {
1282 //Indicate to TL that there is pending data if a queue is non empty
1283 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
1284 {
1285 size = 0;
1286 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
1287 if (size > 0)
1288 {
1289 if (i != WLANTL_AC_HIGH_PRIO)
1290 {
1291 if (VOS_FALSE ==
1292 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
1293 {
1294 hdd_wmm_acquire_access(pAdapter,
1295 (WLANTL_ACEnumType)i, &granted);
1296 pAdapter->psbChanged |= (1 << i);
1297 }
1298 else
1299 granted = VOS_TRUE;
1300 }
1301
1302 if (granted || (i == WLANTL_AC_HIGH_PRIO))
1303 {
1304 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
1305 staId, (WLANTL_ACEnumType)i);
1306 if (!VOS_IS_STATUS_SUCCESS(status))
1307 {
1308 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1309 "%s: Failure in indicating pkt to TL for QID=%d",
1310 __func__, i);
1311 }
1312 }
1313 }
1314 }
1315 }
1316}
1317
Jeff Johnson295189b2012-06-20 16:38:30 -07001318static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
1319 tCsrRoamInfo *pRoamInfo,
1320 v_U8_t staId,
1321 v_MACADDR_t *pPeerMacAddress,
1322 tSirBssDescription *pBssDesc )
1323{
1324 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1325 WLAN_STADescType staDesc = {0};
1326 eCsrEncryptionType connectedCipherAlgo;
1327 v_BOOL_t fConnected;
1328 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1329 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001330 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001331
1332 if ( NULL == pBssDesc)
1333 {
1334 return VOS_STATUS_E_FAILURE;
1335 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 // Get the Station ID from the one saved during the assocation.
1337 staDesc.ucSTAId = staId;
1338
Katya Nigam47528772015-02-11 12:24:49 +05301339 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001340
Katya Nigam47528772015-02-11 12:24:49 +05301341 // grab the bssid from the connection info in the adapter structure and hand that
1342 // over to TL when registering.
1343 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
1344 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001345
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1347
1348 // set the QoS field appropriately
1349 if (hdd_wmm_is_active(pAdapter))
1350 {
1351 staDesc.ucQosEnabled = 1;
1352 }
1353 else
1354 {
1355 staDesc.ucQosEnabled = 0;
1356 }
1357
1358 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1359 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1360 {
1361 staDesc.ucProtectedFrame = 1;
1362 }
1363 else
1364 {
1365 staDesc.ucProtectedFrame = 0;
1366
1367 }
1368
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001369#ifdef FEATURE_WLAN_ESE
1370 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1371#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001372
1373#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1374 /* check whether replay check is valid for the station or not */
1375 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1376 {
1377 /* Encryption mode is either TKIP or AES
1378 and replay check is valid for only these
1379 two encryption modes */
1380 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1381 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1382 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1383 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001384
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 else
1386 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001387 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001389 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1391 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1392 }
1393#endif
1394
1395#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001396 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001397 if (pAdapter->wapi_info.fIsWapiSta)
1398 {
1399 staDesc.ucIsWapiSta = 1;
1400 }
1401 else
1402 {
1403 staDesc.ucIsWapiSta = 0;
1404 }
1405#endif /* FEATURE_WLAN_WAPI */
1406
1407 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1408 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1409
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 // UMA is Not ready yet, Xlation will be done by TL
1411 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001412 staDesc.ucSwFrameRXXlation = 1;
1413 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001414 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 staDesc.ucQosEnabled );
1416 // Initialize signatures and state
1417 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1418 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1419 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1420 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001421 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001422 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 -07001423 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1424 hdd_rx_packet_cbk,
1425 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001426 hdd_tx_fetch_packet_cbk, &staDesc,
1427 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001428
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1430 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001431 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001432 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001434 return vosStatus;
1435 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001436
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001437 if ( cfg_param->dynSplitscan &&
1438 ( VOS_TIMER_STATE_RUNNING !=
1439 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1440 {
1441 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1442 cfg_param->trafficMntrTmrForSplitScan);
1443 }
1444
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301445 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1446 // then go to 'authenticated'. For all other authentication types
1447 // (those that donot require upper layer authentication) we can put
1448 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001449 if (staDesc.wSTAType != WLAN_STA_IBSS)
1450 VOS_ASSERT( fConnected );
1451
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301452 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001453 {
1454 // Connections that do not need Upper layer auth, transition TL directly
1455 // to 'Authenticated' state.
1456 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1457 WLANTL_STA_AUTHENTICATED );
1458
1459 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301460
1461 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001462 }
1463 else
1464 {
1465 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301466 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1467 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001468 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301469 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001470 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 return( vosStatus );
1473}
1474
Jeff Johnson295189b2012-06-20 16:38:30 -07001475static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1476 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1477{
1478 unsigned int len = 0;
1479 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001480 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 tANI_U32 rspRsnLength = 0;
1482 struct ieee80211_channel *chan;
1483
Agarwal Ashish51325b52014-06-16 16:50:49 +05301484 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001485 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001486 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001487 }
1488
Agarwal Ashish51325b52014-06-16 16:50:49 +05301489 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001490 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1491 goto done;
1492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001493
Agarwal Ashish51325b52014-06-16 16:50:49 +05301494 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001495 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1496 goto done;
1497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001498
1499 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1500 pCsrRoamInfo->nAssocReqLength);
1501 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001502 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001503
1504 //pFTAssocRsp needs to point to the IEs
1505 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001506 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 (unsigned int)pFTAssocRsp[0],
1508 (unsigned int)pFTAssocRsp[1]);
1509
1510 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001511 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001514 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001515
1516 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1517 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1518 reqRsnIe, reqRsnLength,
1519 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001520
1521done:
1522 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001523}
Jeff Johnson295189b2012-06-20 16:38:30 -07001524
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301525void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1526{
1527 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1528 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1529 tCsrRoamInfo roamInfo;
1530 roamInfo.fAuthRequired = FALSE;
1531 vos_mem_copy(roamInfo.bssid,
1532 pHddStaCtx->roam_info.bssid,
1533 WNI_CFG_BSSID_LEN);
1534 vos_mem_copy(roamInfo.peerMac,
1535 pHddStaCtx->roam_info.peerMac,
1536 WNI_CFG_BSSID_LEN);
1537
1538 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1539 &roamInfo,
1540 pHddStaCtx->roam_info.roamId,
1541 pHddStaCtx->roam_info.roamStatus,
1542 eCSR_ROAM_RESULT_AUTHENTICATED);
1543 if (halStatus != eHAL_STATUS_SUCCESS)
1544 {
1545 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1546 }
1547 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1548}
1549
Shailender Karmuchia734f332013-04-19 14:02:48 -07001550static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1551 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001552 eCsrRoamResult roamResult )
1553{
1554 struct net_device *dev = pAdapter->dev;
1555 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1556 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301557 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05301558 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001559 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1560 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001561#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 int ft_carrier_on = FALSE;
1563#endif
1564 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301565 v_BOOL_t hddDisconInProgress = FALSE;
1566
1567 /* HDD has initiated disconnect, do not send connect result indication
1568 * to kernel as it will be handled by __cfg80211_disconnect.
1569 */
Agarwal Ashishc089cec2015-08-10 13:10:04 +05301570 if (((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
1571 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)) &&
1572 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1573 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301574 {
1575 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1576 FL(" Disconnect from HDD in progress "));
1577 hddDisconInProgress = TRUE;
1578 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001579
Jeff Johnson295189b2012-06-20 16:38:30 -07001580 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1581 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301582 if ( !hddDisconInProgress )
1583 {
1584 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301585 "%s: Set HDD connState to eConnectionState_Associated",
1586 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301587 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1588 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001589
c_hpothu44ff4e02014-05-08 00:13:57 +05301590 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001591 // Save the connection info from CSR...
1592 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1593#ifdef FEATURE_WLAN_WAPI
1594 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1595 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1596 {
1597 pAdapter->wapi_info.fIsWapiSta = 1;
1598 }
1599 else
1600 {
1601 pAdapter->wapi_info.fIsWapiSta = 0;
1602 }
1603#endif /* FEATURE_WLAN_WAPI */
1604
1605 // indicate 'connect' status to userspace
1606 hdd_SendAssociationEvent(dev,pRoamInfo);
1607
1608
Shailender Karmuchia734f332013-04-19 14:02:48 -07001609 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 INIT_COMPLETION(pAdapter->linkup_event_var);
1611
1612 /*
1613 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1614 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 -07001615 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 know that the device is getting activated properly.
1617 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001618#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05301619 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 {
1621#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001622 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 pAdapter->isLinkUpSvcNeeded = TRUE;
1624
Shailender Karmuchia734f332013-04-19 14:02:48 -07001625 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 pAdapter->isLinkUpSvcNeeded = TRUE;
1627
1628 // Switch on the Carrier to activate the device
1629 netif_carrier_on(dev);
1630
1631 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1632 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1633 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001634 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 {
1636 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1637 }
1638
1639 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1640 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001641#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001642 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001643 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001644 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001645 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 }
1647#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301648 /* Check for STAID */
1649 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1650 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1651 else
1652 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001653
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001654#ifdef FEATURE_WLAN_TDLS
1655 wlan_hdd_tdls_connection_callback(pAdapter);
1656#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001657 //For reassoc, the station is already registered, all we need is to change the state
1658 //of the STA in TL.
1659 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05301660 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 if( !pRoamInfo->fReassocReq )
1662 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001663 struct cfg80211_bss *bss;
1664#ifdef WLAN_FEATURE_VOWIFI_11R
1665 u8 *pFTAssocRsp = NULL;
1666 unsigned int assocRsplen = 0;
1667 u8 *pFTAssocReq = NULL;
1668 unsigned int assocReqlen = 0;
1669 struct ieee80211_channel *chan;
1670#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001673
1674 /* add bss_id to cfg80211 data base */
1675 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1676 if (NULL == bss)
1677 {
1678 pr_err("wlan: Not able to create BSS entry\n");
Katya Nigam346d4e92014-09-02 16:16:12 +05301679 netif_carrier_off(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 return eHAL_STATUS_FAILURE;
1681 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001682#ifdef WLAN_FEATURE_VOWIFI_11R
1683 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001684 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001686
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001687 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001688 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001689 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001690 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001691 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001692 // pFTAssocRsp needs to point to the IEs
1693 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1694 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1695 (unsigned int)pFTAssocRsp[0],
1696 (unsigned int)pFTAssocRsp[1]);
1697 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001698 }
1699 else
1700 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001701 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1702 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001703 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001704
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001705 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001706 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001707 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001708 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001709 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001710 if(!ft_carrier_on)
1711 {
1712 // pFTAssocReq needs to point to the IEs
1713 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1714 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1715 (unsigned int)pFTAssocReq[0],
1716 (unsigned int)pFTAssocReq[1]);
1717 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1718 }
1719 else
1720 {
1721 /* This should contain only the FTIEs */
1722 assocReqlen = pRoamInfo->nAssocReqLength;
1723 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001724 }
1725 else
1726 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001727 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1728 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001729 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001730
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001731 if(ft_carrier_on)
1732 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301733 if ( !hddDisconInProgress )
1734 {
1735 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001736 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301737 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001738 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301739 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001740 assocRsplen);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301741 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1742 {
1743 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1744 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301745 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001746 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1747 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301748 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301749 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1750 {
1751 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1752 pRoamInfo->fAuthRequired = FALSE;
1753
1754 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1755 pRoamInfo->bssid,
1756 HDD_MAC_ADDR_LEN);
1757 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1758 pRoamInfo->peerMac,
1759 HDD_MAC_ADDR_LEN);
1760 pHddStaCtx->roam_info.roamId = roamId;
1761 pHddStaCtx->roam_info.roamStatus = roamStatus;
1762 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1763 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001764 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301765 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001766 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001767 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001768 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001769 cfg80211_connect_result(dev, pRoamInfo->bssid,
1770 pFTAssocReq, assocReqlen,
1771 pFTAssocRsp, assocRsplen,
1772 WLAN_STATUS_SUCCESS,
1773 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001774 }
1775 }
1776 else
1777#endif
1778 {
1779 /* wpa supplicant expecting WPA/RSN IE in connect result */
1780 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1781 pAdapter->sessionId,
1782 &reqRsnLength,
1783 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001784
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001785 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1786 pAdapter->sessionId,
1787 &rspRsnLength,
1788 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301789 if ( !hddDisconInProgress )
1790 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001791#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301792 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301793 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301794 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301795 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1796 {
1797 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1798 }
Mukul Sharma84f27252014-07-14 18:11:42 +05301799 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301800 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001801#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001802
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301803 {
1804 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301805 "%s: sending connect indication to nl80211:"
1806 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301807 " result:%d and Status:%d",
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301808 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1809 roamResult, roamStatus);
1810
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301811 /* inform connect result to nl80211 */
1812 cfg80211_connect_result(dev, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001813 reqRsnIe, reqRsnLength,
1814 rspRsnIe, rspRsnLength,
1815 WLAN_STATUS_SUCCESS,
1816 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301817 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001818 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301820 if ( !hddDisconInProgress )
1821 {
1822 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001823#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301824 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001825#endif
1826 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301827 // Register the Station with TL after associated...
1828 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 pRoamInfo,
1830 pHddStaCtx->conn_info.staId[ 0 ],
1831 NULL,
1832 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301833 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 }
1835 else
1836 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001837 /* wpa supplicant expecting WPA/RSN IE in connect result */
1838 /* in case of reassociation also need to indicate it to supplicant */
1839 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1840 pAdapter->sessionId,
1841 &reqRsnLength,
1842 reqRsnIe);
1843
1844 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301846 if( pRoamInfo->fAuthRequired )
1847 {
1848 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1849 pHddStaCtx->conn_info.staId[ 0 ],
1850 WLANTL_STA_CONNECTED );
1851 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1852 }
1853 else
1854 {
1855 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1856 "%s: staId: %d Changing TL state to AUTHENTICATED",
1857 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1858 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1859 pHddStaCtx->conn_info.staId[ 0 ],
1860 WLANTL_STA_AUTHENTICATED );
1861 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301862 hdd_postTLPacketPendingInd(pAdapter,
1863 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301864 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 }
1866
1867 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1868 {
1869 // perform any WMM-related association processing
1870 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1871 }
1872 else
1873 {
1874 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001875 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001876 vosStatus, vosStatus );
1877 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001878#ifdef WLAN_FEATURE_11W
1879 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1880 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1881#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301882
Jeff Johnson295189b2012-06-20 16:38:30 -07001883 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05301884 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301885 {
1886 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05301887 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301888 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301889 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1890 {
1891 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1892 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001893 }
1894 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1897
1898 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001899 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001900 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301901 " result:%d and Status:%d",
Arif Hussain24bafea2013-11-15 15:10:03 -08001902 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1903 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001904 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001905 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301906 " result:%d and Status:%d",
Arif Hussain24bafea2013-11-15 15:10:03 -08001907 MAC_ADDR_ARRAY(pWextState->req_bssId),
1908 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001909
Sachin Ahuja674c5112015-10-14 13:16:49 +05301910 if (( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
1911 ((roamResult != eCSR_ROAM_RESULT_ASSOCIATED) &&
1912 (eCSR_ROAM_ASSOCIATION_COMPLETION == roamStatus)))
Abhishek Singh611295e2015-07-09 11:11:54 +05301913 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05301914 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
1915
Abhishek Singhf4669da2014-05-26 15:07:49 +05301916 /* Set connection state to eConnectionState_NotConnected only when CSR
1917 * has completed operation - with a ASSOCIATION_FAILURE status
1918 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301919 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301920 {
1921 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1922 "%s: Set HDD connState to eConnectionState_NotConnected",
1923 __func__);
1924 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1925 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05301926 if((pHddCtx->concurrency_mode <= 1) &&
1927 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 {
1929 pHddCtx->isAmpAllowed = VOS_TRUE;
1930 }
1931
1932 //If the Device Mode is Station
1933 // and the P2P Client is Connected
1934 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001935
1936 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001937 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001938 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1939 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05301940 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07001941 {
1942 //Enable BMPS only of other Session is P2P Client
1943 hdd_context_t *pHddCtx = NULL;
1944 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1945
1946 if (NULL != pVosContext)
1947 {
1948 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1949
1950 if(NULL != pHddCtx)
1951 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301952 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301953 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1954 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301955 {
1956 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001957 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301958 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001959 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301960 hdd_enable_bmps_imps(pHddCtx);
1961 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 }
1963 }
1964 }
1965
James Zmudafbf5ffc2013-03-25 12:45:35 -07001966 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001967 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301968 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07001969 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301970
1971 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1972 {
1973 hddLog(LOG1,
1974 FL("Assoication Failure for P2P client and we are trying to re-enable TDLS"));
1975 wlan_hdd_tdls_reenable(pHddCtx);
1976 }
1977
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301978 if (pRoamInfo)
1979 hddLog(VOS_TRACE_LEVEL_ERROR,
1980 "%s: send connect failure to nl80211:"
1981 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301982 " result:%d and Status:%d reasonCode %d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301983 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301984 roamResult, roamStatus, pRoamInfo->reasonCode);
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301985 else
1986 hddLog(VOS_TRACE_LEVEL_ERROR,
1987 "%s: connect failed:"
1988 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301989 " result:%d and Status:%d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301990 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1991 roamResult, roamStatus);
1992
James Zmudafbf5ffc2013-03-25 12:45:35 -07001993 /* inform association failure event to nl80211 */
1994 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1995 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001996 if (pRoamInfo)
1997 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1998 NULL, 0, NULL, 0,
1999 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
2000 GFP_KERNEL );
2001 else
2002 cfg80211_connect_result ( dev, pWextState->req_bssId,
2003 NULL, 0, NULL, 0,
2004 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
2005 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07002006 }
2007 else
2008 {
Sushant Kaushik21f28232014-12-18 11:42:46 +05302009 if (pRoamInfo){
2010 eCsrAuthType authType =
2011 pWextState->roamProfile.AuthType.authType[0];
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302012 eCsrEncryptionType encryptionType =
2013 pWextState->roamProfile.EncryptionType.encryptionType[0];
2014 v_BOOL_t isWep =
2015 (((authType == eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
2016 (authType == eCSR_AUTH_TYPE_SHARED_KEY)) &&
2017 ((encryptionType == eCSR_ENCRYPT_TYPE_WEP40) ||
2018 (encryptionType == eCSR_ENCRYPT_TYPE_WEP104) ||
2019 (encryptionType ==
2020 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2021 (encryptionType ==
2022 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)));
2023
Sushant Kaushik21f28232014-12-18 11:42:46 +05302024
2025 /* In case of OPEN-WEP or SHARED-WEP authentication,
2026 * send exact protocol reason code. This enables user
2027 * applications to reconnect the station with correct
2028 * configuration.
2029 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002030 cfg80211_connect_result ( dev, pRoamInfo->bssid,
2031 NULL, 0, NULL, 0,
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302032 (isWep && pRoamInfo->reasonCode) ?
2033 pRoamInfo->reasonCode :
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002034 WLAN_STATUS_UNSPECIFIED_FAILURE,
2035 GFP_KERNEL );
Sushant Kaushik21f28232014-12-18 11:42:46 +05302036 } else
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002037 cfg80211_connect_result ( dev, pWextState->req_bssId,
2038 NULL, 0, NULL, 0,
2039 WLAN_STATUS_UNSPECIFIED_FAILURE,
2040 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07002041 }
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302042 /*Clear the roam profile*/
2043 hdd_clearRoamProfileIe( pAdapter );
Jeff Johnsone7245742012-09-05 17:12:55 -07002044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002045
Kumar Anand82c009f2014-05-29 00:29:42 -07002046 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002047
c_hpothu24f40982014-04-18 18:00:36 +05302048 if (pRoamInfo)
2049 {
2050 WLANTL_AssocFailed(pRoamInfo->staId);
2051 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302052
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302053 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 netif_tx_disable(dev);
2055 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002056
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 }
2058
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302059 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302060 {
2061 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2062 if (pHostapdAdapter != NULL)
2063 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302064 /* Restart SAP if its operating channel is different
2065 * from AP channel.
2066 */
2067 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2068 (int)pRoamInfo->pBssDesc->channelId)
2069 {
2070 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2071 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2072 (int)pRoamInfo->pBssDesc->channelId);
Deepthi Gowric9c777d2014-12-10 16:17:11 +05302073 hdd_hostapd_stop(pHostapdAdapter->dev);
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302074 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302075 }
2076 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 return eHAL_STATUS_SUCCESS;
2078}
2079
2080/**============================================================================
2081 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002082 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002084
Jeff Johnson295189b2012-06-20 16:38:30 -07002085 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002086static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2087 tCsrRoamInfo *pRoamInfo,
2088 tANI_U32 roamId,
2089 eRoamCmdStatus roamStatus,
2090 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002091{
Katya Nigam47528772015-02-11 12:24:49 +05302092 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2093 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2094 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302095 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302096
Jeff Johnson81c17882013-05-03 09:53:35 -07002097 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2098 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2099
Jeff Johnson295189b2012-06-20 16:38:30 -07002100 switch( roamResult )
2101 {
2102 // both IBSS Started and IBSS Join should come in here.
2103 case eCSR_ROAM_RESULT_IBSS_STARTED:
2104 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002105 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002107 if (NULL == pRoamInfo)
2108 {
2109 VOS_ASSERT(0);
2110 return;
2111 }
2112
2113 /* When IBSS Started comes from CSR, we need to move
2114 * connection state to IBSS Disconnected (meaning no peers
2115 * are in the IBSS).
2116 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302117 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2118 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2119 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002120 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2121 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302122 /*notify wmm */
2123 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002124 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002125
Jeff Johnson81c17882013-05-03 09:53:35 -07002126 if (pRoamInfo->pBssDesc)
2127 {
Anand N Sunkadfec40682015-07-29 09:51:17 +05302128#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2129 struct ieee80211_channel *chan;
2130 int chan_no;
2131 unsigned int freq;
2132#endif
Katya Nigam47528772015-02-11 12:24:49 +05302133 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2134 IBSS_BROADCAST_STAID,
2135 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002136
2137 /* we created the IBSS, notify supplicant */
2138 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2139 MAC_ADDRESS_STR,
2140 __func__, pAdapter->dev->name,
2141 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2142
2143 /* we must first give cfg80211 the BSS information */
2144 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2145 if (NULL == bss)
2146 {
2147 hddLog(VOS_TRACE_LEVEL_ERROR,
2148 "%s: %s: unable to create IBSS entry",
2149 __func__, pAdapter->dev->name);
2150 return;
2151 }
Anand N Sunkadfec40682015-07-29 09:51:17 +05302152#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2153 chan_no = pRoamInfo->pBssDesc->channelId;
Jeff Johnson81c17882013-05-03 09:53:35 -07002154
Anand N Sunkadfec40682015-07-29 09:51:17 +05302155 if (chan_no <= 14)
2156 freq = ieee80211_channel_to_frequency(chan_no,
2157 IEEE80211_BAND_2GHZ);
2158 else
2159 freq = ieee80211_channel_to_frequency(chan_no,
2160 IEEE80211_BAND_5GHZ);
2161
2162 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
2163
2164 if (chan)
2165 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
2166 chan, GFP_KERNEL);
2167 else
2168 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
2169 pAdapter->dev->name,
2170 (int)pRoamInfo->pBssDesc->channelId);
2171#else
Jeff Johnson81c17882013-05-03 09:53:35 -07002172 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302173#endif
Yue Maf49ba872013-08-19 12:04:25 -07002174 cfg80211_put_bss(
2175#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2176 pHddCtx->wiphy,
2177#endif
2178 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07002179 }
Katya Nigam47528772015-02-11 12:24:49 +05302180 else
2181 {
2182 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2183 "%s: NULL Bss Desc",__func__);
2184 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05302185
2186 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
2187 * in IBSS_COALESCED will remove the BC key.
2188 */
2189 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
2190 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
2191 == pHddStaCtx->ibss_enc_key.encType
2192 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
2193 == pHddStaCtx->ibss_enc_key.encType
2194 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2195 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
2196 {
2197 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2198 VOS_STATUS vosStatus;
2199
2200 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2201
2202 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2203 grpmacaddr, WNI_CFG_BSSID_LEN);
2204 hddLog(VOS_TRACE_LEVEL_INFO,
2205 FL(" SET GTK in case of COALESCED"));
2206 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2207 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2208 if ( VOS_STATUS_SUCCESS != vosStatus )
2209 {
2210 hddLog(VOS_TRACE_LEVEL_ERROR,
2211 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
2212 }
2213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 break;
2215 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002216
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
2218 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002219 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
2220 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07002221 break;
2222 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002223
Jeff Johnson295189b2012-06-20 16:38:30 -07002224 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07002225 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
2226 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002228 }
2229
Jeff Johnson81c17882013-05-03 09:53:35 -07002230 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002231}
2232
2233/**============================================================================
2234 *
2235 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
2236 This information is passed to iwconfig later. The peer that joined
2237 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002238 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002239 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002240
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05302242static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07002243{
2244 int fSuccess = FALSE;
2245 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302246 VOS_STATUS status;
2247 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002248
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2250 {
2251 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
2252 {
2253 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002254
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002256
Jeff Johnson295189b2012-06-20 16:38:30 -07002257 fSuccess = TRUE;
2258 break;
2259 }
2260 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002261
Nirav Shah7e3c8132015-06-22 23:51:42 +05302262 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
2263 if (status != VOS_STATUS_SUCCESS) {
2264 hddLog(VOS_TRACE_LEVEL_ERROR,
2265 FL("Not able to add staid hash %d"), staId);
2266 return FALSE;
2267 }
2268
2269 hddLog(VOS_TRACE_LEVEL_INFO,
2270 FL("New station added sta_id %d mac:"
2271 MAC_ADDRESS_STR), staId,
2272 MAC_ADDR_ARRAY(peerMacAddress->bytes));
2273
Shailender Karmuchia734f332013-04-19 14:02:48 -07002274 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07002275}
2276/**============================================================================
2277 *
2278 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002279 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002281
Jeff Johnson295189b2012-06-20 16:38:30 -07002282 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07002283static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07002284{
2285 int fSuccess = FALSE;
2286 int idx = 0;
2287 v_U8_t valid_idx = 0;
2288 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07002289 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002290 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05302291 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002292
Jeff Johnson295189b2012-06-20 16:38:30 -07002293 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2294 {
2295 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
2296 {
2297 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302298 status = hdd_sta_id_hash_remove_entry(pAdapter,
2299 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
2300 if (status != VOS_STATUS_SUCCESS) {
2301 hddLog(VOS_TRACE_LEVEL_ERROR,
2302 FL("Not able to remove staid hash %d"), staId );
2303 fSuccess = FALSE;
2304 } else {
2305 hddLog(VOS_TRACE_LEVEL_INFO,
2306 FL("station removed sta_id %d mac:"
2307 MAC_ADDRESS_STR), staId,
2308 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07002309
Nirav Shah7e3c8132015-06-22 23:51:42 +05302310 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002311
Nirav Shah7e3c8132015-06-22 23:51:42 +05302312 fSuccess = TRUE;
2313 // Note the deleted Index, if its 0 we need special handling
2314 del_idx = idx;
2315 empty_slots++;
2316 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 }
2318 else
2319 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002320 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002321 {
2322 valid_idx = idx;
2323 }
Ravi Joshi8a934352013-09-25 16:46:58 -07002324 else
2325 {
2326 // Found an empty slot
2327 empty_slots++;
2328 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 }
2330 }
2331
Ravi Joshi8a934352013-09-25 16:46:58 -07002332 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
2333 {
2334 // Last peer departed, set the IBSS state appropriately
2335 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002336 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07002337 "Last IBSS Peer Departed!!!" );
2338 }
2339
Jeff Johnson295189b2012-06-20 16:38:30 -07002340 // Find next active staId, to have a valid sta trigger for TL.
2341 if (fSuccess == TRUE)
2342 {
2343 if (del_idx == 0)
2344 {
2345 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
2346 {
2347 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
2348 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
2349 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
2350
2351 pHddStaCtx->conn_info.staId[valid_idx] = 0;
2352 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
2353 }
2354 }
2355 }
2356 return( fSuccess );
2357}
2358
2359/**============================================================================
2360 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002361 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07002362 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002363
Jeff Johnson295189b2012-06-20 16:38:30 -07002364 ===========================================================================*/
2365static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
2366{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002367 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05302368 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2369 "%s: IBSS Connect Indication from SME!!! "
2370 "Set HDD connState to eConnectionState_IbssConnected",
2371 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002372 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
2373 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
2374
2375 // Save the connection info from CSR...
2376 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
2377
2378 // Send the bssid address to the wext.
2379 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002381 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2382 if (NULL == bss)
2383 {
2384 hddLog(VOS_TRACE_LEVEL_ERROR,
2385 "%s: %s: unable to create IBSS entry",
2386 __func__, pAdapter->dev->name);
2387 return eHAL_STATUS_FAILURE;
2388 }
Yue Maf49ba872013-08-19 12:04:25 -07002389 cfg80211_put_bss(
2390#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2391 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
2392#endif
2393 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07002394
2395 return( eHAL_STATUS_SUCCESS );
2396}
2397/**============================================================================
2398 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05302399 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
2400 suspend related data which was cleared during roaming in FWR.
2401
2402 ===========================================================================*/
2403static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
2404{
2405 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
2406 hdd_adapter_t *pAdapter;
2407 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
2408 ENTER();
2409
2410 spin_lock(&pHddCtx->filter_lock);
2411 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
2412 {
2413 pHddCtx->sus_res_mcastbcast_filter =
2414 pHddCtx->configuredMcastBcastFilter;
2415 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
2416 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
2417 hddLog(VOS_TRACE_LEVEL_INFO,
2418 FL("saving configuredMcastBcastFilter = %d"),
2419 pHddCtx->configuredMcastBcastFilter);
2420 hddLog(VOS_TRACE_LEVEL_INFO,
2421 FL("offload: calling hdd_conf_mcastbcast_filter"));
2422 }
2423 spin_unlock(&pHddCtx->filter_lock);
2424
2425 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
2426 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
2427 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
2428
2429 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
2430 //No need to configure GTK Offload from here because it might possible
2431 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
2432 //be handled as part of cfg80211_set_rekey_data processing.
2433 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
2434 {
2435 pAdapter = pAdapterNode->pAdapter;
2436 if( pAdapter &&
2437 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
2438 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
2439 {
2440 if (pHddCtx->cfg_ini->fhostArpOffload)
2441 {
2442 //Configure ARPOFFLOAD
2443 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
2444 if (!VOS_IS_STATUS_SUCCESS(vstatus))
2445 {
2446 hddLog(VOS_TRACE_LEVEL_ERROR,
2447 FL("Failed to disable ARPOffload Feature %d"), vstatus);
2448 }
2449 }
2450#ifdef WLAN_NS_OFFLOAD
2451 //Configure NSOFFLOAD
2452 if (pHddCtx->cfg_ini->fhostNSOffload)
2453 {
2454 hdd_conf_ns_offload(pAdapter, TRUE);
2455 }
2456#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05302457#ifdef WLAN_FEATURE_PACKET_FILTERING
2458 /* During suspend, configure MC Addr list filter to the firmware
2459 * function takes care of checking necessary conditions before
2460 * configuring.
2461 */
2462 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
2463#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05302464 }
2465 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2466 pAdapterNode = pNext;
2467 }
2468 EXIT();
2469}
2470
2471/**============================================================================
2472 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002474
Jeff Johnson295189b2012-06-20 16:38:30 -07002475 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002476static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2477 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 eCsrRoamResult roamResult )
2479{
2480 eCsrEncryptionType connectedCipherAlgo;
2481 v_BOOL_t fConnected = FALSE;
2482 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2483 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302484 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002485 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302486 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002488
2489 if (NULL == pRoamInfo)
2490 {
2491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2492 return eHAL_STATUS_FAILURE;
2493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002494 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002495 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 // not require upper layer authentication) we can put TL directly into 'authenticated'
2497 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2499 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2500 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002501
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2503 if( fConnected )
2504 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002505 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2506 {
2507 v_U8_t staId;
2508
2509 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2510
2511 if ( 0 == memcmp( pRoamInfo->peerMac,
2512 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2513 {
2514 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2515 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05302516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2517 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002518 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2519 }
2520 else
2521 {
2522 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2523 (v_MACADDR_t*)pRoamInfo->peerMac,
2524 &staId);
2525 if ( VOS_STATUS_SUCCESS == vosStatus )
2526 {
2527 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2528 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2529 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2530 staId);
2531 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2532 }
2533 }
2534 }
2535 else
2536 {
Bhargav Shaha805ef22015-07-29 17:31:38 +05302537 WLANTL_GetSTAState(pHddCtx->pvosContext,
2538 pHddStaCtx->conn_info.staId[0],
2539 &prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302540 // TODO: Considering getting a state machine in HDD later.
2541 // This routine is invoked twice. 1)set PTK 2)set GTK.
2542 // The folloing if statement will be TRUE when setting GTK.
2543 // At this time we don't handle the state in detail.
2544 // Related CR: 174048 - TL not in authenticated state
2545 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2546 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2547 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302548
2549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2550 "for StaId=%d. Changing TL state to AUTHENTICATED from"
2551 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302552
2553 // Connections that do not need Upper layer authentication,
2554 // transition TL to 'Authenticated' state after the keys are set.
2555 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2556 pHddStaCtx->conn_info.staId[ 0 ],
2557 WLANTL_STA_AUTHENTICATED );
2558
2559 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302560
2561 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2562 hdd_postTLPacketPendingInd(pAdapter,
2563 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05302564 //Need to call offload because when roaming happen at that time fwr
2565 //clean offload info as part of the DelBss
2566 // No need to configure offload if host was not suspended
2567 spin_lock(&pHddCtx->filter_lock);
2568 if(pHddCtx->hdd_wlan_suspended)
2569 {
2570 spin_unlock(&pHddCtx->filter_lock);
2571 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2572 }
2573 else
2574 {
2575 spin_unlock(&pHddCtx->filter_lock);
2576 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302577 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2578 {
2579 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2580 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302581 }
2582 else
2583 {
2584 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2585 pHddStaCtx->conn_info.staId[ 0 ]);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302586
2587 /* In case of OSEN move TL to 'Authenticated' after PTK is set */
2588 if (pWextState->roamProfile.bOSENAssociation == VOS_TRUE)
2589 {
2590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "PTK set"
2591 " for StaId=%d. Due to OSEN, Changing TL state to"
2592 "AUTHENTICATED from state:%d",
2593 pHddStaCtx->conn_info.staId[0], prevTLState);
2594
2595 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2596 pHddStaCtx->conn_info.staId[ 0 ],
2597 WLANTL_STA_AUTHENTICATED );
2598
2599 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
2600
2601 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2602 hdd_postTLPacketPendingInd(pAdapter,
2603 pHddStaCtx->conn_info.staId[0]);
2604 }
2605
2606
2607
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302608 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2609 {
2610 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2611 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302612 }
2613
2614 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302617 else
2618 {
2619 // possible disassoc after issuing set key and waiting set key complete
2620 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2621 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002622
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 EXIT();
2624 return( eHAL_STATUS_SUCCESS );
2625}
2626/**============================================================================
2627 *
2628 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2629 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002630static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002632{
Jeff Johnson295189b2012-06-20 16:38:30 -07002633 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2634
2635 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2636 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2637 {
2638 struct iw_michaelmicfailure msg;
2639 union iwreq_data wreq;
2640 memset(&msg, '\0', sizeof(msg));
2641 msg.src_addr.sa_family = ARPHRD_ETHER;
2642 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002643 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2644 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002645
Jeff Johnson295189b2012-06-20 16:38:30 -07002646 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2647 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002648 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 msg.flags = IW_MICFAILURE_PAIRWISE;
2650 memset(&wreq, 0, sizeof(wreq));
2651 wreq.data.length = sizeof(msg);
2652 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002653 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002654 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2656 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2657 NL80211_KEYTYPE_GROUP :
2658 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002659 pRoamInfo->u.pMICFailureInfo->keyId,
2660 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002662
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002664
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 return( eHAL_STATUS_SUCCESS );
2666}
2667
2668/**============================================================================
2669 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002670 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002672
Jeff Johnson295189b2012-06-20 16:38:30 -07002673 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002674static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2675 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002676 eCsrRoamResult roamResult )
2677{
2678 VOS_STATUS vosStatus;
2679
2680 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2681 switch( roamResult )
2682 {
2683 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2684 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002685 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002686 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002687
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002688 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002689 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2690 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2691 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002692 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002693
Nirav Shah7e3c8132015-06-22 23:51:42 +05302694 if ( !roamSaveIbssStation( pAdapter, pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 {
2696 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2697 "New IBSS peer but we already have the max we can handle. Can't register this one" );
2698 break;
2699 }
2700
2701 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2702
Shailender Karmuchia734f332013-04-19 14:02:48 -07002703 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2704 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2705 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2706
2707 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05302708 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002709 pRoamInfo,
2710 pRoamInfo->staId,
2711 (v_MACADDR_t *)pRoamInfo->peerMac,
2712 pRoamInfo->pBssDesc );
2713 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2714 {
2715 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002716 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002717 vosStatus, vosStatus );
2718 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002719 pHddStaCtx->ibss_sta_generation++;
2720 memset(&staInfo, 0, sizeof(staInfo));
2721 staInfo.filled = 0;
2722 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2723
2724 cfg80211_new_sta(pAdapter->dev,
2725 (const u8 *)pRoamInfo->peerMac,
2726 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002727
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002728 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2729 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2730 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2731 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2732 {
2733 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302734
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002735 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2736 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2737
2738 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002739 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002740 pHddStaCtx->ibss_enc_key.encType);
2741
2742 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2743 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2744
2745 if ( VOS_STATUS_SUCCESS != vosStatus )
2746 {
2747 hddLog(VOS_TRACE_LEVEL_ERROR,
2748 "%s: sme_RoamSetKey failed, returned %d",
2749 __func__, vosStatus);
2750 return VOS_STATUS_E_FAILURE;
2751 }
2752 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002753 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302754 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 netif_tx_start_all_queues(pAdapter->dev);
2756 break;
2757 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002758
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2760 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002761
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002763
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002765 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2767 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002768 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002769
Ravi Joshicc57ed42013-10-12 16:31:25 -07002770 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002771 {
2772 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2773 "IBSS peer departed by cannot find peer in our registration table with TL" );
2774 }
2775
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002776 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002777 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2778 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2779 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2780 pRoamInfo->staId );
2781
Katya Nigam47528772015-02-11 12:24:49 +05302782 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002783
2784 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002785 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002786
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002787 cfg80211_del_sta(pAdapter->dev,
2788 (const u8 *)&pRoamInfo->peerMac,
2789 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 break;
2791 }
2792 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2793 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002794 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2795 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302797 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002798 netif_tx_disable(pAdapter->dev);
2799 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302800 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2801 "%s: Set HDD connState to eConnectionState_NotConnected",
2802 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002804
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 // Send the bssid address to the wext.
2806 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2807 // clean up data path
2808 hdd_disconnect_tx_rx(pAdapter);
2809 break;
2810 }
2811 default:
2812 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002813
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002815
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 return( eHAL_STATUS_SUCCESS );
2817}
2818
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002819#ifdef FEATURE_WLAN_TDLS
2820/**============================================================================
2821 *
2822 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2823 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2824 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002825
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002826 ===========================================================================*/
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05302827VOS_STATUS hdd_roamRegisterTDLSSTA(hdd_adapter_t *pAdapter,
2828#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
2829 const tANI_U8 *peerMac,
2830#else
2831 tANI_U8 *peerMac,
2832#endif
2833 tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002834{
2835 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002836 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002837 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2838 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002839 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2840 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002841 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2842 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002843
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002844 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2845 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002846 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002847 "%s not connected. ignored", __func__);
2848 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002849 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002850
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002851 /*
2852 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2853 * be peer MAC, here we are wokrking on direct Link
2854 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002855 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002856
2857 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002858
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002859 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002860 sizeof(tSirMacAddr) );
2861
2862 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2863 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2864
2865 /* set the QoS field appropriately ..*/
2866 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2867 : (staDesc.ucQosEnabled = 0) ;
2868
2869 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002870 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002871
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002872 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002873
2874 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002875 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002876
Shailender Karmuchia734f332013-04-19 14:02:48 -07002877 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002878 * UMA is ready we inform TL to do frame translation.
2879 */
2880 staDesc.ucSwFrameTXXlation = 1;
2881 staDesc.ucSwFrameRXXlation = 1;
2882 staDesc.ucAddRmvLLC = 1;
2883
2884 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002885 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002886
2887 /* tdls Direct Link do not need bcastSig */
2888 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002889
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002890#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2891 if(staDesc.ucProtectedFrame)
2892 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2893 else
2894 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2895#endif
2896
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302897 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002898
Shailender Karmuchia734f332013-04-19 14:02:48 -07002899 /* Register the Station with TL... */
2900 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2901 hdd_rx_packet_cbk,
2902 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002903 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002904
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002905 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2906 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002907 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002908 "%s: WLANTL_RegisterSTAClient() failed to register. "
2909 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002910 return vosStatus;
2911 }
2912
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002913 if ( cfg_param->dynSplitscan &&
2914 ( VOS_TIMER_STATE_RUNNING !=
2915 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2916 {
2917 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2918 cfg_param->trafficMntrTmrForSplitScan);
2919 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002920 return( vosStatus );
2921}
2922
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05302923VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002924{
2925 VOS_STATUS vosStatus;
2926 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2927 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2928 {
2929 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2930 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002931 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002932 __func__, staId, vosStatus, vosStatus );
2933 }
2934 return( vosStatus );
2935}
2936
2937
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002938/*
2939 * HDD interface between SME and TL to ensure TDLS client registration with
2940 * TL in case of new TDLS client is added and deregistration at the time
2941 * TDLS client is deleted.
2942 */
2943
Shailender Karmuchia734f332013-04-19 14:02:48 -07002944eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2945 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002946 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002947 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002948 eCsrRoamResult roamResult)
2949{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002950 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002951 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002952 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002953
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002955 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2956 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2957 "ADD_TDLS_PEER" :
2958 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2959 "DEL_TDLS_PEER" :
2960 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2961 "DEL_TDLS_PEER_IND" :
2962 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2963 "DEL_ALL_TDLS_PEER_IND" :
2964 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2965 "UPDATE_TDLS_PEER" :
2966 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2967 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2968 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002969 switch( roamResult )
2970 {
2971 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2972 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002973 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2974 {
2975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002976 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05302977 wlan_hdd_tdls_check_bmps(pAdapter);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002978 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002979 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002980 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002981
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002982 /* check if there is available index for this new TDLS STA */
2983 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2984 {
2985 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2986 {
2987 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2988 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2989
2990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002991 ("TDLS: STA IDX at %d is %d "
2992 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002993 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002994 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002995
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002996 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002997 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2998 status = eHAL_STATUS_SUCCESS ;
2999 break ;
3000 }
3001 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003002 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003003 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003004 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003005 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3006 "wlan_hdd_tdls_set_sta_id() failed");
3007 return VOS_FALSE;
3008 }
3009
3010 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303011 /* store the ucast signature , if required for further reference. */
3012
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003013 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303014 /* start TDLS client registration with TL */
3015 status = hdd_roamRegisterTDLSSTA( pAdapter,
3016 pRoamInfo->peerMac,
3017 pRoamInfo->staId,
3018 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303019 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003020 }
3021 else
3022 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003023 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003024 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07003025 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003026 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003027 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003028 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003029 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003030 break ;
3031 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003032 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3033 {
3034 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3035 {
3036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3037 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3038 }
3039 /* store the ucast signature which will be used later when
3040 * registering to TL
3041 */
3042 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3043 complete(&pAdapter->tdls_add_station_comp);
3044 break;
3045 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303046 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3047 {
3048 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3049 {
3050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3051 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
3052 }
3053 complete(&pAdapter->tdls_link_establish_req_comp);
3054 break;
3055 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003056 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003057 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003058 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003059 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003060 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003061 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3062 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003063 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003065 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3066
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303067 mutex_lock(&pHddCtx->tdls_lock);
3068 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3069 pRoamInfo->peerMac, FALSE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303070 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003071 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3073 " Current status for peer" MAC_ADDRESS_STR "is %d",
3074 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303075 if (TDLS_IS_CONNECTED(curr_peer) ||
3076 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303077 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303078 mutex_unlock(&pHddCtx->tdls_lock);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303079 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3080 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303081 else
3082 mutex_unlock(&pHddCtx->tdls_lock);
3083
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303084 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003085 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303086 else
3087 mutex_unlock(&pHddCtx->tdls_lock);
3088
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303089 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003090 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303091 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003092
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003093 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3094 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3095 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003096 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003097 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003098 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003099 break ;
3100 }
3101 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003102 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003103 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003104 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003105 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3106 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003107 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003108 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3109 "%s: Sending teardown to supplicant with reason code %u",
3110 __func__, pRoamInfo->reasonCode);
3111
3112#ifdef CONFIG_TDLS_IMPLICIT
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303113 mutex_lock(&pHddCtx->tdls_lock);
3114 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac,
3115 FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003116 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303117 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003118#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003119 status = eHAL_STATUS_SUCCESS ;
3120 break ;
3121 }
3122 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3123 {
3124 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003125 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003126 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003127 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3128 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003129 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003131 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003132 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003133 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303134
3135 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003136 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303137 mutex_unlock(&pHddCtx->tdls_lock);
3138
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003139 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3140 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003141
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003142 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003143 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003144 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3145 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003146
3147 status = eHAL_STATUS_SUCCESS ;
3148 }
3149 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303150 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003151 break ;
3152 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003153 default:
3154 {
3155 break ;
3156 }
3157 }
3158
3159 return status ;
3160}
3161#endif
3162
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05303163void iw_full_power_cbfn (void *pContext, eHalStatus status)
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003164{
3165 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3166 hdd_context_t *pHddCtx = NULL;
3167 int ret;
3168
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303169 ENTER();
3170
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003171 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3172 {
3173 hddLog(VOS_TRACE_LEVEL_ERROR,
3174 "%s: Bad param, pAdapter [%p]",
3175 __func__, pAdapter);
3176 return;
3177 }
3178
3179 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3180 ret = wlan_hdd_validate_context(pHddCtx);
3181 if (0 != ret)
3182 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003183 return;
3184 }
3185
3186 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3187 {
3188 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3189 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303190
3191 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003192}
3193
Shailender Karmuchia734f332013-04-19 14:02:48 -07003194eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3196{
3197 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
3198 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303199 hdd_wext_state_t *pWextState = NULL;
3200 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003201 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07003202 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003203
3204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003205 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003206 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003207
3208 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303209 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003210 {
3211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303212 "invalid adapter or adapter has invalid magic");
3213 return eHAL_STATUS_FAILURE;
3214 }
3215
3216 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3217 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3218
3219 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3220 {
3221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3222 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003223 return eHAL_STATUS_FAILURE;
3224 }
3225
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05303226 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
3227 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003228 switch( roamStatus )
3229 {
3230 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki41d95e22015-08-28 12:51:32 +05303231 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
3232 complete(&pAdapter->session_open_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003234
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003235#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
3236 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07003238 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 * interface down */
3240 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303241 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
3242 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05303243 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003244 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3245 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
3246 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3248 }
3249 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05303250 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 break;
3252
3253 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003254 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07003256 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07003257 // eCSR_ROAM_SHOULD_ROAM will be received.
3258 // Where in we will not mark the link down
3259 // Also we want to stop tx at this point when we will be
3260 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003261 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003262 {
3263 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303264 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303266 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3267 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3268 {
3269 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
3270 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003271 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303272 * Deregister this STA with TL, but do not flush the packets
3273 * for this STA from wmm_tx_queue. Since there is no valid STA
3274 * for these packets they will not be transmitted. Eventually
3275 * after the reassociation is successful, these packets will be
3276 * transmitted after registering STA with TL again. This ensures
3277 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003278 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303279 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
3280 pHddStaCtx->conn_info.staId[0]);
3281 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003282 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303283 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3284 FL("WLANTL_ClearSTAClient failed for staID %d."
3285 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
3286 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003287 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003288 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 }
3290 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003291 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 break;
3293#endif
3294
3295 case eCSR_ROAM_SHOULD_ROAM:
3296 // Dont need to do anything
3297 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 struct net_device *dev = pAdapter->dev;
3299 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3300 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303301 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003303#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 if (pHddStaCtx->ft_carrier_on == FALSE)
3305 {
3306#endif
3307 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003308#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 }
3310#endif
3311
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003312#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07003313 //We should clear all sta register with TL, for now, only one.
3314 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
3315 if ( !VOS_IS_STATUS_SUCCESS(status ) )
3316 {
3317 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3318 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
3319 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003320 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003322#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 }
3324 break;
3325 case eCSR_ROAM_LOSTLINK:
3326 case eCSR_ROAM_DISASSOCIATED:
3327 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3329 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05303330 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003331 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3332 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07003333 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3334 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303335 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07003336 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08003337
3338 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
3339 pHddCtx->configuredMcastBcastFilter =
3340 pHddCtx->sus_res_mcastbcast_filter;
3341 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
3342 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303343
Amar Singhald53568e2013-09-26 11:03:45 -07003344 hddLog(VOS_TRACE_LEVEL_INFO,
3345 "offload: disassociation happening, restoring configuredMcastBcastFilter");
3346 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
3347 pHddCtx->configuredMcastBcastFilter);
3348 hddLog(VOS_TRACE_LEVEL_INFO,
3349 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07003350 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3351 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003352#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303353 /* Call to clear any MC Addr List filter applied after
3354 * successful connection.
3355 */
3356 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003357#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003358 }
3359 break;
3360 case eCSR_ROAM_IBSS_LEAVE:
3361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3362 "****eCSR_ROAM_IBSS_LEAVE****");
3363 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3364 break;
3365 case eCSR_ROAM_ASSOCIATION_COMPLETION:
3366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3367 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303368 // To Do - address probable memory leak with WEP encryption upon successful association
3369 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303371 //Clear saved connection information in HDD
3372 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303374 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003375
3376 break;
3377 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003378 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 pRoamInfo, roamId, roamStatus, roamResult );
3380 break;
3381 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07003382 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
3383 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 break;
3385
3386 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
3387 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003388 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003389
3390 case eCSR_ROAM_MIC_ERROR_IND:
3391 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3392 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05303393 case eCSR_ROAM_LOST_LINK_PARAMS_IND:
3394 {
3395 /*
3396 * The RSSI will be subtracted from 100 as FW is sending the RSSI by
3397 * adding the 100 value.
3398 */
3399 pAdapter->rssi_on_disconnect = pRoamInfo->u.pLostLinkParams->rssi - 100;
3400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3401 "%s : Rssi on Disconnect : %d",
3402 __func__, pAdapter->rssi_on_disconnect);
3403 break;
3404 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003406 {
3407 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3408
3409 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003410 (TRUE == pHddCtx->hdd_wlan_suspended) &&
3411 (eCSR_ROAM_RESULT_NONE == roamResult))
3412 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003413 /* Send DTIM period to the FW; only if the wlan is already
3414 in suspend. This is the case with roaming (reassoc),
3415 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
3416 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
3417 before the ENTER_BMPS_REQ ensures Listen Interval is
3418 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003419 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003420
3421 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003422 if due to unexpected scenario, if we are in BMPS,
3423 then trigger Exit and Enter BMPS to take DTIM period
3424 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003425 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
3426 {
3427 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
3428
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003429 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3430 iw_full_power_cbfn, pAdapter,
3431 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003432 }
3433 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303434
3435 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303436 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
3437 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
3438 (eCSR_ROAM_RESULT_NONE == roamResult))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303439 {
3440 hddLog( LOG1, FL("Device in full power."
3441 "Stop and start traffic timer for roaming"));
3442 pmcStopTrafficTimer(pHddCtx->hHal);
3443 if (pmcStartTrafficTimer(pHddCtx->hHal,
3444 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
3445 {
3446 hddLog(LOGP, FL("Cannot start traffic timer"));
3447 }
3448 }
3449
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003450 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303451 if (eCSR_ROAM_RESULT_NONE == roamResult)
3452 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003454 break;
3455#ifdef WLAN_FEATURE_VOWIFI_11R
3456 case eCSR_ROAM_FT_RESPONSE:
3457 hdd_SendFTEvent(pAdapter);
3458 break;
3459#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07003460#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003461 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003462 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07003463 {
3464 /* Notify the supplicant of a new candidate */
3465 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
3466 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003467 break;
3468#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003469
Yue Maef608272013-04-08 23:09:17 -07003470#ifdef FEATURE_WLAN_LFR_METRICS
3471 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
3472 /* This event is to notify pre-auth initiation */
3473 if (VOS_STATUS_SUCCESS !=
3474 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
3475 {
3476 halStatus = eHAL_STATUS_FAILURE;
3477 }
3478 break;
3479 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
3480 /* This event will notify pre-auth completion in case of success */
3481 if (VOS_STATUS_SUCCESS !=
3482 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3483 pRoamInfo, 1))
3484 {
3485 halStatus = eHAL_STATUS_FAILURE;
3486 }
3487 break;
3488 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
3489 /* This event will notify pre-auth completion in case of failure. */
3490 if (VOS_STATUS_SUCCESS !=
3491 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3492 pRoamInfo, 0))
3493 {
3494 halStatus = eHAL_STATUS_FAILURE;
3495 }
3496 break;
3497 case eCSR_ROAM_HANDOVER_SUCCESS:
3498 /* This event is to notify handover success.
3499 It will be only invoked on success */
3500 if (VOS_STATUS_SUCCESS !=
3501 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
3502 {
3503 halStatus = eHAL_STATUS_FAILURE;
3504 }
3505 break;
3506#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 case eCSR_ROAM_REMAIN_CHAN_READY:
3508 hdd_remainChanReadyHandler( pAdapter );
3509 break;
3510 case eCSR_ROAM_SEND_ACTION_CNF:
3511 hdd_sendActionCnf( pAdapter,
3512 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
3513 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003514#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08003515 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003516 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08003517 roamId, roamStatus, roamResult );
3518 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003519 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
3520 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
3521 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003522#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003523#ifdef WLAN_FEATURE_11W
3524 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
3525 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
3526 pRoamInfo->pbFrames,
3527 pRoamInfo->frameType);
3528 break;
3529#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003530#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003531 case eCSR_ROAM_TSM_IE_IND:
3532 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
3533 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
3534 break;
3535
3536 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
3537 {
3538 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
3539 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
3540 {
3541 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
3542 }
3543 break;
3544 }
3545
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003546 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003547 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003548 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003549 break;
3550 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003551
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003552 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003553 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003554 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003555 break;
3556 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003557#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05303558 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
3559 {
3560 pAdapter->maxRateFlags = roamResult;
3561 break;
3562 }
3563 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07003564 break;
3565 }
3566 return( halStatus );
3567}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003568eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003569{
3570 eCsrAuthType auth_type;
3571 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003572 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 {
3574 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003575 } else
3576 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003577 {
3578 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003579 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003580#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003581 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 {
3583 // Check for 11r FT Authentication with PSK
3584 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003585 } else
3586 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 {
3588 // Check for 11R FT Authentication with 802.1X
3589 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003590 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003591#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003592#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003593 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003594 {
3595 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3596 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003597#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003598#ifdef WLAN_FEATURE_11W
3599 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3600 {
3601 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3602 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303603 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
3604 {
3605 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3606 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003607#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003608 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003609 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3610 }
3611 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003612}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003613
Shailender Karmuchia734f332013-04-19 14:02:48 -07003614eCsrAuthType
3615hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003616{
3617 eCsrAuthType auth_type;
3618 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003619 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003620 {
3621 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003622 } else
3623 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003624 {
3625 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003626 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003627#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003628 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003629 {
3630 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003631 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003632#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003633 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3635 }
3636 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3637 return auth_type;
3638}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003639
Shailender Karmuchia734f332013-04-19 14:02:48 -07003640eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003641hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003642{
3643 eCsrEncryptionType cipher_type;
3644 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003645 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 {
3647 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003648 }
3649 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 {
3651 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003652 }
3653 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 {
3655 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003656 }
3657 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 {
3659 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003660 }
3661 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3662 {
3663 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3664 }
3665 else
3666 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003667 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3668 }
3669 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3670 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003671}
Jeff Johnson295189b2012-06-20 16:38:30 -07003672/* To find if the MAC address is NULL */
3673static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3674{
3675 int i;
3676 for (i = 0; i < length; i++)
3677 {
3678 if (0x00 != (macAddr[i]))
3679 {
3680 return FALSE;
3681 }
3682 }
3683 return TRUE;
3684} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003685
Shailender Karmuchia734f332013-04-19 14:02:48 -07003686eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003687hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003688{
3689 eCsrEncryptionType cipher_type;
3690 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003691 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 {
3693 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003694 } else
3695 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 {
3697 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003698 } else
3699 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003700 {
3701 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003702 } else
3703 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003704 {
3705 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003706 } else
3707 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003709 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3710 } else
3711 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3713 }
3714 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3715 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003716}
Jeff Johnson295189b2012-06-20 16:38:30 -07003717
Shailender Karmuchia734f332013-04-19 14:02:48 -07003718static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3719 struct ether_addr *pBssid,
3720 eCsrEncryptionType *pEncryptType,
3721 eCsrEncryptionType *mcEncryptType,
3722 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003723#ifdef WLAN_FEATURE_11W
3724 u_int8_t *pMfpRequired,
3725 u_int8_t *pMfpCapable,
3726#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003727 u_int16_t gen_ie_len,
3728 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003729{
3730 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003731 eHalStatus result;
3732 tDot11fIERSN dot11RSNIE;
3733 tDot11fIEWPA dot11WPAIE;
3734 tANI_U32 i;
3735 tANI_U8 *pRsnIe;
3736 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003738 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003739
3740 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3741 flag to 0 */
3742 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3743 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3744
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003746 if ( gen_ie[0] == DOT11F_EID_RSN)
3747 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003749 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3751 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303752 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3753 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003754 return -EINVAL;
3755 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003756 // Skip past the EID byte and length byte
3757 pRsnIe = gen_ie + 2;
3758 RSNIeLen = gen_ie_len - 2;
3759 // Unpack the RSN IE
3760 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3761 pRsnIe,
3762 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003764 // Copy out the encryption and authentication types
3765 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003766 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003767 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003768 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003769 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 but probably I suspect we can do something different*/
3771 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003772 // Just translate the FIRST one
3773 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3774 //dot11RSNIE.pwise_cipher_suite_count
3775 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3776 //dot11RSNIE.gp_cipher_suite_count
3777 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003778#ifdef WLAN_FEATURE_11W
3779 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3780 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3781#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003782 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003783 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003785 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003786 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303787 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 break;
3789 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003790 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303792 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003793 break;
3794 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003795 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 // For right now, I assume setASSOCIATE() has passed in the bssid.
3797 vos_mem_copy(PMKIDCache[i].BSSID,
3798 pBssid, ETHER_ADDR_LEN);
3799 vos_mem_copy(PMKIDCache[i].PMKID,
3800 dot11RSNIE.pmkid[i],
3801 CSR_RSN_PMKID_SIZE);
3802 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003803
3804 if (updatePMKCache)
3805 {
3806 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003807 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003808 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003809 // Finally set the PMKSA ID Cache in CSR
3810 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3811 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303812 dot11RSNIE.pmkid_count,
3813 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07003814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 }
3816 else if (gen_ie[0] == DOT11F_EID_WPA)
3817 {
3818 // Validity checks
3819 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3820 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3821 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303822 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3823 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 return -EINVAL;
3825 }
3826 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003827 pRsnIe = gen_ie + 2 + 4;
3828 RSNIeLen = gen_ie_len - (2 + 4);
3829 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003830 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3831 pRsnIe,
3832 RSNIeLen,
3833 &dot11WPAIE);
3834 // Copy out the encryption and authentication types
3835 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003836 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003837 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003838 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003839 //dot11WPAIE.auth_suite_count
3840 // Just translate the FIRST one
3841 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3842 //dot11WPAIE.unicast_cipher_count
3843 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3844 //dot11WPAIE.unicast_cipher_count
3845 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3846 }
3847 else
3848 {
3849 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003850 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 }
3852 return 0;
3853}
3854int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3855{
3856 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3857 v_U32_t status = 0;
3858 eCsrEncryptionType RSNEncryptType;
3859 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003860#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303861 u_int8_t RSNMfpRequired = 0;
3862 u_int8_t RSNMfpCapable = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07003863#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 struct ether_addr bSsid; // MAC address of assoc peer
3865 // MAC address of assoc peer
3866 // But, this routine is only called when we are NOT associated.
3867 vos_mem_copy(bSsid.ether_addr_octet,
3868 pWextState->roamProfile.BSSIDs.bssid,
3869 sizeof(bSsid.ether_addr_octet));
3870 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3871 {
3872 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003873 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 else
3875 {
3876 return 0;
3877 }
3878 // The actual processing may eventually be more extensive than this.
3879 // Right now, just consume any PMKIDs that are sent in by the app.
3880 status = hdd_ProcessGENIE(pAdapter,
3881 &bSsid, // MAC address of assoc peer
3882 &RSNEncryptType,
3883 &mcRSNEncryptType,
3884 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003885#ifdef WLAN_FEATURE_11W
3886 &RSNMfpRequired,
3887 &RSNMfpCapable,
3888#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 pWextState->WPARSNIE[1]+2,
3890 pWextState->WPARSNIE);
3891 if (status == 0)
3892 {
3893 // Now copy over all the security attributes you have parsed out
3894 pWextState->roamProfile.EncryptionType.numEntries = 1;
3895 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003896
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3898 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003899
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003900 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3901 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3902 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3903 {
3904 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3905 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3906 either AES/TKIP based on group cipher configuration
3907 mentioned in the wpa_supplicant.conf.*/
3908
3909 /*Set the unicast cipher same as multicast cipher*/
3910 pWextState->roamProfile.EncryptionType.encryptionType[0]
3911 = mcRSNEncryptType;
3912 }
3913
Chet Lanctot186b5732013-03-18 10:26:30 -07003914#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303915 hddLog( LOG1, FL("RSNMfpRequired = %d, RSNMfpCapable = %d"),
3916 RSNMfpRequired, RSNMfpCapable);
Chet Lanctot186b5732013-03-18 10:26:30 -07003917 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3918 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3919#endif
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303920 hddLog( LOG1,
3921 FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
3922 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 }
3924 return 0;
3925}
3926int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3927{
3928 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3929 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3930 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3931 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003932
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003934 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003935
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 switch( pHddStaCtx->conn_info.authType)
3937 {
3938 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003939#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003940 case eCSR_AUTH_TYPE_CCKM_WPA:
3941 case eCSR_AUTH_TYPE_CCKM_RSN:
3942#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003943 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3944
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003946 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003948
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003949#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003950 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3951 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3952 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003953 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003954 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3955 } else
3956 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003957 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003958 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 } else
3960#endif
3961 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3962 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003963 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3964 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3966 == IW_AUTH_KEY_MGMT_PSK) {
3967 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003968 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003971 }
3972 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003973#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003974 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3975 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3976 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003977 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003978 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003980 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003981 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003982 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 } else
3984#endif
3985
3986#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003987 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3988 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003989 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003990 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003991 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003992 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3994 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003995 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 } else
3997#endif
3998
Chet Lanctot186b5732013-03-18 10:26:30 -07003999#ifdef WLAN_FEATURE_11W
4000 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
4001 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4002 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304003 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
4004 pRoamProfile->AuthType.authType[0] =
4005 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4006 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004007#endif
4008
Shailender Karmuchia734f332013-04-19 14:02:48 -07004009 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004011 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
4012 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4014 == IW_AUTH_KEY_MGMT_PSK) {
4015 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004016 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004017 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004020 break;
4021
Jeff Johnson295189b2012-06-20 16:38:30 -07004022 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004023
4024 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 break;
4026 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004027
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004028#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08004029 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004030#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004031 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
4032 break;
4033 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004034
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004036 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004037
Jeff Johnson295189b2012-06-20 16:38:30 -07004038 EXIT();
4039 return 0;
4040}
4041
4042/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004043
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304044 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07004046 to the CSR roam profile.
4047
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 \param - dev - Pointer to the net device.
4049 - info - Pointer to the iw_request_info.
4050 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004051 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004053
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 --------------------------------------------------------------------------*/
4055
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304056int __iw_set_essid(struct net_device *dev,
4057 struct iw_request_info *info,
4058 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004059{
4060 v_U32_t status = 0;
4061 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304062 hdd_adapter_t *pAdapter;
4063 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 v_U32_t roamId;
4065 tCsrRoamProfile *pRoamProfile;
4066 eMib_dot11DesiredBssType connectedBssType;
4067 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304068 tHalHandle hHal;
4069 hdd_station_ctx_t *pHddStaCtx;
4070 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004071
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304073 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4074 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304077 "%s: Adapter is NULL",__func__);
4078 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 }
4080
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304081 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4082 ret = wlan_hdd_validate_context(pHddCtx);
4083 if (0 != ret)
4084 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304085 return ret;
4086 }
4087
4088 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4089 if (NULL == hHal)
4090 {
4091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4092 "%s: Hal Context is NULL",__func__);
4093 return -EINVAL;
4094 }
4095 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4096 if (NULL == pHddStaCtx)
4097 {
4098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4099 "%s: STA Context is NULL",__func__);
4100 return -EINVAL;
4101 }
4102 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4103 if (NULL == pWextState)
4104 {
4105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4106 "%s: pWextState is NULL",__func__);
4107 return -EINVAL;
4108 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
4110 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
4111 return -EBUSY;
4112 }
4113 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
4114 return -EINVAL;
4115 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004116 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 {
4118 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
4119 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
4120 {
4121 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004122 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4124 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
4125
4126 if(VOS_STATUS_SUCCESS == vosStatus)
4127 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
4128 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4129 }
4130 }
4131 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004132 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 {
4134 return -EINVAL;
4135 }
4136 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004137 /** when cfg80211 defined, wpa_supplicant wext driver uses
4138 zero-length, null-string ssid for force disconnection.
4139 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 driver MUST return success */
4141 if ( 0 == wrqu->essid.length ) {
4142 return 0;
4143 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004144
4145 status = hdd_wmm_get_uapsd_mask(pAdapter,
4146 &pWextState->roamProfile.uapsd_mask);
4147 if (VOS_STATUS_SUCCESS != status)
4148 {
4149 pWextState->roamProfile.uapsd_mask = 0;
4150 }
4151 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004152
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004154
4155 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
4157 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
4158 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004159
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 //set gen ie
4161 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
4162
4163 //set auth
4164 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
4165 }
4166#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004167 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004168 if (pAdapter->wapi_info.nWapiMode)
4169 {
4170 switch (pAdapter->wapi_info.wapiAuthMode)
4171 {
4172 case WAPI_AUTH_MODE_PSK:
4173 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004174 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 pRoamProfile->AuthType.numEntries = 1;
4176 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4177 break;
4178 }
4179 case WAPI_AUTH_MODE_CERT:
4180 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004181 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 pRoamProfile->AuthType.numEntries = 1;
4183 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4184 break;
4185 }
4186 } // End of switch
4187 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
4188 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
4189 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004190 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 pRoamProfile->EncryptionType.numEntries = 1;
4192 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4193 pRoamProfile->mcEncryptionType.numEntries = 1;
4194 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4195 }
4196 }
4197#endif /* FEATURE_WLAN_WAPI */
4198 /* if previous genIE is not NULL, update AssocIE */
4199 if (0 != pWextState->genIE.length)
4200 {
4201 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
4202 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
4203 pWextState->genIE.length);
4204 pWextState->assocAddIE.length = pWextState->genIE.length;
4205 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
4206 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
4207
4208 /* clear previous genIE after use it */
4209 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
4210 }
4211
4212 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
4213 pWextState->roamProfile.bWPSAssociation = FALSE;
4214
4215 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
4216 pWextState->roamProfile.nAddIEAssocLength))
4217 pWextState->roamProfile.bWPSAssociation = TRUE;
4218
4219
4220 // Disable auto BMPS entry by PMC until DHCP is done
4221 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
4222
Shailender Karmuchia734f332013-04-19 14:02:48 -07004223 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004224 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004225
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004226 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
4227 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004228 hdd_select_cbmode(pAdapter,
4229 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
4230 }
Agarwal Ashish40f9b872015-09-01 16:17:35 +05304231 /*
4232 * Change conn_state to connecting before sme_RoamConnect(),
4233 * because sme_RoamConnect() has a direct path to call
4234 * hdd_smeRoamCallback(), which will change the conn_state
4235 * If direct path, conn_state will be accordingly changed
4236 * to NotConnected or Associated by either
4237 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
4238 * in sme_RoamCallback()
4239 * if sme_RomConnect is to be queued,
4240 * Connecting state will remain until it is completed.
4241 *
4242 * If connection state is not changed,
4243 * connection state will remain in eConnectionState_NotConnected state.
4244 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
4245 * if conn state is eConnectionState_NotConnected.
4246 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
4247 * informed of connect result indication which is an issue.
4248 */
4249 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
4250 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
4251 {
4252 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4253 FL("Set HDD connState to eConnectionState_Connecting"));
4254 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
4255 eConnectionState_Connecting);
4256 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004257 status = sme_RoamConnect( hHal,pAdapter->sessionId,
4258 &(pWextState->roamProfile), &roamId);
Agarwal Ashish40f9b872015-09-01 16:17:35 +05304259
4260 if ((eHAL_STATUS_SUCCESS != status) &&
4261 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
4262 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4263 {
4264 hddLog(VOS_TRACE_LEVEL_ERROR,
4265 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
4266 pAdapter->sessionId, status);
4267 /* change back to NotAssociated */
4268 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
4269 eConnectionState_NotConnected);
4270 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004271 pRoamProfile->ChannelInfo.ChannelList = NULL;
4272 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004273
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004274 EXIT();
4275 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004276}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004277
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304278int iw_set_essid(struct net_device *dev,
4279 struct iw_request_info *info,
4280 union iwreq_data *wrqu, char *extra)
4281{
4282 int ret;
4283
4284 vos_ssr_protect(__func__);
4285 ret = __iw_set_essid(dev, info, wrqu, extra);
4286 vos_ssr_unprotect(__func__);
4287
4288 return ret;
4289}
4290
Jeff Johnson295189b2012-06-20 16:38:30 -07004291/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004292
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304293 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004295
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 \param - dev - Pointer to the net device.
4297 - info - Pointer to the iw_request_info.
4298 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004299 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004300 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004301
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304303int __iw_get_essid(struct net_device *dev,
4304 struct iw_request_info *info,
4305 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004306{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304307 hdd_adapter_t *pAdapter;
4308 hdd_context_t *pHddCtx;
4309 hdd_wext_state_t *wextBuf;
4310 hdd_station_ctx_t *pHddStaCtx;
4311 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304312
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 ENTER();
4314
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304315 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4316 if (NULL == pAdapter)
4317 {
4318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4319 "%s: Adapter is NULL",__func__);
4320 return -EINVAL;
4321 }
4322
4323 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4324 ret = wlan_hdd_validate_context(pHddCtx);
4325 if (0 != ret)
4326 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304327 return ret;
4328 }
4329
4330 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4331 if (NULL == pHddStaCtx)
4332 {
4333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4334 "%s: STA Context is NULL",__func__);
4335 return -EINVAL;
4336 }
4337
4338 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4339 if (NULL == wextBuf)
4340 {
4341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4342 "%s: wextBuf is NULL",__func__);
4343 return -EINVAL;
4344 }
4345
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
4347 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
4348 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
4349 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
4350 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
4351 {
4352 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
4353 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
4354 dwrq->flags = 1;
4355 } else {
4356 memset(extra, 0, dwrq->length);
4357 dwrq->length = 0;
4358 dwrq->flags = 0;
4359 }
4360 EXIT();
4361 return 0;
4362}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304363
4364int iw_get_essid(struct net_device *dev,
4365 struct iw_request_info *info,
4366 struct iw_point *dwrq, char *extra)
4367{
4368 int ret;
4369
4370 vos_ssr_protect(__func__);
4371 ret = __iw_get_essid(dev, info, dwrq, extra);
4372 vos_ssr_unprotect(__func__);
4373
4374 return ret;
4375}
Jeff Johnson295189b2012-06-20 16:38:30 -07004376/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004377
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304378 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004380
Jeff Johnson295189b2012-06-20 16:38:30 -07004381 \param - dev - Pointer to the net device.
4382 - info - Pointer to the iw_request_info.
4383 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004384 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004385 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004386
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304388int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
4389 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004390{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304391 hdd_adapter_t *pAdapter;
4392 hdd_context_t *pHddCtx;
4393 hdd_wext_state_t *pWextState;
4394 hdd_station_ctx_t *pHddStaCtx;
4395 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004396 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07004397 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304398 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004399
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004401
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304402 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4403 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004404 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4406 "%s: Adapter is NULL",__func__);
4407 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004408 }
4409
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304410 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4411 ret = wlan_hdd_validate_context(pHddCtx);
4412 if (0 != ret)
4413 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304414 return ret;
4415 }
4416
4417 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4418 if (NULL == pHddStaCtx)
4419 {
4420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4421 "%s: STA Context is NULL",__func__);
4422 return -EINVAL;
4423 }
4424
4425 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4426 if (NULL == pWextState)
4427 {
4428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4429 "%s: pWextState is NULL",__func__);
4430 return -EINVAL;
4431 }
4432
4433 pRoamProfile = &pWextState->roamProfile;
4434
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 switch(wrqu->param.flags & IW_AUTH_INDEX)
4436 {
4437 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004438
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004440
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004442
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 case IW_AUTH_CIPHER_PAIRWISE:
4444 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004445 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004448 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4449 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
4452 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004453 }
4454
Jeff Johnson295189b2012-06-20 16:38:30 -07004455 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004456
4457 if( (IW_AUTH_KEY_MGMT_802_1X
4458 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
4460 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004461 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 else
4463 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004464 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004467
4468 if( ( IW_AUTH_KEY_MGMT_802_1X
4469 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4471 /*Dynamic WEP key*/
4472 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4473 else
4474 /*Static WEP key*/
4475 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004476
Jeff Johnson295189b2012-06-20 16:38:30 -07004477 }
4478 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004479
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004481 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 return -EINVAL;
4483 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004484
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 pRoamProfile->EncryptionType.numEntries = 1;
4486 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 break;
4489 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004490 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
4492 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4493 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004494
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4496 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
4497 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004498
4499 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
4501 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004502
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004504
4505 if( ( IW_AUTH_KEY_MGMT_802_1X
4506 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
4507 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4508
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004510
4511 else
4512 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004514
4515 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
4516 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004518 if( ( IW_AUTH_KEY_MGMT_802_1X
4519 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4521 {
4522 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4523 }
4524 else
4525 {
4526 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4527 }
4528 }
4529 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004530
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004532 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 return -EINVAL;
4534 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004535
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 pRoamProfile->mcEncryptionType.numEntries = 1;
4537 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
4538 }
4539 break;
4540
4541 case IW_AUTH_80211_AUTH_ALG:
4542 {
4543 /*Save the auth algo here and set auth type to SME Roam profile
4544 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004545 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07004546 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004547
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
4549 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
4550
4551 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
4552 /*Not supported*/
4553 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4554 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4555 }
4556 break;
4557
4558 case IW_AUTH_KEY_MGMT:
4559 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004560#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004561#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
4562 /*Check for CCKM AKM type */
4563 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004564 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
4565 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004566 /* Set the CCKM bit in authKeyMgmt */
4567 /* Right now, this breaks all ref to authKeyMgmt because our
4568 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 */
4570 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
4571 /*Set the key management to 802.1X*/
4572 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004573 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4575 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
4576 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
4577 /*Save the key management*/
4578 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
4579 //pWextState->authKeyMgmt = wrqu->param.value;
4580 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4581 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4582 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
4583 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
4584 /*Save the key management anyway*/
4585 pWextState->authKeyMgmt = wrqu->param.value;
4586 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
4587 /*Save the key management*/
4588 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
4589 //pWextState->authKeyMgmt = wrqu->param.value;
4590 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4591 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4592 }
4593#else
4594 /*Save the key management*/
4595 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004596#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 }
4598 break;
4599
4600 case IW_AUTH_TKIP_COUNTERMEASURES:
4601 {
4602 if(wrqu->param.value) {
4603 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4604 "Counter Measure started %d", wrqu->param.value);
4605 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
4606 }
4607 else {
4608 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4609 "Counter Measure stopped=%d", wrqu->param.value);
4610 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4611 }
4612 }
4613 break;
4614 case IW_AUTH_DROP_UNENCRYPTED:
4615 case IW_AUTH_WPA_ENABLED:
4616 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
4617 case IW_AUTH_ROAMING_CONTROL:
4618 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004619
Jeff Johnson295189b2012-06-20 16:38:30 -07004620 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004621
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004622 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004623 wrqu->param.flags & IW_AUTH_INDEX);
4624 break;
4625 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004626
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 EXIT();
4628 return 0;
4629}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304630
4631int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
4632 union iwreq_data *wrqu, char *extra)
4633{
4634 int ret;
4635
4636 vos_ssr_protect(__func__);
4637 ret = __iw_set_auth(dev, info, wrqu, extra);
4638 vos_ssr_unprotect(__func__);
4639
4640 return ret;
4641}
4642
Jeff Johnson295189b2012-06-20 16:38:30 -07004643/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004644
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304645 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004646 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004647
Jeff Johnson295189b2012-06-20 16:38:30 -07004648 \param - dev - Pointer to the net device.
4649 - info - Pointer to the iw_request_info.
4650 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004651 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004653
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304655int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4656 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004657{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304658 hdd_adapter_t* pAdapter;
4659 hdd_wext_state_t *pWextState;
4660 tCsrRoamProfile *pRoamProfile;
4661 hdd_context_t *pHddCtx;
4662 int ret = 0;
4663
Jeff Johnson295189b2012-06-20 16:38:30 -07004664 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004665
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304666 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4667 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004668 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4670 "%s: Adapter is NULL",__func__);
4671 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004672 }
4673
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304674 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4675 ret = wlan_hdd_validate_context(pHddCtx);
4676 if (0 != ret)
4677 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304678 return ret;
4679 }
4680
4681 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4682 if (NULL == pWextState)
4683 {
4684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4685 "%s: pWextState is NULL",__func__);
4686 return -EINVAL;
4687 }
4688 pRoamProfile = &pWextState->roamProfile;
4689
Jeff Johnson295189b2012-06-20 16:38:30 -07004690 switch(pRoamProfile->negotiatedAuthType)
4691 {
4692 case eCSR_AUTH_TYPE_WPA_NONE:
4693 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4694 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
4695 break;
4696 case eCSR_AUTH_TYPE_WPA:
4697 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4698 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
4699 break;
4700#ifdef WLAN_FEATURE_VOWIFI_11R
4701 case eCSR_AUTH_TYPE_FT_RSN:
4702#endif
4703 case eCSR_AUTH_TYPE_RSN:
4704 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4705 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
4706 break;
4707 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4708 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4709 break;
4710 case eCSR_AUTH_TYPE_SHARED_KEY:
4711 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
4712 break;
4713 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004714 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4716 break;
4717 case eCSR_AUTH_TYPE_AUTOSWITCH:
4718 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4719 break;
4720 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304721 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004722 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4723 return -EIO;
4724#ifdef WLAN_FEATURE_VOWIFI_11R
4725 case eCSR_AUTH_TYPE_FT_RSN_PSK:
4726#endif
4727 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07004728#ifdef WLAN_FEATURE_11W
4729 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05304730 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07004731#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05304732 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004733 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4734 return -EIO;
4735 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304736 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4738 return -EIO;
4739 }
4740 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
4741 {
4742 switch(pRoamProfile->negotiatedUCEncryptionType)
4743 {
4744 case eCSR_ENCRYPT_TYPE_NONE:
4745 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4746 break;
4747 case eCSR_ENCRYPT_TYPE_WEP40:
4748 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4749 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4750 break;
4751 case eCSR_ENCRYPT_TYPE_TKIP:
4752 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4753 break;
4754 case eCSR_ENCRYPT_TYPE_WEP104:
4755 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4756 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4757 break;
4758 case eCSR_ENCRYPT_TYPE_AES:
4759 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4760 break;
4761 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304762 hddLog(LOG1, "%s called with unknown auth type %d ",
4763 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004764 return -EIO;
4765 }
4766 }
4767
Shailender Karmuchia734f332013-04-19 14:02:48 -07004768 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 {
4770 switch(pRoamProfile->negotiatedMCEncryptionType)
4771 {
4772 case eCSR_ENCRYPT_TYPE_NONE:
4773 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4774 break;
4775 case eCSR_ENCRYPT_TYPE_WEP40:
4776 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4777 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4778 break;
4779 case eCSR_ENCRYPT_TYPE_TKIP:
4780 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4781 break;
4782 case eCSR_ENCRYPT_TYPE_WEP104:
4783 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4784 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4785 break;
4786 case eCSR_ENCRYPT_TYPE_AES:
4787 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4788 break;
4789 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304790 hddLog(LOG1, "%s called with unknown auth type %d ",
4791 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004792 return -EIO;
4793 }
4794 }
4795
4796 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004797 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004798 EXIT();
4799 return 0;
4800}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304801
4802int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4803 union iwreq_data *wrqu,char *extra)
4804{
4805 int ret;
4806
4807 vos_ssr_protect(__func__);
4808 ret = __iw_get_auth(dev, info, wrqu, extra);
4809 vos_ssr_unprotect(__func__);
4810
4811 return ret;
4812}
4813
Jeff Johnson295189b2012-06-20 16:38:30 -07004814/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004815
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304816 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07004817 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004818 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004819
Jeff Johnson295189b2012-06-20 16:38:30 -07004820 \param - dev - Pointer to the net device.
4821 - info - Pointer to the iw_request_info.
4822 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004823 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004824 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004825
Jeff Johnson295189b2012-06-20 16:38:30 -07004826 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304827int __iw_set_ap_address(struct net_device *dev,
4828 struct iw_request_info *info,
4829 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004830{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304831 hdd_station_ctx_t *pHddStaCtx;
4832 hdd_adapter_t *pAdapter;
4833 hdd_context_t *pHddCtx;
4834 v_U8_t *pMacAddress = NULL;
4835 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304836
Jeff Johnson295189b2012-06-20 16:38:30 -07004837 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304838
4839 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4840 if (NULL == pAdapter)
4841 {
4842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4843 "%s: Adapter is NULL", __func__);
4844 return -EINVAL;
4845 }
4846 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4847 ret = wlan_hdd_validate_context(pHddCtx);
4848 if (0 != ret)
4849 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304850 return ret;
4851 }
4852 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4853 if (NULL == pHddStaCtx)
4854 {
4855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4856 "%s: pHddStaCtx is NULL", __func__);
4857 return -EINVAL;
4858 }
4859
Jeff Johnson295189b2012-06-20 16:38:30 -07004860 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4862 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07004864
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304865 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004866 return 0;
4867}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304868
4869int iw_set_ap_address(struct net_device *dev,
4870 struct iw_request_info *info,
4871 union iwreq_data *wrqu, char *extra)
4872{
4873 int ret;
4874
4875 vos_ssr_protect(__func__);
4876 ret = __iw_set_ap_address(dev, info, wrqu, extra);
4877 vos_ssr_unprotect(__func__);
4878
4879 return ret;
4880}
4881
Jeff Johnson295189b2012-06-20 16:38:30 -07004882/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004883
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304884 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 This function returns the BSSID to the wpa_supplicant
4886 \param - dev - Pointer to the net device.
4887 - info - Pointer to the iw_request_info.
4888 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004889 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004890 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004891
Jeff Johnson295189b2012-06-20 16:38:30 -07004892 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304893int __iw_get_ap_address(struct net_device *dev,
4894 struct iw_request_info *info,
4895 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004896{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304897 hdd_station_ctx_t *pHddStaCtx;
4898 hdd_adapter_t *pAdapter;
4899 hdd_context_t *pHddCtx;
4900 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304901
Jeff Johnson295189b2012-06-20 16:38:30 -07004902 ENTER();
4903
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304904 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4905 if (NULL == pAdapter)
4906 {
4907 hddLog(VOS_TRACE_LEVEL_ERROR,
4908 "%s: Adapter is NULL", __func__);
4909 return -EINVAL;
4910 }
4911 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4912 ret = wlan_hdd_validate_context(pHddCtx);
4913 if (0 != ret)
4914 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304915 return ret;
4916 }
4917 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4918 if (NULL == pHddStaCtx)
4919 {
4920 hddLog(VOS_TRACE_LEVEL_ERROR,
4921 "%s: pHddStaCtx is NULL", __func__);
4922 return -EINVAL;
4923 }
4924
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4926 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4927 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004928 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004929 }
4930 else
4931 {
4932 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4933 }
4934 EXIT();
4935 return 0;
4936}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004937
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304938int iw_get_ap_address(struct net_device *dev,
4939 struct iw_request_info *info,
4940 union iwreq_data *wrqu, char *extra)
4941{
4942 int ret;
4943
4944 vos_ssr_protect(__func__);
4945 ret = __iw_get_ap_address(dev, info, wrqu, extra);
4946 vos_ssr_unprotect(__func__);
4947
4948 return ret;
4949}
4950
Chet Lanctot186b5732013-03-18 10:26:30 -07004951#ifdef WLAN_FEATURE_11W
4952/**---------------------------------------------------------------------------
4953
4954 \brief hdd_indicateUnprotMgmtFrame -
4955 This function forwards the unprotected management frame to the supplicant
4956 \param - pAdapter - Pointer to HDD adapter
4957 - nFrameLength - Length of the unprotected frame being passed
4958 - pbFrames - Pointer to the frame buffer
4959 - frameType - 802.11 frame type
4960 \return - nothing
4961
4962 --------------------------------------------------------------------------*/
4963void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4964 tANI_U32 nFrameLength,
4965 tANI_U8* pbFrames,
4966 tANI_U8 frameType )
4967{
4968 tANI_U8 type = 0;
4969 tANI_U8 subType = 0;
4970
4971 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4972 __func__, frameType, nFrameLength);
4973
4974 /* Sanity Checks */
4975 if (NULL == pAdapter)
4976 {
4977 hddLog( LOGE, FL("pAdapter is NULL"));
4978 return;
4979 }
4980
4981 if (NULL == pAdapter->dev)
4982 {
4983 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4984 return;
4985 }
4986
4987 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4988 {
4989 hddLog( LOGE, FL("pAdapter has invalid magic"));
4990 return;
4991 }
4992
4993 if( !nFrameLength )
4994 {
4995 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4996 return;
4997 }
4998
4999 if (NULL == pbFrames) {
5000 hddLog( LOGE, FL("pbFrames is NULL"));
5001 return;
5002 }
5003
5004 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
5005 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
5006
5007 /* Get pAdapter from Destination mac address of the frame */
5008 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
5009 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305010#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5011 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5012#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005013 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305014#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005015 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
5016 }
5017 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
5018 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305019#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5020 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5021#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005022 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305023#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005024 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
5025 }
5026 else
5027 {
5028 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
5029 return;
5030 }
5031}
5032#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005033
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005034#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005035void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
5036 tANI_U8 state,
5037 tANI_U16 measInterval )
5038{
5039 union iwreq_data wrqu;
5040 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005041 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005042
5043 if (NULL == pAdapter)
5044 return;
5045
5046 // create the event
5047 memset(&wrqu, '\0', sizeof(wrqu));
5048 memset(buf, '\0', sizeof(buf));
5049
5050 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
5051 tid, state, measInterval);
5052
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005053 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005054
5055 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005056 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005057 // send the event
5058 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5059}
5060
5061void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
5062{
5063 union iwreq_data wrqu;
5064 char buf[IW_CUSTOM_MAX + 1];
5065 char *pos = buf;
5066 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5067
5068 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5069 return;
5070
5071 // create the event
5072 memset(&wrqu, '\0', sizeof(wrqu));
5073 memset(buf, '\0', sizeof(buf));
5074
5075 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305076 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
5077 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
5078 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
5079 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005080
5081 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
5082 pos += nBytes;
5083 freeBytes -= nBytes;
5084
5085 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
5086 pos += WNI_CFG_BSSID_LEN;
5087 freeBytes -= WNI_CFG_BSSID_LEN;
5088
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005089 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
5090 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005091
5092 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005093 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005094
5095 // send the event
5096 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5097}
5098
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005099void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005100{
5101 union iwreq_data wrqu;
5102 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005103 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005104
5105 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5106 return;
5107
5108 // create the event
5109 memset(&wrqu, '\0', sizeof(wrqu));
5110 memset(buf, '\0', sizeof(buf));
5111
5112 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
5113
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005114 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005115
5116 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005117 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005118
5119 // send the event
5120 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5121}
5122
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005123void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
5124 const tANI_U16 measurementToken,
5125 const tANI_BOOLEAN flag,
5126 const tANI_U8 numBss)
5127{
5128 union iwreq_data wrqu;
5129 char buf[IW_CUSTOM_MAX];
5130 char *pos = buf;
5131 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5132
5133 memset(&wrqu, '\0', sizeof(wrqu));
5134 memset(buf, '\0', sizeof(buf));
5135
5136 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
5137 numBss);
5138
5139 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
5140 flag, numBss);
5141
5142 wrqu.data.pointer = buf;
5143 wrqu.data.length = nBytes;
5144 // send the event
5145 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5146}
5147
5148
5149static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005150 const tCsrRoamInfo *pRoamInfo)
5151{
5152 union iwreq_data wrqu;
5153 char buf[IW_CUSTOM_MAX + 1];
5154 char *pos = buf;
5155 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5156 tANI_U8 i = 0, len = 0;
5157 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
5158 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005159 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
5160 tANI_U8 ieLenByte = 1;
5161 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
5162#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005163
5164 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5165 return;
5166
5167 /* Custom event can pass maximum of 256 bytes of data,
5168 based on the IE len we need to identify how many BSS info can
5169 be filled in to custom event data */
5170 /*
5171 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
5172 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
5173 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
5174 */
5175
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005176 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005177 {
5178 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
5179 /* If the measurement is none and no scan results found,
5180 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005181 hdd_indicateEseBcnReportNoResults(pAdapter,
5182 pRoamInfo->pEseBcnReportRsp->measurementToken,
5183 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005184 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005185 }
5186 else
5187 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005188 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005189 {
5190 memset(&wrqu, '\0', sizeof(wrqu));
5191 memset(buf, '\0', sizeof(buf));
5192 tot_bcn_ieLen = 0;
5193 sendBss = 0;
5194 pos = buf;
5195 freeBytes = IW_CUSTOM_MAX;
5196
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005197 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005198 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005199 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
5200 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005201 {
5202 break;
5203 }
5204 tot_bcn_ieLen += len;
5205 sendBss++;
5206 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
5207 "IeLength(%d) Length of Ie(%d) totLen(%d)",
5208 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005209 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005210 tot_bcn_ieLen);
5211 }
5212
5213 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
5214 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005215 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5216 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005217
5218 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005219 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5220 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005221 pos += nBytes;
5222 freeBytes -= nBytes;
5223
5224 /* Copy total Beacon report data length */
5225 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
5226 pos += sizeof(tot_bcn_ieLen);
5227 freeBytes -= sizeof(tot_bcn_ieLen);
5228
5229 for (i = 0; i < sendBss; i++)
5230 {
5231 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305232 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
5233 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005234 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005235 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
5236 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
5237 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
5238 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
5239 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
5240 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
5241 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
5242 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
5243 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
5244 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
5245 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
5246 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
5247 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
5248 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
5249 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
5250 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005251
5252 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005253 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
5254 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005255 pos += len;
5256 freeBytes -= len;
5257
5258 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005259 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005260 vos_mem_copy(pos, (char*)&len, sizeof(len));
5261 pos += sizeof(len);
5262 freeBytes -= sizeof(len);
5263
5264 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005265 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005266 pos += len;
5267 freeBytes -= len;
5268 }
5269
5270 wrqu.data.pointer = buf;
5271 wrqu.data.length = strlen(buf);
5272
5273 // send the event
5274 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5275 lastSent += sendBss;
5276 }
5277 }
5278}
5279
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005280#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005281