blob: 4fc44c2557a4ef809d5302243bbbd8a253914c32 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05302 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028/**========================================================================
29
30 \file wlan_hdd_assoc.c
31 \brief WLAN Host Device Driver implementation
Shailender Karmuchia734f332013-04-19 14:02:48 -070032
Jeff Johnson295189b2012-06-20 16:38:30 -070033 ========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070034/**=========================================================================
35 EDIT HISTORY FOR FILE
36
37
38 This section contains comments describing changes made to the module.
39 Notice that changes are listed in reverse chronological order.
40
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070046 -------- --- --------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -070047 05/06/09 Shailender Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070048 ==========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070049
Jeff Johnson295189b2012-06-20 16:38:30 -070050#include "wlan_hdd_includes.h"
51#include <aniGlobal.h>
52#include "dot11f.h"
53#include "wlan_nlink_common.h"
54#include "wlan_btc_svc.h"
55#include "wlan_hdd_power.h"
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +053056#include "wlan_hdd_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070057#include <linux/ieee80211.h>
58#include <linux/wireless.h>
59#include <net/cfg80211.h>
60#include "wlan_hdd_cfg80211.h"
61#include "csrInsideApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include "wlan_hdd_p2p.h"
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053063#include <vos_sched.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080064#include "wlan_hdd_tdls.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "sme_Api.h"
Sushant Kaushikba6764e2014-06-30 19:52:09 +053066#include "wlan_hdd_hostapd.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053067#include "vos_utils.h"
Siddharth Bhalda0d1622015-04-24 15:47:49 +053068#include <wlan_hdd_wext.h>
Mukul Sharma84f27252014-07-14 18:11:42 +053069
Jeff Johnson295189b2012-06-20 16:38:30 -070070v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
71
Shailender Karmuchia734f332013-04-19 14:02:48 -070072struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -070073{
74 u_char ether_addr_octet[6];
75};
76// These are needed to recognize WPA and RSN suite types
77#define HDD_WPA_OUI_SIZE 4
78v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
79v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
80v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
81v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
82v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
83v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080084#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070085v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080086#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070087#define HDD_RSN_OUI_SIZE 4
88v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
89v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
90v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
91v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
92v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
93v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080094#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070095v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080096#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -070097#ifdef WLAN_FEATURE_11W
98v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053099/* RSN-8021X-SHA256 */
100v_U8_t ccpRSNOui08[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 };
Chet Lanctot186b5732013-03-18 10:26:30 -0700101#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700102
Shailender Karmuchia734f332013-04-19 14:02:48 -0700103#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700104// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700105#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
106#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700107#endif
108
109#define BEACON_FRAME_IES_OFFSET 12
110
Chet Lanctot186b5732013-03-18 10:26:30 -0700111#ifdef WLAN_FEATURE_11W
112void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
113 tANI_U32 nFrameLength,
114 tANI_U8* pbFrames,
115 tANI_U8 frameType );
116#endif
117
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800118#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700119static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
120 tANI_U8 state,
121 tANI_U16 measInterval );
122static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800123static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
124static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700125
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800126#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700127
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530128static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
129 tCsrRoamInfo *pRoamInfo,
130 tANI_U32 roamId,
131 eRoamCmdStatus roamStatus,
132 eCsrRoamResult roamResult );
133
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530134v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
135 eConnectionState connState )
136{
137 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530138 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
139 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700140 pHddStaCtx->conn_info.connState = connState;
141}
142
143// returns FALSE if not connected.
144// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
145// returns the connection state. Can specify NULL if you dont' want to get the actual state.
146
Shailender Karmuchia734f332013-04-19 14:02:48 -0700147static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
148 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700149{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700150 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700152
Jeff Johnson295189b2012-06-20 16:38:30 -0700153 // get the connection state.
154 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700155 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700157 eConnectionState_IbssConnected == connState ||
158 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 {
160 fConnected = VOS_TRUE;
161 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700162 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 {
164 fConnected = VOS_FALSE;
165 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700166
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 if ( pConnState )
168 {
169 *pConnState = connState;
170 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700171
Jeff Johnson295189b2012-06-20 16:38:30 -0700172 return( fConnected );
173}
174
175v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
176{
177 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700178}
Jeff Johnson295189b2012-06-20 16:38:30 -0700179
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530180eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
181{
182 v_U8_t staChannel = 0;
183
184 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
185 {
186 staChannel = pHddStaCtx->conn_info.operationChannel;
187 }
188
189 if ( staChannel > 0 && staChannel < 14 )
190 return eCSR_BAND_24;
191 else if (staChannel >= 36 && staChannel <= 165 )
192 return eCSR_BAND_5G;
193 else /* If station is not connected return as eCSR_BAND_ALL */
194 return eCSR_BAND_ALL;
195}
196
197
Jeff Johnson295189b2012-06-20 16:38:30 -0700198//TODO - Not used anyhwere. Can be removed.
199#if 0
200//
201v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
202{
203 v_BOOL_t fConnectedInfra = FALSE;
204 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700205
Jeff Johnson295189b2012-06-20 16:38:30 -0700206 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700207 {
208 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700209 {
210 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700211 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700212 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700213
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 return( fConnectedInfra );
215}
216#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700217
Jeff Johnson295189b2012-06-20 16:38:30 -0700218static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
219{
220 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700221
Jeff Johnson295189b2012-06-20 16:38:30 -0700222 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700223
224 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700225 {
226 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
227 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700228
Jeff Johnson295189b2012-06-20 16:38:30 -0700229 return( fConnected );
230}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700231
Jeff Johnson295189b2012-06-20 16:38:30 -0700232inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
233{
234 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700235
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700237
238 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 {
240 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
241 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700242
Jeff Johnson295189b2012-06-20 16:38:30 -0700243 return( fConnected );
244}
245
246static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
247{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700248 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700249 {
250 case eCSR_BSS_TYPE_INFRASTRUCTURE:
251 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
252 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700253
Jeff Johnson295189b2012-06-20 16:38:30 -0700254 case eCSR_BSS_TYPE_IBSS:
255 case eCSR_BSS_TYPE_START_IBSS:
256 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
257 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700258
259 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700260 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700261 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700262 default:
263 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700264 break;
265 }
266
Jeff Johnson295189b2012-06-20 16:38:30 -0700267}
268
269void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
270{
271 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
272 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700273
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700275
276 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700277 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700278 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700279 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
280 {
281 VOS_ASSERT( pRoamInfo->pBssDesc );
282 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
283
284 // Save the Station ID for this station from the 'Roam Info'.
285 //For IBSS mode, staId is assigned in NEW_PEER_IND
286 //For reassoc, the staID doesn't change and it may be invalid in this structure
287 //so no change here.
288 if( !pRoamInfo->fReassocReq )
289 {
290 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
291 }
292 }
293 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700294 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700295 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700296 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 else
298 {
299 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
300 // or we can't function.
301 VOS_ASSERT( 0 );
302 }
303
304 // notify WMM
305 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
306
307 if( !pRoamInfo->u.pConnectedProfile )
308 {
309 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
310 }
311 else
312 {
313 // Get Multicast Encryption Type
314 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
315 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
316 // Get Unicast Encrytion Type
317 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
318 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
319
320 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
321
322 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
323
324 // Save the ssid for the connection
325 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530326
327 // Save dot11mode in which STA associated to AP
328 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Deepthi Gowriae6a1662015-10-12 12:59:37 +0530329
330 pHddStaCtx->conn_info.rate_flags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700332 }
333
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700335 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
336
Jeff Johnson295189b2012-06-20 16:38:30 -0700337}
338
339#if defined(WLAN_FEATURE_VOWIFI_11R)
340/*
341 * Send the 11R key information to the supplicant.
342 * Only then can the supplicant generate the PMK-R1.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800343 * (BTW, the ESE supplicant also needs the Assoc Resp IEs
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 * for the same purpose.)
345 *
346 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
347 * this contains the R1KHID, R0KHID and the MDID.
348 * For FT, this consists of the Reassoc Rsp FTIEs.
349 * This is the Assoc Response.
350 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700351static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 tCsrRoamInfo *pCsrRoamInfo)
353{
354 union iwreq_data wrqu;
355 char *buff;
356 unsigned int len = 0;
357 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700358
359 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700360 {
361 hddLog(LOGE,
362 "%s: pCsrRoamInfo->nAssocRspLength=%d",
363 __func__, (int)pCsrRoamInfo->nAssocRspLength);
364 return;
365 }
366
Shailender Karmuchia734f332013-04-19 14:02:48 -0700367 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700368 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700369 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700370 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700371 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 return;
373 }
374
375 // pFTAssocRsp needs to point to the IEs
376 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
377 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
378 (unsigned int)pFTAssocRsp[0],
379 (unsigned int)pFTAssocRsp[1]);
380
381 // We need to send the IEs to the supplicant.
382 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700383 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700385 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700386 return;
387 }
388
389 // Send the Assoc Resp, the supplicant needs this for initial Auth.
390 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700391 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700393 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
395
396 kfree(buff);
397}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700398#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700399
400#ifdef WLAN_FEATURE_VOWIFI_11R
401
402/*---------------------------------------------------
403 *
404 * Send the FTIEs, RIC IEs during FT. This is eventually
405 * used to send the FT events to the supplicant
406 *
407 * At the reception of Auth2 we send the RIC followed
408 * by the auth response IEs to the supplicant.
409 * Once both are received in the supplicant, an FT
410 * event is generated to the supplicant.
411 *
412 *---------------------------------------------------
413 */
414void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
415{
Jeff Johnson295189b2012-06-20 16:38:30 -0700416 tANI_U16 auth_resp_len = 0;
417 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700418 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
419
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530420#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700421 struct cfg80211_ft_event_params ftEvent;
422 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
423 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
424 struct net_device *dev = pAdapter->dev;
425#else
426 char *buff;
427 union iwreq_data wrqu;
428 tANI_U16 str_len;
429#endif
430
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530431#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530432 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
433 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700434
Kanchanapally, Vidyullatha31b8d142015-01-30 14:25:18 +0530435 sme_GetRICIEs(pHddCtx->hHal, (u8 *)ricIe,
436 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530437 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700438 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530439 hddLog(LOGW,
440 "%s: RIC IEs is of length 0 not sending RIC Information for now",
441 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700442 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700443
444 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530445 ftEvent.ric_ies_len = ric_ies_length;
446 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700447
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530448 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800449 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700450
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530451 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700452 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530453 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700454 return;
455 }
456
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530457 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530458
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530459 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700460
461 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
462 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
463
Jeff Johnson59a121e2013-11-30 09:46:08 -0800464 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
465 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
466 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530467 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800468 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
469 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
470 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700471
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530472 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700473
474#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530475 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700476 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530477 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530479 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 return;
481 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530482 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700483
Shailender Karmuchia734f332013-04-19 14:02:48 -0700484 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530486 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800487 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530488 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530490 hddLog(LOGW,
491 "%s: RIC IEs is of length 0 not sending RIC Information for now",
492 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 }
494 else
495 {
496 wrqu.data.length = str_len + ric_ies_length;
497 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
498 }
499
500 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530501 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530503 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
504 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700505
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530506 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530508 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Bhargav Shah8b5b2f72015-07-14 11:53:46 +0530509 kfree(buff);
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 return;
511 }
512
513 wrqu.data.length = str_len + auth_resp_len;
514 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
515
516 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700517#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700518}
519
520#endif /* WLAN_FEATURE_VOWIFI_11R */
521
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800522#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700523
524/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800525 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 * (This keeps the supplicant "up to date" on the current channel.)
527 *
528 * The current (new AP) channel information is passed in.
529 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700530static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 tCsrRoamInfo *pCsrRoamInfo)
532{
533 union iwreq_data wrqu;
534 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700535
Shailender Karmuchia734f332013-04-19 14:02:48 -0700536
537 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 {
539 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800540 "%s: pCsrRoamInfo->pBssDesc=%p",
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 __func__, descriptor);
542 return;
543 }
544
545 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -0800546 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 memset(&wrqu, '\0', sizeof(wrqu));
548 wrqu.freq.m = descriptor->channelId;
549 wrqu.freq.e = 0;
550 wrqu.freq.i = 0;
551 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
552}
553
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800554#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700555
556void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
557{
558 union iwreq_data wrqu;
559 u8 *pBeaconIes;
560 u8 currentLen = 0;
561 char *buff;
562 int totalIeLen = 0, currentOffset = 0, strLen;
563
564 memset(&wrqu, '\0', sizeof(wrqu));
565
566 if (0 == pCsrRoamInfo->nBeaconLength)
567 {
568 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
569 return;
570 }
571 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700572 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700574 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700575 return;
576 }
577
578 // pBeaconIes needs to point to the IEs
579 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
580 (unsigned int)pBeaconIes[0],
581 (unsigned int)pBeaconIes[1]);
582 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700583
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 // We need to send the IEs to the supplicant.
585 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700586 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700588 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 return;
590 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700591 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700592
593 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
594 currentLen = strLen + 1;
595
596 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
597 do
598 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700599 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 * max size and send it to supplicant. Changes are done in supplicant to handle this */
601 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
602 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
603 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
604 currentOffset += currentLen;
605 totalIeLen -= currentLen;
606 wrqu.data.length = strLen + 1 + currentLen;
607 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700608 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700609 else
610 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
611
612 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
613 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
614 } while (totalIeLen > 0);
615
616 kfree(buff);
617}
618
619static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
620{
621 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
622 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
623 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
624 union iwreq_data wrqu;
625 int we_event;
626 char *msg;
627 int type = -1;
628
Shailender Karmuchia734f332013-04-19 14:02:48 -0700629#if defined (WLAN_FEATURE_VOWIFI_11R)
630 // Added to find the auth type on the fly at run time
631 // rather than with cfg to see if FT is enabled
632 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
634#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700635
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700637 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700639
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
641 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530642 /* In case of roaming ; We are not doing disconnect.
643 * If disconnect is not being done for roam; We will not
644 * decrease count for Active sessions. We should not increase active
645 * active session in case of roaming.
646 */
Padma, Santhosh Kumar87ba40f2014-11-26 19:40:15 +0530647 if((pHddStaCtx->ft_carrier_on == FALSE) && !pCsrRoamInfo->fReassocReq)
Agarwal Ashish51325b52014-06-16 16:50:49 +0530648 {
649 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
650 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700651 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
652 type = WLAN_STA_ASSOC_DONE_IND;
653
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700654#ifdef WLAN_FEATURE_P2P_DEBUG
655 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
656 {
657 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
658 {
659 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
660 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
661 "Connecting state to Connected State for 8-way "
662 "Handshake");
663 }
664 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
665 {
666 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
667 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
668 "Connecting state to P2P Client Connection Completed");
669 }
670 }
671#endif
SaidiReddy Yenugaa8b32f92016-07-27 19:29:18 +0530672 hddLog(VOS_TRACE_LEVEL_INFO, MAC_ADDRESS_STR " connected to "
Sushant Kaushikdc3184b2015-10-09 12:00:21 +0530673 MAC_ADDRESS_STR,
Arif Hussain77d044f2014-01-03 19:56:04 -0800674 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
Kiet Lam34947452014-01-21 23:23:40 -0800675 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700676 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
677
Bhargav Shahd0715912015-10-01 18:17:37 +0530678 hdd_manage_delack_timer(pHddCtx);
679
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
681 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
682 * and fFTEnable is TRUE */
683#ifdef WLAN_FEATURE_VOWIFI_11R
684 // Send FT Keys to the supplicant when FT is enabled
685 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700686 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800687#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700688 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
689 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
690#endif
691 )
692 {
693 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
694 }
695#endif
696 }
697 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
698 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530699 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -0700700 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700701 type = WLAN_STA_ASSOC_DONE_IND;
Deepthi Gowric7591cc2015-12-28 15:43:17 +0530702
703 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
704 "wlan: new IBSS connection to " MAC_ADDRESS_STR,
705 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700706 }
707 else /* Not Associated */
708 {
Deepthi Gowric7591cc2015-12-28 15:43:17 +0530709 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
710 "wlan: disconnected");
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 type = WLAN_STA_DISASSOC_DONE_IND;
712 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
Bhargav Shahd0715912015-10-01 18:17:37 +0530713
714 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700716 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700717
718 msg = NULL;
719 /*During the WLAN uninitialization,supplicant is stopped before the
720 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530721 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 {
723 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800724#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700725 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700726 {
727 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
728 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
730 }
731#endif
732 }
733 send_btc_nlink_msg(type, 0);
734}
735
736void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
737{
738 // Remove staId, bssId and peerMacAddress
739 pHddStaCtx->conn_info.staId [ 0 ] = 0;
740 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
741 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
742
743 // Clear all security settings
744 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
745 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
746 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
747
748 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700749 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700750
751 // Set not-connected state
752 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700753
754 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
755}
Katya Nigam47528772015-02-11 12:24:49 +0530756
757VOS_STATUS hdd_ibss_deinit_tx_rx_sta ( hdd_adapter_t *pAdapter, v_U8_t STAId )
758{
Katya Nigam1fd24402015-02-16 14:52:19 +0530759 v_U8_t ac;
760 /**Track whether OS TX queue has been disabled.*/
761 v_BOOL_t txSuspended[NUM_TX_QUEUES];
762 v_U8_t tlAC;
Katya Nigam47528772015-02-11 12:24:49 +0530763 v_U8_t i;
764 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
765 hdd_ibss_peer_info_t *pPeerInfo;
766
767 if( NULL == pHddStaCtx )
768 {
769 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
770 "%s: HDD station context NULL ",__func__);
771 return VOS_STATUS_E_FAILURE;
772 }
Katya Nigam1fd24402015-02-16 14:52:19 +0530773
Katya Nigam47528772015-02-11 12:24:49 +0530774 pPeerInfo = &pHddStaCtx->ibss_peer_info;
775 if (FALSE == pPeerInfo->ibssStaInfo[STAId].isUsed)
776 {
777 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
778 "%s: Deinit station not inited %d", __func__, STAId );
779 return VOS_STATUS_E_FAILURE;
780 }
781
782 hdd_flush_ibss_tx_queues(pAdapter, STAId);
Katya Nigam1fd24402015-02-16 14:52:19 +0530783
784 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
785 {
786 tlAC = hdd_QdiscAcToTlAC[ac];
787 txSuspended[ac] = pPeerInfo->ibssStaInfo[STAId].txSuspended[tlAC];
788 }
789
Katya Nigam47528772015-02-11 12:24:49 +0530790 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
791
Katya Nigam1fd24402015-02-16 14:52:19 +0530792 /* re-init hdd list, since netdev can still open adapter until
793 * driver gets unloaded
794 */
795 for (i = 0; i < NUM_TX_QUEUES; i ++)
796 {
797 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i],
798 HDD_TX_QUEUE_MAX_LEN);
799 }
800
801 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
802 {
803 if (txSuspended[ac])
804 {
805 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
806 "%s: TX queue re-enabled", __func__);
807 netif_wake_subqueue(pAdapter->dev, ac);
808 }
809 }
Katya Nigam47528772015-02-11 12:24:49 +0530810 return VOS_STATUS_SUCCESS;
811}
812
813static VOS_STATUS hdd_ibss_DeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
814{
815 VOS_STATUS vosStatus;
816
817 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
818 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
819 {
820 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
821 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
822 "Status= %d [0x%08X]",
823 __func__, staId, vosStatus, vosStatus );
824 }
825
826 vosStatus = hdd_ibss_deinit_tx_rx_sta ( pAdapter, staId );
827 if( VOS_STATUS_E_FAILURE == vosStatus )
828 {
829 VOS_TRACE ( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
830 "hdd_ibss_deinit_tx_rx_sta() failed for staID %d. "
831 "Status = %d [0x%08X]",
832 staId, vosStatus, vosStatus );
833 }
834
835 return( vosStatus );
836}
837
838VOS_STATUS hdd_ibss_init_tx_rx_sta( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA)
839{
840 v_U8_t i = 0;
841 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
842 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
843
844 if (pPeerInfo->ibssStaInfo[STAId].isUsed)
845 {
846 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
847 "%s: Reinit station %d", __func__, STAId );
848 return VOS_STATUS_E_FAILURE;
849 }
850
851 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
852 for (i = 0; i < NUM_TX_QUEUES; i ++)
853 {
854 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i], HDD_TX_QUEUE_MAX_LEN);
855 }
856
857 pPeerInfo->ibssStaInfo[STAId].isUsed = VOS_TRUE;
858 pPeerInfo->ibssStaInfo[STAId].isDeauthInProgress = VOS_FALSE;
859 vos_copy_macaddr( &pPeerInfo->ibssStaInfo[STAId].macAddrSTA, pmacAddrSTA);
860
861 return VOS_STATUS_SUCCESS;
862}
863
864static VOS_STATUS hdd_ibss_RegisterSTA( hdd_adapter_t *pAdapter,
865 tCsrRoamInfo *pRoamInfo,
866 v_U8_t staId,
867 v_MACADDR_t *pPeerMacAddress,
868 tSirBssDescription *pBssDesc )
869{
870 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
871 WLAN_STADescType staDesc = {0};
872 eCsrEncryptionType connectedCipherAlgo;
873 v_BOOL_t fConnected;
874 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
875 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
876 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
877
878 if ( pPeerInfo->ibssStaInfo[staId].isUsed )
879 {
880 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
881 "clean up old entry for STA %d", staId);
882 hdd_ibss_DeregisterSTA( pAdapter, staId );
883 }
884
885 staDesc.ucSTAId = staId;
886 staDesc.wSTAType = WLAN_STA_IBSS;
887
888 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
889 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
890 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
891 // pass when making an Infrastructure connection.
892 vos_mem_copy(staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes));
893 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId, 6 );
894 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
895
896 if (hdd_wmm_is_active(pAdapter))
897 {
898 staDesc.ucQosEnabled = 1;
899 }
900 else
901 {
902 staDesc.ucQosEnabled = 0;
903 }
904 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
905 "HDD SOFTAP register TL QoS_enabled=%d",
906 staDesc.ucQosEnabled );
907
908 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
909 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
910 {
911 staDesc.ucProtectedFrame = 1;
912 }
913 else
914 {
915 staDesc.ucProtectedFrame = 0;
916
917 }
918
919 hdd_ibss_init_tx_rx_sta(pAdapter, staId, &staDesc.vSTAMACAddress);
920
921 // UMA is Not ready yet, Xlation will be done by TL
922 staDesc.ucSwFrameTXXlation = 1;
923 staDesc.ucSwFrameRXXlation = 1;
924 staDesc.ucAddRmvLLC = 1;
925 // Initialize signatures and state
926 staDesc.ucUcastSig = pRoamInfo->ucastSig;
927 staDesc.ucBcastSig = pRoamInfo->bcastSig;
928 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED;
929
930 staDesc.ucIsReplayCheckValid = VOS_FALSE;
931
932 // Register the Station with TL.
933 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
934 hdd_rx_packet_cbk,
935 hdd_tx_complete_cbk,
936 hdd_ibss_tx_fetch_packet_cbk, &staDesc,
937 pBssDesc->rssi );
938 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
939 {
940 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
941 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
942 vosStatus, vosStatus );
943 return vosStatus;
944 }
945
946 //Timer value should be in milliseconds
947 if ( pHddCtx->cfg_ini->dynSplitscan &&
948 ( VOS_TIMER_STATE_RUNNING !=
949 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
950 {
951 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
952 pHddCtx->cfg_ini->trafficMntrTmrForSplitScan);
953 }
954
955 pPeerInfo->ibssStaInfo[staId].ucSTAId = staId;
956 pPeerInfo->ibssStaInfo[staId].isQosEnabled = staDesc.ucQosEnabled;
957
958 vosStatus = WLANTL_ChangeSTAState( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId,
959 WLANTL_STA_AUTHENTICATED );
960
961 pPeerInfo->ibssStaInfo[staId].tlSTAState = WLANTL_STA_AUTHENTICATED;
962 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
963
964 return( vosStatus );
965}
966
Jeff Johnson295189b2012-06-20 16:38:30 -0700967/* TODO Revist this function. and data path */
968static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
969{
970 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700971
Katya Nigam47528772015-02-11 12:24:49 +0530972 hdd_disconnect_tx_rx(pAdapter);
Ravi Joshif9520d62013-10-18 04:11:46 -0700973
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
975 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
976 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530977 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700979 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700980 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 }
982 return( vosStatus );
983}
984
985
986static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
987 tANI_U32 roamId, eRoamCmdStatus roamStatus,
988 eCsrRoamResult roamResult )
989{
990 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700991 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 struct net_device *dev = pAdapter->dev;
993 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
994 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700995 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530996 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700997
998 // Sanity check
999 if(dev == NULL)
1000 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05301001 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001002 "%s: net_dev is released return", __func__);
1003 return eHAL_STATUS_FAILURE;
1004 }
1005
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301007 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 netif_tx_disable(dev);
1009 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +05301010 //TxTimeoutCount need to reset in case of disconnect handler
1011 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001012
Jeff Johnsone7245742012-09-05 17:12:55 -07001013 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301014 /* If only STA mode is on */
1015 if((pHddCtx->concurrency_mode <= 1) &&
1016 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
1017 {
1018 pHddCtx->isAmpAllowed = VOS_TRUE;
1019 }
1020
Agarwal Ashish47d18112014-08-04 19:55:07 +05301021 /* Need to apply spin lock before decreasing active sessions
1022 * as there can be chance for double decrement if context switch
1023 * Calls wlan_hdd_disconnect.
1024 */
1025
1026 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh087de602015-10-21 17:18:55 +05301027
1028 /* HDD has initiated disconnect, do not send disconnect indication
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301029 * to kernel. Sending disconnected event to kernel for userspace
1030 * initiated disconnect will be handled by diconnect handler call
1031 * to cfg80211_disconnected
Abhishek Singh087de602015-10-21 17:18:55 +05301032 */
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301033 if ((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
1034 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301035 {
1036 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1037 FL(" HDD has initiated a disconnect, no need to send"
1038 " disconnect indication to kernel"));
1039 sendDisconInd = FALSE;
1040 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301041 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -07001042 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301043 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singh087de602015-10-21 17:18:55 +05301044 FL("Set HDD connState to eConnectionState_Disconnecting from %d "),
Agarwal Ashish47d18112014-08-04 19:55:07 +05301045 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301046 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
1047 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 }
Agarwal Ashish47d18112014-08-04 19:55:07 +05301049 spin_unlock_bh(&pAdapter->lock_for_active_session);
1050
Jeff Johnson295189b2012-06-20 16:38:30 -07001051 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -07001052
1053 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07001054
1055 // indicate 'disconnect' status to wpa_supplicant...
1056 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 /* indicate disconnected event to nl80211 */
1058 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
1059 {
1060 /*During the WLAN uninitialization,supplicant is stopped before the
1061 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301062 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 {
Sushant Kaushik0b343422015-05-25 17:15:55 +05301064 if (sendDisconInd)
1065 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1066 "%s: sent disconnected event to nl80211",
1067 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001068#ifdef WLAN_FEATURE_P2P_DEBUG
1069 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1070 {
1071 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
1072 {
1073 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
1074 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
1075 "and moved to disconnected state");
1076 }
1077 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
1078 {
1079 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
1080 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
1081 "and moved to inactive state");
1082 }
1083 }
1084#endif
Sushant Kaushikbad61892015-07-10 16:43:28 +05301085 if ((roamStatus == eCSR_ROAM_LOSTLINK) &&
1086 !pRoamInfo->reasonCode)
1087 wlan_hdd_get_frame_logs(pAdapter,
1088 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301089 /*Only send indication to kernel if not initiated by kernel*/
1090 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301092 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
1093 if ( eCSR_ROAM_LOSTLINK == roamStatus )
1094 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301095 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
1096 pRoamInfo->reasonCode);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301097 }
1098 else
1099 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301100 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301101 WLAN_REASON_UNSPECIFIED);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301104
1105 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1106 {
1107 hddLog(LOG1,
1108 FL("P2P client is getting removed and we are tryig to re-enable TDLS"));
1109 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301110 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301111
Jeff Johnson295189b2012-06-20 16:38:30 -07001112 //If the Device Mode is Station
1113 // and the P2P Client is Connected
1114 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001115
1116 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001117 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001118 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 {
1120 //Enable BMPS only of other Session is P2P Client
1121 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001122 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001123
1124 if (NULL != pVosContext)
1125 {
1126 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1127
1128 if(NULL != pHddCtx)
1129 {
1130 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301131 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1132 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301134 if (pHddCtx->hdd_wlan_suspended)
1135 {
1136 hdd_set_pwrparams(pHddCtx);
1137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 }
1141 }
1142 }
1143 }
1144 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001145
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301146 hdd_wmm_adapter_clear(pAdapter);
Kapil Guptae6867482016-06-26 13:31:37 +05301147 /* Clear PER based roam stats */
1148#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1149 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
1150 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
1151 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
1152 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
1153 sme_unset_per_roam_rxconfig(pHddCtx->hHal);
1154#endif
Mukul Sharmac159c432014-01-15 15:42:46 +05301155#if defined(WLAN_FEATURE_VOWIFI_11R)
1156 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1157#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301158
1159 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1160 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301161 v_U8_t i;
1162
Katya Nigam63ce1772014-09-26 15:53:49 +05301163 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301164 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301165 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1166 {
1167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301168 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1169 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301170 sta_id, status, status );
1171
1172 status = eHAL_STATUS_FAILURE;
1173 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301174 pHddCtx->sta_to_adapter[sta_id] = NULL;
1175
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301176 /*Clear all the peer sta register with TL.*/
1177 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1178 {
1179 if (0 != pHddStaCtx->conn_info.staId[i])
1180 {
1181 sta_id = pHddStaCtx->conn_info.staId[i];
1182
1183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1184 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301185 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301186 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1187 {
1188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1189 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1190 "Status= %d [0x%x]"),
1191 sta_id, status, status );
1192 status = eHAL_STATUS_FAILURE;
1193 }
1194
Nirav Shah7e3c8132015-06-22 23:51:42 +05301195 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1196 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1197 if (vstatus != VOS_STATUS_SUCCESS) {
1198 hddLog(VOS_TRACE_LEVEL_ERROR,
1199 FL("Not able to remove staid hash %d"),
1200 sta_id);
1201 status = eHAL_STATUS_FAILURE;
1202 } else {
1203 hddLog(VOS_TRACE_LEVEL_INFO,
1204 FL("ibss station removed sta_id %d mac:"
1205 MAC_ADDRESS_STR), sta_id,
1206 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1207 }
1208
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301209 /*set the staid and peer mac as 0, all other reset are
1210 * done in hdd_connRemoveConnectInfo.
1211 */
1212 pHddStaCtx->conn_info.staId[i]= 0;
1213 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1214
1215 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1216 pHddCtx->sta_to_adapter[sta_id] = NULL;
1217 }
1218 }
1219
Katya Nigam63ce1772014-09-26 15:53:49 +05301220 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301221 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301223 sta_id = pHddStaCtx->conn_info.staId[0];
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05301224 /* clear scan cache for Link Lost */
1225 if (pRoamInfo && !pRoamInfo->reasonCode &&
1226 (eCSR_ROAM_LOSTLINK == roamStatus)) {
1227 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1228 pHddStaCtx->conn_info.bssId);
1229 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1230 pHddStaCtx->conn_info.bssId);
1231 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301232
1233 //We should clear all sta register with TL, for now, only one.
1234 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1235 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1236 {
1237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1238 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1239 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001240 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001241
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301242 status = eHAL_STATUS_FAILURE;
1243 }
1244
1245 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301247
1248#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1249 if (VOS_STATUS_SUCCESS !=
1250 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1251 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1252 {
1253 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1254 "WLANTL_ClearInterfaceStats Failed", __func__);
1255 }
1256 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1257 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1258 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1259 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1260#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1261
Jeff Johnson295189b2012-06-20 16:38:30 -07001262 // Clear saved connection information in HDD
1263 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +05301264 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1265 "%s: Set HDD connState to eConnectionState_NotConnected",
1266 __func__);
1267 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301268#ifdef WLAN_FEATURE_GTK_OFFLOAD
1269 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1270 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1271 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301272 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1273 sizeof (tSirGtkOffloadParams));
1274 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301275 }
1276#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001277
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001278#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001279 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1280 {
1281 wlan_hdd_tdls_disconnection_callback(pAdapter);
1282 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001283#endif
1284
Jeff Johnson295189b2012-06-20 16:38:30 -07001285 //Unblock anyone waiting for disconnect to complete
1286 complete(&pAdapter->disconnect_comp_var);
1287 return( status );
1288}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301289
1290static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
1291 v_U8_t staId)
1292{
1293 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1294 v_SINT_t i;
1295 v_SIZE_t size;
1296 VOS_STATUS status;
1297 v_BOOL_t granted = VOS_FALSE;
1298
1299 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1300 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
1301 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
1302 {
1303 //Indicate to TL that there is pending data if a queue is non empty
1304 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
1305 {
1306 size = 0;
1307 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
1308 if (size > 0)
1309 {
1310 if (i != WLANTL_AC_HIGH_PRIO)
1311 {
1312 if (VOS_FALSE ==
1313 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
1314 {
1315 hdd_wmm_acquire_access(pAdapter,
1316 (WLANTL_ACEnumType)i, &granted);
1317 pAdapter->psbChanged |= (1 << i);
1318 }
1319 else
1320 granted = VOS_TRUE;
1321 }
1322
1323 if (granted || (i == WLANTL_AC_HIGH_PRIO))
1324 {
1325 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
1326 staId, (WLANTL_ACEnumType)i);
1327 if (!VOS_IS_STATUS_SUCCESS(status))
1328 {
1329 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1330 "%s: Failure in indicating pkt to TL for QID=%d",
1331 __func__, i);
1332 }
1333 }
1334 }
1335 }
1336 }
1337}
1338
Jeff Johnson295189b2012-06-20 16:38:30 -07001339static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
1340 tCsrRoamInfo *pRoamInfo,
1341 v_U8_t staId,
1342 v_MACADDR_t *pPeerMacAddress,
1343 tSirBssDescription *pBssDesc )
1344{
1345 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1346 WLAN_STADescType staDesc = {0};
1347 eCsrEncryptionType connectedCipherAlgo;
1348 v_BOOL_t fConnected;
1349 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1350 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001351 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001352
1353 if ( NULL == pBssDesc)
1354 {
1355 return VOS_STATUS_E_FAILURE;
1356 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 // Get the Station ID from the one saved during the assocation.
1358 staDesc.ucSTAId = staId;
1359
Katya Nigam47528772015-02-11 12:24:49 +05301360 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001361
Katya Nigam47528772015-02-11 12:24:49 +05301362 // grab the bssid from the connection info in the adapter structure and hand that
1363 // over to TL when registering.
1364 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
1365 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001366
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1368
1369 // set the QoS field appropriately
1370 if (hdd_wmm_is_active(pAdapter))
1371 {
1372 staDesc.ucQosEnabled = 1;
1373 }
1374 else
1375 {
1376 staDesc.ucQosEnabled = 0;
1377 }
1378
1379 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1380 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1381 {
1382 staDesc.ucProtectedFrame = 1;
1383 }
1384 else
1385 {
1386 staDesc.ucProtectedFrame = 0;
1387
1388 }
1389
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001390#ifdef FEATURE_WLAN_ESE
1391 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1392#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001393
1394#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1395 /* check whether replay check is valid for the station or not */
1396 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1397 {
1398 /* Encryption mode is either TKIP or AES
1399 and replay check is valid for only these
1400 two encryption modes */
1401 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1402 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1403 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1404 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001405
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 else
1407 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001408 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001410 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001411 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1412 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1413 }
1414#endif
1415
1416#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001417 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 if (pAdapter->wapi_info.fIsWapiSta)
1419 {
1420 staDesc.ucIsWapiSta = 1;
1421 }
1422 else
1423 {
1424 staDesc.ucIsWapiSta = 0;
1425 }
1426#endif /* FEATURE_WLAN_WAPI */
1427
1428 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1429 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1430
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 // UMA is Not ready yet, Xlation will be done by TL
1432 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 staDesc.ucSwFrameRXXlation = 1;
1434 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001435 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 staDesc.ucQosEnabled );
1437 // Initialize signatures and state
1438 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1439 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1440 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1441 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001442 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001443 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "%s: HDD register TL ucInitState=%d", __func__, staDesc.ucInitState );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001444 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1445 hdd_rx_packet_cbk,
1446 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001447 hdd_tx_fetch_packet_cbk, &staDesc,
1448 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001449
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1451 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001452 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001453 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001454 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001455 return vosStatus;
1456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001457
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001458 if ( cfg_param->dynSplitscan &&
1459 ( VOS_TIMER_STATE_RUNNING !=
1460 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1461 {
1462 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1463 cfg_param->trafficMntrTmrForSplitScan);
1464 }
1465
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301466 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1467 // then go to 'authenticated'. For all other authentication types
1468 // (those that donot require upper layer authentication) we can put
1469 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001470 if (staDesc.wSTAType != WLAN_STA_IBSS)
1471 VOS_ASSERT( fConnected );
1472
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301473 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001474 {
1475 // Connections that do not need Upper layer auth, transition TL directly
1476 // to 'Authenticated' state.
1477 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1478 WLANTL_STA_AUTHENTICATED );
1479
1480 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301481
1482 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001483 }
1484 else
1485 {
1486 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301487 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1488 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001489 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301490 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001491 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 return( vosStatus );
1494}
1495
Jeff Johnson295189b2012-06-20 16:38:30 -07001496static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1497 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1498{
1499 unsigned int len = 0;
1500 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001501 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001502 tANI_U32 rspRsnLength = 0;
Abhishek Singh5a597e62016-12-05 15:16:30 +05301503 struct cfg80211_bss* bss;
1504 tCsrRoamConnectedProfile roam_profile;
Jeff Johnson295189b2012-06-20 16:38:30 -07001505 struct ieee80211_channel *chan;
Abhishek Singh5a597e62016-12-05 15:16:30 +05301506 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001507
Agarwal Ashish51325b52014-06-16 16:50:49 +05301508 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001509 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001510 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001511 }
1512
Agarwal Ashish51325b52014-06-16 16:50:49 +05301513 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001514 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1515 goto done;
1516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001517
Agarwal Ashish51325b52014-06-16 16:50:49 +05301518 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001519 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1520 goto done;
1521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001522
1523 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1524 pCsrRoamInfo->nAssocReqLength);
1525 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001526 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001527
1528 //pFTAssocRsp needs to point to the IEs
1529 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001530 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001531 (unsigned int)pFTAssocRsp[0],
1532 (unsigned int)pFTAssocRsp[1]);
1533
1534 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001535 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001536 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001537 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001538 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001539
Abhishek Singh5a597e62016-12-05 15:16:30 +05301540 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1541 (int) pCsrRoamInfo->pBssDesc->channelId);
1542 vos_mem_zero(&roam_profile, sizeof(tCsrRoamConnectedProfile));
1543 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roam_profile);
1544 bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
1545 chan, pCsrRoamInfo->bssid,
1546 &roam_profile.SSID.ssId[0],
1547 roam_profile.SSID.length);
1548 cfg80211_roamed_bss(dev, bss,
Jeff Johnson295189b2012-06-20 16:38:30 -07001549 reqRsnIe, reqRsnLength,
1550 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001551
1552done:
1553 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001554}
Jeff Johnson295189b2012-06-20 16:38:30 -07001555
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301556void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1557{
1558 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1559 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1560 tCsrRoamInfo roamInfo;
1561 roamInfo.fAuthRequired = FALSE;
1562 vos_mem_copy(roamInfo.bssid,
1563 pHddStaCtx->roam_info.bssid,
1564 WNI_CFG_BSSID_LEN);
1565 vos_mem_copy(roamInfo.peerMac,
1566 pHddStaCtx->roam_info.peerMac,
1567 WNI_CFG_BSSID_LEN);
1568
1569 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1570 &roamInfo,
1571 pHddStaCtx->roam_info.roamId,
1572 pHddStaCtx->roam_info.roamStatus,
1573 eCSR_ROAM_RESULT_AUTHENTICATED);
1574 if (halStatus != eHAL_STATUS_SUCCESS)
1575 {
1576 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1577 }
1578 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1579}
1580
Shailender Karmuchia734f332013-04-19 14:02:48 -07001581static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1582 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 eCsrRoamResult roamResult )
1584{
1585 struct net_device *dev = pAdapter->dev;
1586 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1587 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301588 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05301589 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001590 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1591 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001592#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 int ft_carrier_on = FALSE;
1594#endif
1595 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301596 v_BOOL_t hddDisconInProgress = FALSE;
1597
1598 /* HDD has initiated disconnect, do not send connect result indication
1599 * to kernel as it will be handled by __cfg80211_disconnect.
1600 */
Agarwal Ashishc089cec2015-08-10 13:10:04 +05301601 if (((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
1602 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)) &&
1603 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1604 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301605 {
1606 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1607 FL(" Disconnect from HDD in progress "));
1608 hddDisconInProgress = TRUE;
1609 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001610
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1612 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301613 if ( !hddDisconInProgress )
1614 {
1615 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301616 "%s: Set HDD connState to eConnectionState_Associated",
1617 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301618 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001620
c_hpothu44ff4e02014-05-08 00:13:57 +05301621 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001622 // Save the connection info from CSR...
1623 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
Kapil Guptae6867482016-06-26 13:31:37 +05301624
1625#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1626 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
1627 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
1628 !hddDisconInProgress &&
1629 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
1630 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
1631 sme_set_per_roam_rxconfig(pHddCtx->hHal,
1632 pHddStaCtx->conn_info.staId[0],
1633 pHddCtx->cfg_ini->rateDownThreshold,
1634 pHddCtx->cfg_ini->rateUpThreshold,
1635 pHddCtx->cfg_ini->PERroamTriggerPercent,
1636 pHddCtx->cfg_ini->PERroamRxPktsThreshold,
1637 pHddCtx->cfg_ini->waitPeriodForNextPERScan);
1638#endif
1639
Jeff Johnson295189b2012-06-20 16:38:30 -07001640#ifdef FEATURE_WLAN_WAPI
1641 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1642 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1643 {
1644 pAdapter->wapi_info.fIsWapiSta = 1;
1645 }
1646 else
1647 {
1648 pAdapter->wapi_info.fIsWapiSta = 0;
1649 }
1650#endif /* FEATURE_WLAN_WAPI */
1651
1652 // indicate 'connect' status to userspace
1653 hdd_SendAssociationEvent(dev,pRoamInfo);
1654
1655
Shailender Karmuchia734f332013-04-19 14:02:48 -07001656 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001657 INIT_COMPLETION(pAdapter->linkup_event_var);
1658
1659 /*
1660 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1661 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 -07001662 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 know that the device is getting activated properly.
1664 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001665#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05301666 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07001667 {
1668#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001669 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 pAdapter->isLinkUpSvcNeeded = TRUE;
1671
Shailender Karmuchia734f332013-04-19 14:02:48 -07001672 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 pAdapter->isLinkUpSvcNeeded = TRUE;
1674
1675 // Switch on the Carrier to activate the device
1676 netif_carrier_on(dev);
1677
1678 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1679 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1680 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001681 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 {
1683 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1684 }
1685
1686 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1687 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001688#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001689 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001690 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 }
1694#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301695 /* Check for STAID */
1696 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1697 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1698 else
1699 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001700
1701 //For reassoc, the station is already registered, all we need is to change the state
1702 //of the STA in TL.
1703 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05301704 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 if( !pRoamInfo->fReassocReq )
1706 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001707 struct cfg80211_bss *bss;
1708#ifdef WLAN_FEATURE_VOWIFI_11R
1709 u8 *pFTAssocRsp = NULL;
1710 unsigned int assocRsplen = 0;
1711 u8 *pFTAssocReq = NULL;
1712 unsigned int assocReqlen = 0;
1713 struct ieee80211_channel *chan;
1714#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001716 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001717
1718 /* add bss_id to cfg80211 data base */
1719 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1720 if (NULL == bss)
1721 {
Abhishek Singh7ca68f32016-06-28 10:23:10 +05301722 hddLog(LOGE,
1723 FL("Not able to create BSS entry"));
Katya Nigam346d4e92014-09-02 16:16:12 +05301724 netif_carrier_off(dev);
Abhishek Singh7ca68f32016-06-28 10:23:10 +05301725 if (!hddDisconInProgress) {
1726 /*
1727 * Here driver was not able to update cfg80211 database
1728 * this can happen if connected channel is not valid,
1729 * i.e reg domain was changed during connection.
1730 * Queue disconnect for the session if disconnect is
1731 * not in progress.
1732 */
1733 hddLog(LOGE, FL("Disconnecting..."));
1734 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1735 pAdapter->sessionId,
1736 eCSR_DISCONNECT_REASON_UNSPECIFIED);
1737 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 return eHAL_STATUS_FAILURE;
1739 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001740#ifdef WLAN_FEATURE_VOWIFI_11R
1741 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001742 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001743 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001744
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001745 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001746 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001747 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001748 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001749 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001750 // pFTAssocRsp needs to point to the IEs
1751 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1752 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1753 (unsigned int)pFTAssocRsp[0],
1754 (unsigned int)pFTAssocRsp[1]);
1755 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001756 }
1757 else
1758 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001759 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1760 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001761 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001762
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001763 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001764 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001765 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001766 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001767 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001768 if(!ft_carrier_on)
1769 {
1770 // pFTAssocReq needs to point to the IEs
1771 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1772 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1773 (unsigned int)pFTAssocReq[0],
1774 (unsigned int)pFTAssocReq[1]);
1775 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1776 }
1777 else
1778 {
1779 /* This should contain only the FTIEs */
1780 assocReqlen = pRoamInfo->nAssocReqLength;
1781 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001782 }
1783 else
1784 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001785 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1786 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001787 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001788
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001789 if(ft_carrier_on)
1790 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301791 if ( !hddDisconInProgress )
1792 {
Abhishek Singh5a597e62016-12-05 15:16:30 +05301793 struct cfg80211_bss *roam_bss;
1794
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301795 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001796 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301797 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001798 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301799 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001800 assocRsplen);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05301801 if (pHddCtx->cfg_ini &&
1802 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301803 {
1804 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1805 }
Abhishek Singh5a597e62016-12-05 15:16:30 +05301806 roam_bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
1807 chan, pRoamInfo->bssid,
1808 pRoamInfo->u.pConnectedProfile->SSID.ssId,
1809 pRoamInfo->u.pConnectedProfile->SSID.length);
1810 cfg80211_roamed_bss(dev, roam_bss,
1811 pFTAssocReq, assocReqlen,
1812 pFTAssocRsp, assocRsplen,
1813 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301814 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301815 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1816 {
1817 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1818 pRoamInfo->fAuthRequired = FALSE;
1819
1820 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1821 pRoamInfo->bssid,
1822 HDD_MAC_ADDR_LEN);
1823 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1824 pRoamInfo->peerMac,
1825 HDD_MAC_ADDR_LEN);
1826 pHddStaCtx->roam_info.roamId = roamId;
1827 pHddStaCtx->roam_info.roamStatus = roamStatus;
1828 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1829 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001830 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301831 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001832 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001833 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001834 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05301835 hdd_connect_result(dev, pRoamInfo->bssid, pRoamInfo,
1836 pFTAssocReq, assocReqlen,
1837 pFTAssocRsp, assocRsplen,
1838 WLAN_STATUS_SUCCESS,
1839 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001840 }
1841 }
1842 else
1843#endif
1844 {
1845 /* wpa supplicant expecting WPA/RSN IE in connect result */
1846 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1847 pAdapter->sessionId,
1848 &reqRsnLength,
1849 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001850
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001851 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1852 pAdapter->sessionId,
1853 &rspRsnLength,
1854 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301855 if ( !hddDisconInProgress )
1856 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001857#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301858 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301859 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301860 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05301861 if (pHddCtx->cfg_ini &&
1862 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301863 {
1864 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1865 }
Mukul Sharma84f27252014-07-14 18:11:42 +05301866 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301867 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001868#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001869
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301870 {
1871 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301872 "%s: sending connect indication to nl80211:"
1873 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301874 " result:%d and Status:%d",
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301875 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1876 roamResult, roamStatus);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301877 /* inform connect result to nl80211 */
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05301878 hdd_connect_result(dev, pRoamInfo->bssid,
1879 pRoamInfo,
1880 reqRsnIe, reqRsnLength,
1881 rspRsnIe, rspRsnLength,
1882 WLAN_STATUS_SUCCESS,
1883 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301884 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001885 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001886 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301887 if ( !hddDisconInProgress )
1888 {
1889 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001890#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301891 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001892#endif
1893 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301894 // Register the Station with TL after associated...
1895 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 pRoamInfo,
1897 pHddStaCtx->conn_info.staId[ 0 ],
1898 NULL,
1899 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 }
1902 else
1903 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001904 /* wpa supplicant expecting WPA/RSN IE in connect result */
1905 /* in case of reassociation also need to indicate it to supplicant */
1906 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1907 pAdapter->sessionId,
1908 &reqRsnLength,
1909 reqRsnIe);
1910
1911 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301913 if( pRoamInfo->fAuthRequired )
1914 {
1915 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1916 pHddStaCtx->conn_info.staId[ 0 ],
1917 WLANTL_STA_CONNECTED );
1918 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1919 }
1920 else
1921 {
1922 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1923 "%s: staId: %d Changing TL state to AUTHENTICATED",
1924 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1925 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1926 pHddStaCtx->conn_info.staId[ 0 ],
1927 WLANTL_STA_AUTHENTICATED );
1928 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301929 hdd_postTLPacketPendingInd(pAdapter,
1930 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301931 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001932 }
1933
1934 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1935 {
1936 // perform any WMM-related association processing
1937 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1938 }
1939 else
1940 {
1941 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001942 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001943 vosStatus, vosStatus );
1944 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001945#ifdef WLAN_FEATURE_11W
1946 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1947 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1948#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301949
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05301951 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301952 {
1953 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05301954 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301955 }
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05301956 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301957 {
1958 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1959 }
Padma, Santhosh Kumar38cef182016-02-18 12:22:51 +05301960#ifdef FEATURE_WLAN_TDLS
1961 wlan_hdd_tdls_connection_callback(pAdapter);
1962#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001963 }
1964 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001966 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1967
1968 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001969 if (pRoamInfo)
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301970 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1971 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
1972 MAC_ADDR_ARRAY(pRoamInfo->bssid), roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001973 else
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301974 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1975 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
Arif Hussain24bafea2013-11-15 15:10:03 -08001976 MAC_ADDR_ARRAY(pWextState->req_bssId),
1977 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001978
Sachin Ahuja674c5112015-10-14 13:16:49 +05301979 if (( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
1980 ((roamResult != eCSR_ROAM_RESULT_ASSOCIATED) &&
1981 (eCSR_ROAM_ASSOCIATION_COMPLETION == roamStatus)))
Abhishek Singh611295e2015-07-09 11:11:54 +05301982 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05301983 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
1984
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05301985 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
1986 (pRoamInfo &&
1987 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
1988 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
1989 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode)))) {
1990 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1991 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
1992 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1993 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
1994 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05301995 /* Set connection state to eConnectionState_NotConnected only when CSR
1996 * has completed operation - with a ASSOCIATION_FAILURE status
1997 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301998 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301999 {
2000 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2001 "%s: Set HDD connState to eConnectionState_NotConnected",
2002 __func__);
2003 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
2004 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05302005 if((pHddCtx->concurrency_mode <= 1) &&
2006 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 {
2008 pHddCtx->isAmpAllowed = VOS_TRUE;
2009 }
2010
2011 //If the Device Mode is Station
2012 // and the P2P Client is Connected
2013 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07002014
2015 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07002016 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07002017 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
2018 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05302019 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07002020 {
2021 //Enable BMPS only of other Session is P2P Client
2022 hdd_context_t *pHddCtx = NULL;
2023 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
2024
2025 if (NULL != pVosContext)
2026 {
2027 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
2028
2029 if(NULL != pHddCtx)
2030 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302031 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05302032 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
2033 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302034 {
2035 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002036 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302037 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002038 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302039 hdd_enable_bmps_imps(pHddCtx);
2040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002041 }
2042 }
2043 }
2044
James Zmudafbf5ffc2013-03-25 12:45:35 -07002045 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08002046 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302047 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07002048 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05302049
2050 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2051 {
2052 hddLog(LOG1,
2053 FL("Assoication Failure for P2P client and we are trying to re-enable TDLS"));
2054 wlan_hdd_tdls_reenable(pHddCtx);
2055 }
2056
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302057 if (pRoamInfo)
2058 hddLog(VOS_TRACE_LEVEL_ERROR,
2059 "%s: send connect failure to nl80211:"
2060 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302061 " result:%d and Status:%d reasonCode %d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302062 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302063 roamResult, roamStatus, pRoamInfo->reasonCode);
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302064 else
2065 hddLog(VOS_TRACE_LEVEL_ERROR,
2066 "%s: connect failed:"
2067 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302068 " result:%d and Status:%d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302069 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
2070 roamResult, roamStatus);
2071
James Zmudafbf5ffc2013-03-25 12:45:35 -07002072 /* inform association failure event to nl80211 */
2073 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
2074 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002075 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302076 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002077 NULL, 0, NULL, 0,
2078 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302079 GFP_KERNEL);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002080 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302081 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002082 NULL, 0, NULL, 0,
2083 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302084 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002085 }
2086 else
2087 {
Gao Wu6ca73b32016-05-09 14:35:49 +08002088 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302089 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002090 NULL, 0, NULL, 0,
2091 pRoamInfo->reasonCode ?
2092 pRoamInfo->reasonCode :
2093 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302094 GFP_KERNEL);
Gao Wu6ca73b32016-05-09 14:35:49 +08002095 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302096 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002097 NULL, 0, NULL, 0,
2098 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302099 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002100 }
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302101 /*Clear the roam profile*/
2102 hdd_clearRoamProfileIe( pAdapter );
Jeff Johnsone7245742012-09-05 17:12:55 -07002103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002104
Kumar Anand82c009f2014-05-29 00:29:42 -07002105 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002106
c_hpothu24f40982014-04-18 18:00:36 +05302107 if (pRoamInfo)
2108 {
2109 WLANTL_AssocFailed(pRoamInfo->staId);
2110 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302111
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302112 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002113 netif_tx_disable(dev);
2114 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002115
Jeff Johnson295189b2012-06-20 16:38:30 -07002116 }
2117
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302118 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302119 {
2120 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2121 if (pHostapdAdapter != NULL)
2122 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302123 /* Restart SAP if its operating channel is different
2124 * from AP channel.
2125 */
2126 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2127 (int)pRoamInfo->pBssDesc->channelId)
2128 {
2129 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2130 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2131 (int)pRoamInfo->pBssDesc->channelId);
Deepthi Gowric9c777d2014-12-10 16:17:11 +05302132 hdd_hostapd_stop(pHostapdAdapter->dev);
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302133 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302134 }
2135 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002136 return eHAL_STATUS_SUCCESS;
2137}
2138
2139/**============================================================================
2140 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002141 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002143
Jeff Johnson295189b2012-06-20 16:38:30 -07002144 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002145static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2146 tCsrRoamInfo *pRoamInfo,
2147 tANI_U32 roamId,
2148 eRoamCmdStatus roamStatus,
2149 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002150{
Katya Nigam47528772015-02-11 12:24:49 +05302151 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2152 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2153 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302154 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302155
Jeff Johnson81c17882013-05-03 09:53:35 -07002156 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2157 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2158
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 switch( roamResult )
2160 {
2161 // both IBSS Started and IBSS Join should come in here.
2162 case eCSR_ROAM_RESULT_IBSS_STARTED:
2163 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002164 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002166 if (NULL == pRoamInfo)
2167 {
2168 VOS_ASSERT(0);
2169 return;
2170 }
2171
2172 /* When IBSS Started comes from CSR, we need to move
2173 * connection state to IBSS Disconnected (meaning no peers
2174 * are in the IBSS).
2175 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302176 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2177 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2178 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002179 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2180 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302181 /*notify wmm */
2182 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002183 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002184
Jeff Johnson81c17882013-05-03 09:53:35 -07002185 if (pRoamInfo->pBssDesc)
2186 {
Anand N Sunkadfec40682015-07-29 09:51:17 +05302187#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2188 struct ieee80211_channel *chan;
2189 int chan_no;
2190 unsigned int freq;
2191#endif
Katya Nigam47528772015-02-11 12:24:49 +05302192 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2193 IBSS_BROADCAST_STAID,
2194 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002195
2196 /* we created the IBSS, notify supplicant */
2197 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2198 MAC_ADDRESS_STR,
2199 __func__, pAdapter->dev->name,
2200 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2201
2202 /* we must first give cfg80211 the BSS information */
2203 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2204 if (NULL == bss)
2205 {
2206 hddLog(VOS_TRACE_LEVEL_ERROR,
2207 "%s: %s: unable to create IBSS entry",
2208 __func__, pAdapter->dev->name);
2209 return;
2210 }
Abhishek Singh00b71972016-01-07 10:51:04 +05302211#ifdef WLAN_FEATURE_RMC
2212 netif_carrier_on(pAdapter->dev);
2213 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
2214 netif_tx_start_all_queues(pAdapter->dev);
2215#endif
Anand N Sunkadfec40682015-07-29 09:51:17 +05302216#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2217 chan_no = pRoamInfo->pBssDesc->channelId;
Jeff Johnson81c17882013-05-03 09:53:35 -07002218
Anand N Sunkadfec40682015-07-29 09:51:17 +05302219 if (chan_no <= 14)
2220 freq = ieee80211_channel_to_frequency(chan_no,
2221 IEEE80211_BAND_2GHZ);
2222 else
2223 freq = ieee80211_channel_to_frequency(chan_no,
2224 IEEE80211_BAND_5GHZ);
2225
2226 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
2227
2228 if (chan)
2229 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
2230 chan, GFP_KERNEL);
2231 else
2232 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
2233 pAdapter->dev->name,
2234 (int)pRoamInfo->pBssDesc->channelId);
2235#else
Jeff Johnson81c17882013-05-03 09:53:35 -07002236 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302237#endif
Yue Maf49ba872013-08-19 12:04:25 -07002238 cfg80211_put_bss(
2239#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2240 pHddCtx->wiphy,
2241#endif
2242 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07002243 }
Katya Nigam47528772015-02-11 12:24:49 +05302244 else
2245 {
2246 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2247 "%s: NULL Bss Desc",__func__);
2248 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05302249
2250 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
2251 * in IBSS_COALESCED will remove the BC key.
2252 */
2253 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
2254 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
2255 == pHddStaCtx->ibss_enc_key.encType
2256 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
2257 == pHddStaCtx->ibss_enc_key.encType
2258 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2259 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
2260 {
2261 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2262 VOS_STATUS vosStatus;
2263
2264 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2265
2266 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2267 grpmacaddr, WNI_CFG_BSSID_LEN);
2268 hddLog(VOS_TRACE_LEVEL_INFO,
2269 FL(" SET GTK in case of COALESCED"));
2270 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2271 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2272 if ( VOS_STATUS_SUCCESS != vosStatus )
2273 {
2274 hddLog(VOS_TRACE_LEVEL_ERROR,
2275 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
2276 }
2277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 break;
2279 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002280
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
2282 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002283 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
2284 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 break;
2286 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002287
Jeff Johnson295189b2012-06-20 16:38:30 -07002288 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07002289 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
2290 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002292 }
2293
Jeff Johnson81c17882013-05-03 09:53:35 -07002294 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002295}
2296
2297/**============================================================================
2298 *
2299 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
2300 This information is passed to iwconfig later. The peer that joined
2301 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002302 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002304
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05302306static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07002307{
2308 int fSuccess = FALSE;
2309 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302310 VOS_STATUS status;
2311 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002312
Jeff Johnson295189b2012-06-20 16:38:30 -07002313 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2314 {
2315 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
2316 {
2317 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002318
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002320
Jeff Johnson295189b2012-06-20 16:38:30 -07002321 fSuccess = TRUE;
2322 break;
2323 }
2324 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002325
Nirav Shah7e3c8132015-06-22 23:51:42 +05302326 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
2327 if (status != VOS_STATUS_SUCCESS) {
2328 hddLog(VOS_TRACE_LEVEL_ERROR,
2329 FL("Not able to add staid hash %d"), staId);
2330 return FALSE;
2331 }
2332
2333 hddLog(VOS_TRACE_LEVEL_INFO,
2334 FL("New station added sta_id %d mac:"
2335 MAC_ADDRESS_STR), staId,
2336 MAC_ADDR_ARRAY(peerMacAddress->bytes));
2337
Shailender Karmuchia734f332013-04-19 14:02:48 -07002338 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07002339}
2340/**============================================================================
2341 *
2342 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002343 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002344 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002345
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07002347static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07002348{
2349 int fSuccess = FALSE;
2350 int idx = 0;
2351 v_U8_t valid_idx = 0;
2352 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07002353 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002354 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05302355 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002356
Jeff Johnson295189b2012-06-20 16:38:30 -07002357 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2358 {
2359 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
2360 {
2361 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302362 status = hdd_sta_id_hash_remove_entry(pAdapter,
2363 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
2364 if (status != VOS_STATUS_SUCCESS) {
2365 hddLog(VOS_TRACE_LEVEL_ERROR,
2366 FL("Not able to remove staid hash %d"), staId );
2367 fSuccess = FALSE;
2368 } else {
2369 hddLog(VOS_TRACE_LEVEL_INFO,
2370 FL("station removed sta_id %d mac:"
2371 MAC_ADDRESS_STR), staId,
2372 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07002373
Nirav Shah7e3c8132015-06-22 23:51:42 +05302374 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002375
Nirav Shah7e3c8132015-06-22 23:51:42 +05302376 fSuccess = TRUE;
2377 // Note the deleted Index, if its 0 we need special handling
2378 del_idx = idx;
2379 empty_slots++;
2380 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 }
2382 else
2383 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002384 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002385 {
2386 valid_idx = idx;
2387 }
Ravi Joshi8a934352013-09-25 16:46:58 -07002388 else
2389 {
2390 // Found an empty slot
2391 empty_slots++;
2392 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002393 }
2394 }
2395
Ravi Joshi8a934352013-09-25 16:46:58 -07002396 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
2397 {
2398 // Last peer departed, set the IBSS state appropriately
2399 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002400 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07002401 "Last IBSS Peer Departed!!!" );
2402 }
2403
Jeff Johnson295189b2012-06-20 16:38:30 -07002404 // Find next active staId, to have a valid sta trigger for TL.
2405 if (fSuccess == TRUE)
2406 {
2407 if (del_idx == 0)
2408 {
2409 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
2410 {
2411 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
2412 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
2413 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
2414
2415 pHddStaCtx->conn_info.staId[valid_idx] = 0;
2416 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
2417 }
2418 }
2419 }
2420 return( fSuccess );
2421}
2422
2423/**============================================================================
2424 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002425 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07002426 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002427
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 ===========================================================================*/
2429static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
2430{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002431 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05302432 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2433 "%s: IBSS Connect Indication from SME!!! "
2434 "Set HDD connState to eConnectionState_IbssConnected",
2435 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002436 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
2437 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
2438
2439 // Save the connection info from CSR...
2440 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
2441
2442 // Send the bssid address to the wext.
2443 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002445 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2446 if (NULL == bss)
2447 {
2448 hddLog(VOS_TRACE_LEVEL_ERROR,
2449 "%s: %s: unable to create IBSS entry",
2450 __func__, pAdapter->dev->name);
2451 return eHAL_STATUS_FAILURE;
2452 }
Yue Maf49ba872013-08-19 12:04:25 -07002453 cfg80211_put_bss(
2454#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2455 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
2456#endif
2457 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07002458
2459 return( eHAL_STATUS_SUCCESS );
2460}
Mukul Sharmad2589a52014-04-23 21:06:25 +05302461
2462/**============================================================================
2463 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002464 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002465
Jeff Johnson295189b2012-06-20 16:38:30 -07002466 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002467static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2468 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002469 eCsrRoamResult roamResult )
2470{
2471 eCsrEncryptionType connectedCipherAlgo;
2472 v_BOOL_t fConnected = FALSE;
2473 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2474 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302475 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002476 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302477 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002479
2480 if (NULL == pRoamInfo)
2481 {
2482 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2483 return eHAL_STATUS_FAILURE;
2484 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002485 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002486 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 // not require upper layer authentication) we can put TL directly into 'authenticated'
2488 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2490 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2491 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002492
Jeff Johnson295189b2012-06-20 16:38:30 -07002493 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2494 if( fConnected )
2495 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002496 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2497 {
2498 v_U8_t staId;
2499
2500 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2501
2502 if ( 0 == memcmp( pRoamInfo->peerMac,
2503 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2504 {
2505 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2506 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05302507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2508 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002509 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2510 }
2511 else
2512 {
2513 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2514 (v_MACADDR_t*)pRoamInfo->peerMac,
2515 &staId);
2516 if ( VOS_STATUS_SUCCESS == vosStatus )
2517 {
2518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2519 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2520 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2521 staId);
2522 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2523 }
2524 }
2525 }
2526 else
2527 {
Bhargav Shaha805ef22015-07-29 17:31:38 +05302528 WLANTL_GetSTAState(pHddCtx->pvosContext,
2529 pHddStaCtx->conn_info.staId[0],
2530 &prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302531 // TODO: Considering getting a state machine in HDD later.
2532 // This routine is invoked twice. 1)set PTK 2)set GTK.
2533 // The folloing if statement will be TRUE when setting GTK.
2534 // At this time we don't handle the state in detail.
2535 // Related CR: 174048 - TL not in authenticated state
2536 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2537 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2538 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302539
2540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2541 "for StaId=%d. Changing TL state to AUTHENTICATED from"
2542 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302543
2544 // Connections that do not need Upper layer authentication,
2545 // transition TL to 'Authenticated' state after the keys are set.
2546 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2547 pHddStaCtx->conn_info.staId[ 0 ],
2548 WLANTL_STA_AUTHENTICATED );
2549
2550 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302551
2552 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2553 hdd_postTLPacketPendingInd(pAdapter,
2554 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05302555 //Need to call offload because when roaming happen at that time fwr
2556 //clean offload info as part of the DelBss
2557 // No need to configure offload if host was not suspended
2558 spin_lock(&pHddCtx->filter_lock);
2559 if(pHddCtx->hdd_wlan_suspended)
2560 {
2561 spin_unlock(&pHddCtx->filter_lock);
2562 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2563 }
2564 else
2565 {
2566 spin_unlock(&pHddCtx->filter_lock);
2567 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302568 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2569 {
2570 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2571 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302572 }
2573 else
2574 {
2575 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2576 pHddStaCtx->conn_info.staId[ 0 ]);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302577
2578 /* In case of OSEN move TL to 'Authenticated' after PTK is set */
2579 if (pWextState->roamProfile.bOSENAssociation == VOS_TRUE)
2580 {
2581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "PTK set"
2582 " for StaId=%d. Due to OSEN, Changing TL state to"
2583 "AUTHENTICATED from state:%d",
2584 pHddStaCtx->conn_info.staId[0], prevTLState);
2585
2586 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2587 pHddStaCtx->conn_info.staId[ 0 ],
2588 WLANTL_STA_AUTHENTICATED );
2589
2590 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
2591
2592 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2593 hdd_postTLPacketPendingInd(pAdapter,
2594 pHddStaCtx->conn_info.staId[0]);
2595 }
2596
2597
2598
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302599 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2600 {
2601 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2602 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302603 }
2604
2605 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302608 else
2609 {
2610 // possible disassoc after issuing set key and waiting set key complete
2611 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2612 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002613
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 EXIT();
2615 return( eHAL_STATUS_SUCCESS );
2616}
2617/**============================================================================
2618 *
2619 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2620 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002621static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002622 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002623{
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2625
2626 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2627 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2628 {
2629 struct iw_michaelmicfailure msg;
2630 union iwreq_data wreq;
2631 memset(&msg, '\0', sizeof(msg));
2632 msg.src_addr.sa_family = ARPHRD_ETHER;
2633 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002634 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2635 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002636
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2638 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002639 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 msg.flags = IW_MICFAILURE_PAIRWISE;
2641 memset(&wreq, 0, sizeof(wreq));
2642 wreq.data.length = sizeof(msg);
2643 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002645 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002646 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2647 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2648 NL80211_KEYTYPE_GROUP :
2649 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002650 pRoamInfo->u.pMICFailureInfo->keyId,
2651 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002652 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002653
Jeff Johnson295189b2012-06-20 16:38:30 -07002654 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002655
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 return( eHAL_STATUS_SUCCESS );
2657}
2658
2659/**============================================================================
2660 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002661 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002663
Jeff Johnson295189b2012-06-20 16:38:30 -07002664 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002665static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2666 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002667 eCsrRoamResult roamResult )
2668{
2669 VOS_STATUS vosStatus;
2670
2671 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2672 switch( roamResult )
2673 {
2674 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2675 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002676 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05302677 struct station_info *staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002678
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302679 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2680 "IBSS New Peer indication from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002681 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2682 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002684
Jeff Johnson295189b2012-06-20 16:38:30 -07002685 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2686
Shailender Karmuchia734f332013-04-19 14:02:48 -07002687 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2688 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2689 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2690
2691 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05302692 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 pRoamInfo,
2694 pRoamInfo->staId,
2695 (v_MACADDR_t *)pRoamInfo->peerMac,
2696 pRoamInfo->pBssDesc );
2697 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2698 {
2699 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002700 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 vosStatus, vosStatus );
2702 }
Abhishek Singhdecf1b62016-02-09 11:53:58 +05302703 if (!roamSaveIbssStation(pAdapter,
2704 pRoamInfo->staId,
2705 (v_MACADDR_t *)pRoamInfo->peerMac))
2706 {
2707 hddLog(LOGW, FL("Not Able to add sta in sta hash"));
2708 break;
2709 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002710 pHddStaCtx->ibss_sta_generation++;
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05302711
2712 staInfo = vos_mem_malloc(sizeof(*staInfo));
2713 if (staInfo == NULL) {
2714 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2715 "memory allocation for station_info failed");
2716 return eHAL_STATUS_FAILED_ALLOC;
2717 }
2718
2719 memset(staInfo, 0, sizeof(*staInfo));
2720 staInfo->filled = 0;
2721 staInfo->generation = pHddStaCtx->ibss_sta_generation;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002722
2723 cfg80211_new_sta(pAdapter->dev,
2724 (const u8 *)pRoamInfo->peerMac,
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05302725 staInfo, GFP_KERNEL);
2726 vos_mem_free(staInfo);
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
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302776 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2777 "IBSS Peer Departed from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002778 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 ?
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05302967 "LINK_ESTABLISH_REQ_RSP" :
2968 roamResult == eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP ?
2969 "CHANNEL_SWITCH_REQ_RSP" : "UNKNOWN",
Arif Hussain24bafea2013-11-15 15:10:03 -08002970 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002971 switch( roamResult )
2972 {
2973 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2974 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002975 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2976 {
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05302977 hddTdlsPeer_t *curr_peer;
2978
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002980 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05302981 wlan_hdd_tdls_check_bmps(pAdapter);
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05302982
2983 mutex_lock(&pHddCtx->tdls_lock);
2984 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
2985 pRoamInfo->peerMac, FALSE);
2986 if (NULL != curr_peer)
2987 curr_peer->link_status = eTDLS_LINK_TEARING;
2988 else
2989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2990 "%s %d curr_peer is Null", __func__,__LINE__);
2991 mutex_unlock(&pHddCtx->tdls_lock);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002992 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002993 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002994 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002995
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002996 /* check if there is available index for this new TDLS STA */
2997 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2998 {
2999 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
3000 {
3001 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
3002 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
3003
3004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003005 ("TDLS: STA IDX at %d is %d "
3006 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003007 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003008 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003009
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003010 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003011 (v_MACADDR_t *)pRoamInfo->peerMac) ;
3012 status = eHAL_STATUS_SUCCESS ;
3013 break ;
3014 }
3015 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003016 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003017 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003018 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003019 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3020 "wlan_hdd_tdls_set_sta_id() failed");
3021 return VOS_FALSE;
3022 }
3023
3024 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303025 /* store the ucast signature , if required for further reference. */
3026
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003027 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303028 /* start TDLS client registration with TL */
3029 status = hdd_roamRegisterTDLSSTA( pAdapter,
3030 pRoamInfo->peerMac,
3031 pRoamInfo->staId,
3032 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303033 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003034 }
3035 else
3036 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003037 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07003039 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003040 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003041 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003042 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003043 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003044 break ;
3045 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003046 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3047 {
3048 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3049 {
3050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3051 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3052 }
3053 /* store the ucast signature which will be used later when
3054 * registering to TL
3055 */
3056 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3057 complete(&pAdapter->tdls_add_station_comp);
3058 break;
3059 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303060 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3061 {
3062 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3063 {
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303064 hddTdlsPeer_t *curr_peer;
3065
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3067 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303068
3069 mutex_lock(&pHddCtx->tdls_lock);
3070 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3071 pRoamInfo->peerMac, FALSE);
3072 if (curr_peer)
3073 curr_peer->link_status = eTDLS_LINK_TEARING;
3074 else
3075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3076 "%s %d curr_peer is Null",__func__,__LINE__);
3077 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303078 }
3079 complete(&pAdapter->tdls_link_establish_req_comp);
3080 break;
3081 }
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303082 case eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP:
3083 {
3084 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3086 "%s: Channel switch request failed. %d", __func__,
3087 pRoamInfo->statusCode);
3088 else
3089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3090 "%s: Channel switch request Success", __func__);
3091 break;
3092 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003093 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003094 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003095 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003096 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003097 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003098 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3099 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003100 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003102 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3103
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303104 mutex_lock(&pHddCtx->tdls_lock);
3105 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3106 pRoamInfo->peerMac, FALSE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303107 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003108 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3110 " Current status for peer" MAC_ADDRESS_STR "is %d",
3111 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303112 if (TDLS_IS_CONNECTED(curr_peer) ||
3113 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303114 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303115 mutex_unlock(&pHddCtx->tdls_lock);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303116 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3117 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303118 else
3119 mutex_unlock(&pHddCtx->tdls_lock);
3120
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303121 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003122 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303123 else
3124 mutex_unlock(&pHddCtx->tdls_lock);
3125
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303126 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003127 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303128 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003129
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003130 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3131 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3132 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003133 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003134 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003135 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003136 break ;
3137 }
3138 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003139 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003140 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003141 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003142 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3143 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003144 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003145 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3146 "%s: Sending teardown to supplicant with reason code %u",
3147 __func__, pRoamInfo->reasonCode);
3148
3149#ifdef CONFIG_TDLS_IMPLICIT
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303150 mutex_lock(&pHddCtx->tdls_lock);
3151 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac,
3152 FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003153 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Abhishek Singh96568922016-01-05 15:28:12 +05303154 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3155 curr_peer->peerMac);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303156 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003157#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003158 status = eHAL_STATUS_SUCCESS ;
3159 break ;
3160 }
3161 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3162 {
3163 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003164 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003165 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003166 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3167 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003168 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003170 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003171 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003172 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303173
3174 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003175 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303176 mutex_unlock(&pHddCtx->tdls_lock);
3177
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003178 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3179 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003180
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003181 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003182 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003183 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3184 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003185
3186 status = eHAL_STATUS_SUCCESS ;
3187 }
3188 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303189 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003190 break ;
3191 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003192 default:
3193 {
3194 break ;
3195 }
3196 }
3197
3198 return status ;
3199}
3200#endif
3201
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05303202void iw_full_power_cbfn (void *pContext, eHalStatus status)
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003203{
3204 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3205 hdd_context_t *pHddCtx = NULL;
3206 int ret;
3207
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303208 ENTER();
3209
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003210 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3211 {
3212 hddLog(VOS_TRACE_LEVEL_ERROR,
3213 "%s: Bad param, pAdapter [%p]",
3214 __func__, pAdapter);
3215 return;
3216 }
3217
3218 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3219 ret = wlan_hdd_validate_context(pHddCtx);
3220 if (0 != ret)
3221 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003222 return;
3223 }
3224
3225 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3226 {
3227 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3228 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303229
3230 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003231}
3232
Shailender Karmuchia734f332013-04-19 14:02:48 -07003233eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3235{
3236 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
3237 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303238 hdd_wext_state_t *pWextState = NULL;
3239 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003240 VOS_STATUS status = VOS_STATUS_SUCCESS;
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05303241 struct cfg80211_bss *bss_status;
Amar Singhal49fdfd52013-08-13 13:25:12 -07003242 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003243
3244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003245 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003246 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003247
3248 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303249 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003250 {
3251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303252 "invalid adapter or adapter has invalid magic");
3253 return eHAL_STATUS_FAILURE;
3254 }
3255
3256 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3257 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3258
3259 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3260 {
3261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3262 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003263 return eHAL_STATUS_FAILURE;
3264 }
3265
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05303266 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
3267 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003268 switch( roamStatus )
3269 {
3270 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki41d95e22015-08-28 12:51:32 +05303271 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
3272 complete(&pAdapter->session_open_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003274
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003275#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
3276 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07003278 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 * interface down */
3280 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303281 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
3282 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05303283 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3285 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
3286 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3288 }
3289 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05303290 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 break;
3292
3293 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003294 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07003296 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07003297 // eCSR_ROAM_SHOULD_ROAM will be received.
3298 // Where in we will not mark the link down
3299 // Also we want to stop tx at this point when we will be
3300 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003301 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 {
3303 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303304 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303306 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3307 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3308 {
3309 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
3310 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003311 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303312 * Deregister this STA with TL, but do not flush the packets
3313 * for this STA from wmm_tx_queue. Since there is no valid STA
3314 * for these packets they will not be transmitted. Eventually
3315 * after the reassociation is successful, these packets will be
3316 * transmitted after registering STA with TL again. This ensures
3317 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003318 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303319 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
3320 pHddStaCtx->conn_info.staId[0]);
3321 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003322 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303323 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3324 FL("WLANTL_ClearSTAClient failed for staID %d."
3325 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
3326 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003327 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003328 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 }
3330 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003331 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 break;
3333#endif
3334
3335 case eCSR_ROAM_SHOULD_ROAM:
3336 // Dont need to do anything
3337 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 struct net_device *dev = pAdapter->dev;
3339 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3340 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303341 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003342 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003343#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 if (pHddStaCtx->ft_carrier_on == FALSE)
3345 {
3346#endif
3347 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003348#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003349 }
3350#endif
3351
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003352#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07003353 //We should clear all sta register with TL, for now, only one.
3354 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
3355 if ( !VOS_IS_STATUS_SUCCESS(status ) )
3356 {
3357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3358 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
3359 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003360 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003361 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003362#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 }
3364 break;
3365 case eCSR_ROAM_LOSTLINK:
3366 case eCSR_ROAM_DISASSOCIATED:
3367 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3369 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05303370 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3372 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07003373 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3374 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303375 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07003376 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08003377
3378 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
3379 pHddCtx->configuredMcastBcastFilter =
3380 pHddCtx->sus_res_mcastbcast_filter;
3381 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
3382 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303383
Amar Singhald53568e2013-09-26 11:03:45 -07003384 hddLog(VOS_TRACE_LEVEL_INFO,
3385 "offload: disassociation happening, restoring configuredMcastBcastFilter");
3386 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
3387 pHddCtx->configuredMcastBcastFilter);
3388 hddLog(VOS_TRACE_LEVEL_INFO,
3389 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3391 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003392#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303393 /* Call to clear any MC Addr List filter applied after
3394 * successful connection.
3395 */
3396 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003397#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003398 }
3399 break;
3400 case eCSR_ROAM_IBSS_LEAVE:
3401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3402 "****eCSR_ROAM_IBSS_LEAVE****");
3403 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3404 break;
3405 case eCSR_ROAM_ASSOCIATION_COMPLETION:
3406 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3407 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303408 // To Do - address probable memory leak with WEP encryption upon successful association
3409 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303411 //Clear saved connection information in HDD
3412 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003413 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303414 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003415
3416 break;
3417 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003418 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 pRoamInfo, roamId, roamStatus, roamResult );
3420 break;
3421 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07003422 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
3423 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 break;
3425
3426 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
3427 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003428 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003429
3430 case eCSR_ROAM_MIC_ERROR_IND:
3431 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3432 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05303433 case eCSR_ROAM_LOST_LINK_PARAMS_IND:
3434 {
3435 /*
3436 * The RSSI will be subtracted from 100 as FW is sending the RSSI by
3437 * adding the 100 value.
3438 */
3439 pAdapter->rssi_on_disconnect = pRoamInfo->u.pLostLinkParams->rssi - 100;
3440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3441 "%s : Rssi on Disconnect : %d",
3442 __func__, pAdapter->rssi_on_disconnect);
3443 break;
3444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003446 {
3447 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3448
3449 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003450 (TRUE == pHddCtx->hdd_wlan_suspended) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05303451 ((eCSR_ROAM_RESULT_NONE == roamResult)||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05303452 (pRoamInfo && pRoamInfo->is11rAssoc)))
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003453 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003454 /* Send DTIM period to the FW; only if the wlan is already
3455 in suspend. This is the case with roaming (reassoc),
3456 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
3457 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
3458 before the ENTER_BMPS_REQ ensures Listen Interval is
3459 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003460 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003461
3462 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003463 if due to unexpected scenario, if we are in BMPS,
3464 then trigger Exit and Enter BMPS to take DTIM period
3465 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003466 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
3467 {
3468 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
3469
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003470 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3471 iw_full_power_cbfn, pAdapter,
3472 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003473 }
3474 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303475
3476 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303477 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
3478 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05303479 ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05303480 (pRoamInfo && pRoamInfo->is11rAssoc)))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303481 {
3482 hddLog( LOG1, FL("Device in full power."
3483 "Stop and start traffic timer for roaming"));
3484 pmcStopTrafficTimer(pHddCtx->hHal);
3485 if (pmcStartTrafficTimer(pHddCtx->hHal,
3486 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
3487 {
3488 hddLog(LOGP, FL("Cannot start traffic timer"));
3489 }
3490 }
3491
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003492 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05303493 if ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05303494 (pRoamInfo && pRoamInfo->is11rAssoc))
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303495 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003497 break;
3498#ifdef WLAN_FEATURE_VOWIFI_11R
3499 case eCSR_ROAM_FT_RESPONSE:
3500 hdd_SendFTEvent(pAdapter);
3501 break;
3502#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07003503#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003504 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003505 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07003506 {
3507 /* Notify the supplicant of a new candidate */
3508 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
3509 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003510 break;
3511#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003512
Yue Maef608272013-04-08 23:09:17 -07003513#ifdef FEATURE_WLAN_LFR_METRICS
3514 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
3515 /* This event is to notify pre-auth initiation */
3516 if (VOS_STATUS_SUCCESS !=
3517 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
3518 {
3519 halStatus = eHAL_STATUS_FAILURE;
3520 }
3521 break;
3522 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
3523 /* This event will notify pre-auth completion in case of success */
3524 if (VOS_STATUS_SUCCESS !=
3525 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3526 pRoamInfo, 1))
3527 {
3528 halStatus = eHAL_STATUS_FAILURE;
3529 }
3530 break;
3531 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
3532 /* This event will notify pre-auth completion in case of failure. */
3533 if (VOS_STATUS_SUCCESS !=
3534 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3535 pRoamInfo, 0))
3536 {
3537 halStatus = eHAL_STATUS_FAILURE;
3538 }
3539 break;
3540 case eCSR_ROAM_HANDOVER_SUCCESS:
3541 /* This event is to notify handover success.
3542 It will be only invoked on success */
3543 if (VOS_STATUS_SUCCESS !=
3544 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
3545 {
3546 halStatus = eHAL_STATUS_FAILURE;
3547 }
3548 break;
3549#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 case eCSR_ROAM_REMAIN_CHAN_READY:
3551 hdd_remainChanReadyHandler( pAdapter );
3552 break;
3553 case eCSR_ROAM_SEND_ACTION_CNF:
3554 hdd_sendActionCnf( pAdapter,
3555 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
3556 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003557#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08003558 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003559 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08003560 roamId, roamStatus, roamResult );
3561 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003562 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
3563 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
3564 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003565#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003566#ifdef WLAN_FEATURE_11W
3567 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
3568 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
3569 pRoamInfo->pbFrames,
3570 pRoamInfo->frameType);
3571 break;
3572#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003573#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003574 case eCSR_ROAM_TSM_IE_IND:
3575 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
3576 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
3577 break;
3578
3579 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
3580 {
3581 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
3582 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
3583 {
3584 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
3585 }
3586 break;
3587 }
3588
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003589 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003590 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003591 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003592 break;
3593 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003594
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003595 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003596 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003597 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003598 break;
3599 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003600#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05303601 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
3602 {
3603 pAdapter->maxRateFlags = roamResult;
3604 break;
3605 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05303606 case eCSR_ROAM_UPDATE_SCAN_RESULT:
3607 if (pRoamInfo && pRoamInfo->pBssDesc) {
3608 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
3609 pRoamInfo->pBssDesc);
3610 if (bss_status)
3611 cfg80211_put_bss(
3612#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
3613 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
3614#endif
3615 bss_status);
3616 else
3617 hddLog(LOG1, FL("UPDATE_SCAN_RESULT returned NULL"));
3618 }
3619 break;
Girish Gowlia95daca2015-02-04 20:31:31 +05303620 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 break;
3622 }
3623 return( halStatus );
3624}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003625eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003626{
3627 eCsrAuthType auth_type;
3628 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003629 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 {
3631 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003632 } else
3633 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 {
3635 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003636 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003637#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003638 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 {
3640 // Check for 11r FT Authentication with PSK
3641 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003642 } else
3643 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 {
3645 // Check for 11R FT Authentication with 802.1X
3646 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003647 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003648#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003649#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003650 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003651 {
3652 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3653 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003654#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003655#ifdef WLAN_FEATURE_11W
3656 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3657 {
3658 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3659 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303660 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
3661 {
3662 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3663 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003664#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003665 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3667 }
3668 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003669}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003670
Shailender Karmuchia734f332013-04-19 14:02:48 -07003671eCsrAuthType
3672hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003673{
3674 eCsrAuthType auth_type;
3675 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003676 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 {
3678 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003679 } else
3680 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 {
3682 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003683 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003684#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003685 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 {
3687 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003688 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003689#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003690 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003691 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3692 }
3693 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3694 return auth_type;
3695}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003696
Shailender Karmuchia734f332013-04-19 14:02:48 -07003697eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003698hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003699{
3700 eCsrEncryptionType cipher_type;
3701 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003702 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 {
3704 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003705 }
3706 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 {
3708 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003709 }
3710 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 {
3712 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003713 }
3714 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003715 {
3716 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003717 }
3718 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3719 {
3720 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3721 }
3722 else
3723 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003724 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3725 }
3726 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3727 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003728}
Jeff Johnson295189b2012-06-20 16:38:30 -07003729/* To find if the MAC address is NULL */
3730static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3731{
3732 int i;
3733 for (i = 0; i < length; i++)
3734 {
3735 if (0x00 != (macAddr[i]))
3736 {
3737 return FALSE;
3738 }
3739 }
3740 return TRUE;
3741} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003742
Shailender Karmuchia734f332013-04-19 14:02:48 -07003743eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003744hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003745{
3746 eCsrEncryptionType cipher_type;
3747 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003748 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 {
3750 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003751 } else
3752 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 {
3754 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003755 } else
3756 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003757 {
3758 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003759 } else
3760 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003761 {
3762 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003763 } else
3764 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003766 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3767 } else
3768 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3770 }
3771 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3772 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003773}
Jeff Johnson295189b2012-06-20 16:38:30 -07003774
Shailender Karmuchia734f332013-04-19 14:02:48 -07003775static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3776 struct ether_addr *pBssid,
3777 eCsrEncryptionType *pEncryptType,
3778 eCsrEncryptionType *mcEncryptType,
3779 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003780#ifdef WLAN_FEATURE_11W
3781 u_int8_t *pMfpRequired,
3782 u_int8_t *pMfpCapable,
3783#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003784 u_int16_t gen_ie_len,
3785 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003786{
3787 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003788 eHalStatus result;
3789 tDot11fIERSN dot11RSNIE;
3790 tDot11fIEWPA dot11WPAIE;
3791 tANI_U32 i;
3792 tANI_U8 *pRsnIe;
3793 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003795 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003796
3797 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3798 flag to 0 */
3799 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3800 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3801
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003803 if ( gen_ie[0] == DOT11F_EID_RSN)
3804 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003806 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003807 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3808 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303809 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3810 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 return -EINVAL;
3812 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003813 // Skip past the EID byte and length byte
3814 pRsnIe = gen_ie + 2;
3815 RSNIeLen = gen_ie_len - 2;
3816 // Unpack the RSN IE
3817 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3818 pRsnIe,
3819 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003820 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003821 // Copy out the encryption and authentication types
3822 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003823 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003824 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003825 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003826 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 but probably I suspect we can do something different*/
3828 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003829 // Just translate the FIRST one
3830 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3831 //dot11RSNIE.pwise_cipher_suite_count
3832 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3833 //dot11RSNIE.gp_cipher_suite_count
3834 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003835#ifdef WLAN_FEATURE_11W
3836 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3837 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3838#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003839 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003840 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003842 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303844 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003845 break;
3846 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003847 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303849 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 break;
3851 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003852 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 // For right now, I assume setASSOCIATE() has passed in the bssid.
3854 vos_mem_copy(PMKIDCache[i].BSSID,
3855 pBssid, ETHER_ADDR_LEN);
3856 vos_mem_copy(PMKIDCache[i].PMKID,
3857 dot11RSNIE.pmkid[i],
3858 CSR_RSN_PMKID_SIZE);
3859 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003860
3861 if (updatePMKCache)
3862 {
3863 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003864 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003865 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003866 // Finally set the PMKSA ID Cache in CSR
3867 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3868 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303869 dot11RSNIE.pmkid_count,
3870 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07003871 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003872 }
3873 else if (gen_ie[0] == DOT11F_EID_WPA)
3874 {
3875 // Validity checks
3876 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3877 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3878 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303879 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3880 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003881 return -EINVAL;
3882 }
3883 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003884 pRsnIe = gen_ie + 2 + 4;
3885 RSNIeLen = gen_ie_len - (2 + 4);
3886 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3888 pRsnIe,
3889 RSNIeLen,
3890 &dot11WPAIE);
3891 // Copy out the encryption and authentication types
3892 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003893 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003895 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 //dot11WPAIE.auth_suite_count
3897 // Just translate the FIRST one
3898 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3899 //dot11WPAIE.unicast_cipher_count
3900 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3901 //dot11WPAIE.unicast_cipher_count
3902 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3903 }
3904 else
3905 {
3906 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003907 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003908 }
3909 return 0;
3910}
3911int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3912{
3913 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3914 v_U32_t status = 0;
3915 eCsrEncryptionType RSNEncryptType;
3916 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003917#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303918 u_int8_t RSNMfpRequired = 0;
3919 u_int8_t RSNMfpCapable = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07003920#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 struct ether_addr bSsid; // MAC address of assoc peer
3922 // MAC address of assoc peer
3923 // But, this routine is only called when we are NOT associated.
3924 vos_mem_copy(bSsid.ether_addr_octet,
3925 pWextState->roamProfile.BSSIDs.bssid,
3926 sizeof(bSsid.ether_addr_octet));
3927 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3928 {
3929 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003931 else
3932 {
3933 return 0;
3934 }
3935 // The actual processing may eventually be more extensive than this.
3936 // Right now, just consume any PMKIDs that are sent in by the app.
3937 status = hdd_ProcessGENIE(pAdapter,
3938 &bSsid, // MAC address of assoc peer
3939 &RSNEncryptType,
3940 &mcRSNEncryptType,
3941 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003942#ifdef WLAN_FEATURE_11W
3943 &RSNMfpRequired,
3944 &RSNMfpCapable,
3945#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003946 pWextState->WPARSNIE[1]+2,
3947 pWextState->WPARSNIE);
3948 if (status == 0)
3949 {
3950 // Now copy over all the security attributes you have parsed out
3951 pWextState->roamProfile.EncryptionType.numEntries = 1;
3952 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003953
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3955 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003956
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003957 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3958 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3959 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3960 {
3961 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3962 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3963 either AES/TKIP based on group cipher configuration
3964 mentioned in the wpa_supplicant.conf.*/
3965
3966 /*Set the unicast cipher same as multicast cipher*/
3967 pWextState->roamProfile.EncryptionType.encryptionType[0]
3968 = mcRSNEncryptType;
3969 }
3970
Chet Lanctot186b5732013-03-18 10:26:30 -07003971#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303972 hddLog( LOG1, FL("RSNMfpRequired = %d, RSNMfpCapable = %d"),
3973 RSNMfpRequired, RSNMfpCapable);
Chet Lanctot186b5732013-03-18 10:26:30 -07003974 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3975 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3976#endif
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303977 hddLog( LOG1,
3978 FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
3979 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003980 }
3981 return 0;
3982}
3983int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3984{
3985 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3986 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3987 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3988 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003989
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003991 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003992
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 switch( pHddStaCtx->conn_info.authType)
3994 {
3995 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003996#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003997 case eCSR_AUTH_TYPE_CCKM_WPA:
3998 case eCSR_AUTH_TYPE_CCKM_RSN:
3999#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004000 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
4001
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004003 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004005
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004006#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004007 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
4008 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4009 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004010 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004011 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
4012 } else
4013 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004014 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004015 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 } else
4017#endif
4018 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4019 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004020 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
4021 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004022 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4023 == IW_AUTH_KEY_MGMT_PSK) {
4024 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004025 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004026 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004027 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 }
4029 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004030#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004031 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
4032 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4033 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004034 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004035 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004036 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004037 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004038 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004039 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 } else
4041#endif
4042
4043#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004044 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
4045 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004047 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07004048 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004049 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4051 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004052 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 } else
4054#endif
4055
Chet Lanctot186b5732013-03-18 10:26:30 -07004056#ifdef WLAN_FEATURE_11W
4057 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
4058 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4059 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304060 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
4061 pRoamProfile->AuthType.authType[0] =
4062 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4063 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004064#endif
4065
Shailender Karmuchia734f332013-04-19 14:02:48 -07004066 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004068 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
4069 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4071 == IW_AUTH_KEY_MGMT_PSK) {
4072 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004073 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004077 break;
4078
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004080
4081 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 break;
4083 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004084
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004085#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08004086 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004087#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
4089 break;
4090 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004091
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004093 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004094
Jeff Johnson295189b2012-06-20 16:38:30 -07004095 EXIT();
4096 return 0;
4097}
4098
4099/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004100
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304101 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07004103 to the CSR roam profile.
4104
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 \param - dev - Pointer to the net device.
4106 - info - Pointer to the iw_request_info.
4107 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004108 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004110
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 --------------------------------------------------------------------------*/
4112
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304113int __iw_set_essid(struct net_device *dev,
4114 struct iw_request_info *info,
4115 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004116{
4117 v_U32_t status = 0;
4118 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304119 hdd_adapter_t *pAdapter;
4120 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 v_U32_t roamId;
4122 tCsrRoamProfile *pRoamProfile;
4123 eMib_dot11DesiredBssType connectedBssType;
4124 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304125 tHalHandle hHal;
4126 hdd_station_ctx_t *pHddStaCtx;
4127 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004128
Jeff Johnson295189b2012-06-20 16:38:30 -07004129 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304130 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4131 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004132 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304134 "%s: Adapter is NULL",__func__);
4135 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 }
4137
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304138 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4139 ret = wlan_hdd_validate_context(pHddCtx);
4140 if (0 != ret)
4141 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304142 return ret;
4143 }
4144
4145 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4146 if (NULL == hHal)
4147 {
4148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4149 "%s: Hal Context is NULL",__func__);
4150 return -EINVAL;
4151 }
4152 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4153 if (NULL == pHddStaCtx)
4154 {
4155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4156 "%s: STA Context is NULL",__func__);
4157 return -EINVAL;
4158 }
4159 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4160 if (NULL == pWextState)
4161 {
4162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4163 "%s: pWextState is NULL",__func__);
4164 return -EINVAL;
4165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
4167 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
4168 return -EBUSY;
4169 }
4170 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
4171 return -EINVAL;
4172 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004173 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004174 {
4175 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
4176 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
4177 {
4178 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004179 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4181 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
4182
4183 if(VOS_STATUS_SUCCESS == vosStatus)
4184 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
4185 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4186 }
4187 }
4188 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004189 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 {
4191 return -EINVAL;
4192 }
4193 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004194 /** when cfg80211 defined, wpa_supplicant wext driver uses
4195 zero-length, null-string ssid for force disconnection.
4196 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07004197 driver MUST return success */
4198 if ( 0 == wrqu->essid.length ) {
4199 return 0;
4200 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004201
4202 status = hdd_wmm_get_uapsd_mask(pAdapter,
4203 &pWextState->roamProfile.uapsd_mask);
4204 if (VOS_STATUS_SUCCESS != status)
4205 {
4206 pWextState->roamProfile.uapsd_mask = 0;
4207 }
4208 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004209
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004211
4212 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
4214 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
4215 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004216
Jeff Johnson295189b2012-06-20 16:38:30 -07004217 //set gen ie
4218 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
4219
4220 //set auth
4221 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
4222 }
4223#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004224 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 if (pAdapter->wapi_info.nWapiMode)
4226 {
4227 switch (pAdapter->wapi_info.wapiAuthMode)
4228 {
4229 case WAPI_AUTH_MODE_PSK:
4230 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004231 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 pRoamProfile->AuthType.numEntries = 1;
4233 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4234 break;
4235 }
4236 case WAPI_AUTH_MODE_CERT:
4237 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004238 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 pRoamProfile->AuthType.numEntries = 1;
4240 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4241 break;
4242 }
4243 } // End of switch
4244 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
4245 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
4246 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004247 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 pRoamProfile->EncryptionType.numEntries = 1;
4249 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4250 pRoamProfile->mcEncryptionType.numEntries = 1;
4251 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4252 }
4253 }
4254#endif /* FEATURE_WLAN_WAPI */
4255 /* if previous genIE is not NULL, update AssocIE */
4256 if (0 != pWextState->genIE.length)
4257 {
4258 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
4259 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
4260 pWextState->genIE.length);
4261 pWextState->assocAddIE.length = pWextState->genIE.length;
4262 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
4263 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
4264
4265 /* clear previous genIE after use it */
4266 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
4267 }
4268
4269 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
4270 pWextState->roamProfile.bWPSAssociation = FALSE;
4271
4272 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
4273 pWextState->roamProfile.nAddIEAssocLength))
4274 pWextState->roamProfile.bWPSAssociation = TRUE;
4275
4276
4277 // Disable auto BMPS entry by PMC until DHCP is done
4278 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
4279
Shailender Karmuchia734f332013-04-19 14:02:48 -07004280 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004281 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004282
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004283 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
4284 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004285 hdd_select_cbmode(pAdapter,
4286 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
4287 }
Agarwal Ashish40f9b872015-09-01 16:17:35 +05304288 /*
4289 * Change conn_state to connecting before sme_RoamConnect(),
4290 * because sme_RoamConnect() has a direct path to call
4291 * hdd_smeRoamCallback(), which will change the conn_state
4292 * If direct path, conn_state will be accordingly changed
4293 * to NotConnected or Associated by either
4294 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
4295 * in sme_RoamCallback()
4296 * if sme_RomConnect is to be queued,
4297 * Connecting state will remain until it is completed.
4298 *
4299 * If connection state is not changed,
4300 * connection state will remain in eConnectionState_NotConnected state.
4301 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
4302 * if conn state is eConnectionState_NotConnected.
4303 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
4304 * informed of connect result indication which is an issue.
4305 */
4306 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
4307 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
4308 {
4309 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4310 FL("Set HDD connState to eConnectionState_Connecting"));
4311 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
4312 eConnectionState_Connecting);
4313 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004314 status = sme_RoamConnect( hHal,pAdapter->sessionId,
4315 &(pWextState->roamProfile), &roamId);
Agarwal Ashish40f9b872015-09-01 16:17:35 +05304316
4317 if ((eHAL_STATUS_SUCCESS != status) &&
4318 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
4319 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4320 {
4321 hddLog(VOS_TRACE_LEVEL_ERROR,
4322 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
4323 pAdapter->sessionId, status);
4324 /* change back to NotAssociated */
4325 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
4326 eConnectionState_NotConnected);
4327 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004328 pRoamProfile->ChannelInfo.ChannelList = NULL;
4329 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004330
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004331 EXIT();
4332 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004333}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004334
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304335int iw_set_essid(struct net_device *dev,
4336 struct iw_request_info *info,
4337 union iwreq_data *wrqu, char *extra)
4338{
4339 int ret;
4340
4341 vos_ssr_protect(__func__);
4342 ret = __iw_set_essid(dev, info, wrqu, extra);
4343 vos_ssr_unprotect(__func__);
4344
4345 return ret;
4346}
4347
Jeff Johnson295189b2012-06-20 16:38:30 -07004348/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004349
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304350 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004352
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 \param - dev - Pointer to the net device.
4354 - info - Pointer to the iw_request_info.
4355 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004356 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004358
Jeff Johnson295189b2012-06-20 16:38:30 -07004359 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304360int __iw_get_essid(struct net_device *dev,
4361 struct iw_request_info *info,
4362 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004363{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304364 hdd_adapter_t *pAdapter;
4365 hdd_context_t *pHddCtx;
4366 hdd_wext_state_t *wextBuf;
4367 hdd_station_ctx_t *pHddStaCtx;
4368 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304369
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 ENTER();
4371
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304372 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4373 if (NULL == pAdapter)
4374 {
4375 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4376 "%s: Adapter is NULL",__func__);
4377 return -EINVAL;
4378 }
4379
4380 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4381 ret = wlan_hdd_validate_context(pHddCtx);
4382 if (0 != ret)
4383 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304384 return ret;
4385 }
4386
4387 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4388 if (NULL == pHddStaCtx)
4389 {
4390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4391 "%s: STA Context is NULL",__func__);
4392 return -EINVAL;
4393 }
4394
4395 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4396 if (NULL == wextBuf)
4397 {
4398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4399 "%s: wextBuf is NULL",__func__);
4400 return -EINVAL;
4401 }
4402
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
4404 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
4405 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
4406 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
4407 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
4408 {
4409 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
4410 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
4411 dwrq->flags = 1;
4412 } else {
4413 memset(extra, 0, dwrq->length);
4414 dwrq->length = 0;
4415 dwrq->flags = 0;
4416 }
4417 EXIT();
4418 return 0;
4419}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304420
4421int iw_get_essid(struct net_device *dev,
4422 struct iw_request_info *info,
4423 struct iw_point *dwrq, char *extra)
4424{
4425 int ret;
4426
4427 vos_ssr_protect(__func__);
4428 ret = __iw_get_essid(dev, info, dwrq, extra);
4429 vos_ssr_unprotect(__func__);
4430
4431 return ret;
4432}
Jeff Johnson295189b2012-06-20 16:38:30 -07004433/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004434
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304435 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004437
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 \param - dev - Pointer to the net device.
4439 - info - Pointer to the iw_request_info.
4440 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004441 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004442 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004443
Jeff Johnson295189b2012-06-20 16:38:30 -07004444 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304445int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
4446 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004447{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304448 hdd_adapter_t *pAdapter;
4449 hdd_context_t *pHddCtx;
4450 hdd_wext_state_t *pWextState;
4451 hdd_station_ctx_t *pHddStaCtx;
4452 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004453 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304455 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004456
Jeff Johnson295189b2012-06-20 16:38:30 -07004457 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004458
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304459 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4460 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004461 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4463 "%s: Adapter is NULL",__func__);
4464 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004465 }
4466
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304467 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4468 ret = wlan_hdd_validate_context(pHddCtx);
4469 if (0 != ret)
4470 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304471 return ret;
4472 }
4473
4474 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4475 if (NULL == pHddStaCtx)
4476 {
4477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4478 "%s: STA Context is NULL",__func__);
4479 return -EINVAL;
4480 }
4481
4482 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4483 if (NULL == pWextState)
4484 {
4485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4486 "%s: pWextState is NULL",__func__);
4487 return -EINVAL;
4488 }
4489
4490 pRoamProfile = &pWextState->roamProfile;
4491
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 switch(wrqu->param.flags & IW_AUTH_INDEX)
4493 {
4494 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004495
Jeff Johnson295189b2012-06-20 16:38:30 -07004496 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004497
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004499
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 case IW_AUTH_CIPHER_PAIRWISE:
4501 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004502 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004504 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4506 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004507 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
4509 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004510 }
4511
Jeff Johnson295189b2012-06-20 16:38:30 -07004512 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004513
4514 if( (IW_AUTH_KEY_MGMT_802_1X
4515 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
4517 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004518 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 else
4520 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004521 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004524
4525 if( ( IW_AUTH_KEY_MGMT_802_1X
4526 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4528 /*Dynamic WEP key*/
4529 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4530 else
4531 /*Static WEP key*/
4532 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004533
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 }
4535 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004536
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004538 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 return -EINVAL;
4540 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004541
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 pRoamProfile->EncryptionType.numEntries = 1;
4543 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 break;
4546 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004547 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
4549 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4550 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004551
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4553 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
4554 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004555
4556 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
4558 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004559
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004561
4562 if( ( IW_AUTH_KEY_MGMT_802_1X
4563 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
4564 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4565
Jeff Johnson295189b2012-06-20 16:38:30 -07004566 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004567
4568 else
4569 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004571
4572 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
4573 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004575 if( ( IW_AUTH_KEY_MGMT_802_1X
4576 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4578 {
4579 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4580 }
4581 else
4582 {
4583 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4584 }
4585 }
4586 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004587
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004589 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 return -EINVAL;
4591 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004592
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 pRoamProfile->mcEncryptionType.numEntries = 1;
4594 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
4595 }
4596 break;
4597
4598 case IW_AUTH_80211_AUTH_ALG:
4599 {
4600 /*Save the auth algo here and set auth type to SME Roam profile
4601 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004602 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004604
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
4606 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
4607
4608 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
4609 /*Not supported*/
4610 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4611 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4612 }
4613 break;
4614
4615 case IW_AUTH_KEY_MGMT:
4616 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004617#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004618#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
4619 /*Check for CCKM AKM type */
4620 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004621 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
4622 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004623 /* Set the CCKM bit in authKeyMgmt */
4624 /* Right now, this breaks all ref to authKeyMgmt because our
4625 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07004626 */
4627 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
4628 /*Set the key management to 802.1X*/
4629 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004630 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4632 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
4633 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
4634 /*Save the key management*/
4635 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
4636 //pWextState->authKeyMgmt = wrqu->param.value;
4637 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4638 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4639 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
4640 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
4641 /*Save the key management anyway*/
4642 pWextState->authKeyMgmt = wrqu->param.value;
4643 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
4644 /*Save the key management*/
4645 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
4646 //pWextState->authKeyMgmt = wrqu->param.value;
4647 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4648 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4649 }
4650#else
4651 /*Save the key management*/
4652 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004653#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 }
4655 break;
4656
4657 case IW_AUTH_TKIP_COUNTERMEASURES:
4658 {
4659 if(wrqu->param.value) {
4660 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4661 "Counter Measure started %d", wrqu->param.value);
4662 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
4663 }
4664 else {
4665 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4666 "Counter Measure stopped=%d", wrqu->param.value);
4667 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4668 }
4669 }
4670 break;
4671 case IW_AUTH_DROP_UNENCRYPTED:
4672 case IW_AUTH_WPA_ENABLED:
4673 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
4674 case IW_AUTH_ROAMING_CONTROL:
4675 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004676
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004678
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004679 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 wrqu->param.flags & IW_AUTH_INDEX);
4681 break;
4682 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004683
Jeff Johnson295189b2012-06-20 16:38:30 -07004684 EXIT();
4685 return 0;
4686}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304687
4688int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
4689 union iwreq_data *wrqu, char *extra)
4690{
4691 int ret;
4692
4693 vos_ssr_protect(__func__);
4694 ret = __iw_set_auth(dev, info, wrqu, extra);
4695 vos_ssr_unprotect(__func__);
4696
4697 return ret;
4698}
4699
Jeff Johnson295189b2012-06-20 16:38:30 -07004700/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004701
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304702 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004703 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004704
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 \param - dev - Pointer to the net device.
4706 - info - Pointer to the iw_request_info.
4707 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004708 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004710
Jeff Johnson295189b2012-06-20 16:38:30 -07004711 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304712int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4713 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004714{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304715 hdd_adapter_t* pAdapter;
4716 hdd_wext_state_t *pWextState;
4717 tCsrRoamProfile *pRoamProfile;
4718 hdd_context_t *pHddCtx;
4719 int ret = 0;
4720
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004722
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304723 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4724 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004725 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4727 "%s: Adapter is NULL",__func__);
4728 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004729 }
4730
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304731 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4732 ret = wlan_hdd_validate_context(pHddCtx);
4733 if (0 != ret)
4734 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304735 return ret;
4736 }
4737
4738 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4739 if (NULL == pWextState)
4740 {
4741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4742 "%s: pWextState is NULL",__func__);
4743 return -EINVAL;
4744 }
4745 pRoamProfile = &pWextState->roamProfile;
4746
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 switch(pRoamProfile->negotiatedAuthType)
4748 {
4749 case eCSR_AUTH_TYPE_WPA_NONE:
4750 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4751 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
4752 break;
4753 case eCSR_AUTH_TYPE_WPA:
4754 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4755 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
4756 break;
4757#ifdef WLAN_FEATURE_VOWIFI_11R
4758 case eCSR_AUTH_TYPE_FT_RSN:
4759#endif
4760 case eCSR_AUTH_TYPE_RSN:
4761 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4762 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
4763 break;
4764 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4765 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4766 break;
4767 case eCSR_AUTH_TYPE_SHARED_KEY:
4768 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
4769 break;
4770 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004771 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004772 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4773 break;
4774 case eCSR_AUTH_TYPE_AUTOSWITCH:
4775 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4776 break;
4777 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304778 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004779 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4780 return -EIO;
4781#ifdef WLAN_FEATURE_VOWIFI_11R
4782 case eCSR_AUTH_TYPE_FT_RSN_PSK:
4783#endif
4784 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07004785#ifdef WLAN_FEATURE_11W
4786 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05304787 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07004788#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05304789 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4791 return -EIO;
4792 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304793 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004794 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4795 return -EIO;
4796 }
4797 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
4798 {
4799 switch(pRoamProfile->negotiatedUCEncryptionType)
4800 {
4801 case eCSR_ENCRYPT_TYPE_NONE:
4802 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4803 break;
4804 case eCSR_ENCRYPT_TYPE_WEP40:
4805 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4806 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4807 break;
4808 case eCSR_ENCRYPT_TYPE_TKIP:
4809 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4810 break;
4811 case eCSR_ENCRYPT_TYPE_WEP104:
4812 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4813 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4814 break;
4815 case eCSR_ENCRYPT_TYPE_AES:
4816 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4817 break;
4818 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304819 hddLog(LOG1, "%s called with unknown auth type %d ",
4820 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 return -EIO;
4822 }
4823 }
4824
Shailender Karmuchia734f332013-04-19 14:02:48 -07004825 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004826 {
4827 switch(pRoamProfile->negotiatedMCEncryptionType)
4828 {
4829 case eCSR_ENCRYPT_TYPE_NONE:
4830 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4831 break;
4832 case eCSR_ENCRYPT_TYPE_WEP40:
4833 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4834 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4835 break;
4836 case eCSR_ENCRYPT_TYPE_TKIP:
4837 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4838 break;
4839 case eCSR_ENCRYPT_TYPE_WEP104:
4840 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4841 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4842 break;
4843 case eCSR_ENCRYPT_TYPE_AES:
4844 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4845 break;
4846 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304847 hddLog(LOG1, "%s called with unknown auth type %d ",
4848 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 return -EIO;
4850 }
4851 }
4852
4853 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004854 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 EXIT();
4856 return 0;
4857}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304858
4859int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4860 union iwreq_data *wrqu,char *extra)
4861{
4862 int ret;
4863
4864 vos_ssr_protect(__func__);
4865 ret = __iw_get_auth(dev, info, wrqu, extra);
4866 vos_ssr_unprotect(__func__);
4867
4868 return ret;
4869}
4870
Jeff Johnson295189b2012-06-20 16:38:30 -07004871/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004872
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304873 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07004874 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004875 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004876
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 \param - dev - Pointer to the net device.
4878 - info - Pointer to the iw_request_info.
4879 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004880 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004882
Jeff Johnson295189b2012-06-20 16:38:30 -07004883 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304884int __iw_set_ap_address(struct net_device *dev,
4885 struct iw_request_info *info,
4886 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004887{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304888 hdd_station_ctx_t *pHddStaCtx;
4889 hdd_adapter_t *pAdapter;
4890 hdd_context_t *pHddCtx;
4891 v_U8_t *pMacAddress = NULL;
4892 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304893
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304895
4896 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4897 if (NULL == pAdapter)
4898 {
4899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4900 "%s: Adapter is NULL", __func__);
4901 return -EINVAL;
4902 }
4903 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4904 ret = wlan_hdd_validate_context(pHddCtx);
4905 if (0 != ret)
4906 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304907 return ret;
4908 }
4909 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4910 if (NULL == pHddStaCtx)
4911 {
4912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4913 "%s: pHddStaCtx is NULL", __func__);
4914 return -EINVAL;
4915 }
4916
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4919 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004920 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07004921
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304922 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004923 return 0;
4924}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304925
4926int iw_set_ap_address(struct net_device *dev,
4927 struct iw_request_info *info,
4928 union iwreq_data *wrqu, char *extra)
4929{
4930 int ret;
4931
4932 vos_ssr_protect(__func__);
4933 ret = __iw_set_ap_address(dev, info, wrqu, extra);
4934 vos_ssr_unprotect(__func__);
4935
4936 return ret;
4937}
4938
Jeff Johnson295189b2012-06-20 16:38:30 -07004939/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004940
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304941 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 This function returns the BSSID to the wpa_supplicant
4943 \param - dev - Pointer to the net device.
4944 - info - Pointer to the iw_request_info.
4945 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004946 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004948
Jeff Johnson295189b2012-06-20 16:38:30 -07004949 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304950int __iw_get_ap_address(struct net_device *dev,
4951 struct iw_request_info *info,
4952 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004953{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304954 hdd_station_ctx_t *pHddStaCtx;
4955 hdd_adapter_t *pAdapter;
4956 hdd_context_t *pHddCtx;
4957 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304958
Jeff Johnson295189b2012-06-20 16:38:30 -07004959 ENTER();
4960
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304961 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4962 if (NULL == pAdapter)
4963 {
4964 hddLog(VOS_TRACE_LEVEL_ERROR,
4965 "%s: Adapter is NULL", __func__);
4966 return -EINVAL;
4967 }
4968 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4969 ret = wlan_hdd_validate_context(pHddCtx);
4970 if (0 != ret)
4971 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304972 return ret;
4973 }
4974 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4975 if (NULL == pHddStaCtx)
4976 {
4977 hddLog(VOS_TRACE_LEVEL_ERROR,
4978 "%s: pHddStaCtx is NULL", __func__);
4979 return -EINVAL;
4980 }
4981
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4983 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4984 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004985 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 }
4987 else
4988 {
4989 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4990 }
4991 EXIT();
4992 return 0;
4993}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004994
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304995int iw_get_ap_address(struct net_device *dev,
4996 struct iw_request_info *info,
4997 union iwreq_data *wrqu, char *extra)
4998{
4999 int ret;
5000
5001 vos_ssr_protect(__func__);
5002 ret = __iw_get_ap_address(dev, info, wrqu, extra);
5003 vos_ssr_unprotect(__func__);
5004
5005 return ret;
5006}
5007
Chet Lanctot186b5732013-03-18 10:26:30 -07005008#ifdef WLAN_FEATURE_11W
5009/**---------------------------------------------------------------------------
5010
5011 \brief hdd_indicateUnprotMgmtFrame -
5012 This function forwards the unprotected management frame to the supplicant
5013 \param - pAdapter - Pointer to HDD adapter
5014 - nFrameLength - Length of the unprotected frame being passed
5015 - pbFrames - Pointer to the frame buffer
5016 - frameType - 802.11 frame type
5017 \return - nothing
5018
5019 --------------------------------------------------------------------------*/
5020void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
5021 tANI_U32 nFrameLength,
5022 tANI_U8* pbFrames,
5023 tANI_U8 frameType )
5024{
5025 tANI_U8 type = 0;
5026 tANI_U8 subType = 0;
5027
5028 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
5029 __func__, frameType, nFrameLength);
5030
5031 /* Sanity Checks */
5032 if (NULL == pAdapter)
5033 {
5034 hddLog( LOGE, FL("pAdapter is NULL"));
5035 return;
5036 }
5037
5038 if (NULL == pAdapter->dev)
5039 {
5040 hddLog( LOGE, FL("pAdapter->dev is NULL"));
5041 return;
5042 }
5043
5044 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
5045 {
5046 hddLog( LOGE, FL("pAdapter has invalid magic"));
5047 return;
5048 }
5049
5050 if( !nFrameLength )
5051 {
5052 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
5053 return;
5054 }
5055
5056 if (NULL == pbFrames) {
5057 hddLog( LOGE, FL("pbFrames is NULL"));
5058 return;
5059 }
5060
5061 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
5062 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
5063
5064 /* Get pAdapter from Destination mac address of the frame */
5065 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
5066 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305067#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5068 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5069#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005070 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305071#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005072 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
5073 }
5074 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
5075 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305076#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5077 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5078#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005079 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305080#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005081 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
5082 }
5083 else
5084 {
5085 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
5086 return;
5087 }
5088}
5089#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005090
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005091#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005092void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
5093 tANI_U8 state,
5094 tANI_U16 measInterval )
5095{
5096 union iwreq_data wrqu;
5097 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005098 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005099
5100 if (NULL == pAdapter)
5101 return;
5102
5103 // create the event
5104 memset(&wrqu, '\0', sizeof(wrqu));
5105 memset(buf, '\0', sizeof(buf));
5106
5107 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
5108 tid, state, measInterval);
5109
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005110 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005111
5112 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005113 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005114 // send the event
5115 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5116}
5117
5118void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
5119{
5120 union iwreq_data wrqu;
5121 char buf[IW_CUSTOM_MAX + 1];
5122 char *pos = buf;
5123 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5124
5125 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5126 return;
5127
5128 // create the event
5129 memset(&wrqu, '\0', sizeof(wrqu));
5130 memset(buf, '\0', sizeof(buf));
5131
5132 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305133 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
5134 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
5135 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
5136 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005137
5138 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
5139 pos += nBytes;
5140 freeBytes -= nBytes;
5141
5142 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
5143 pos += WNI_CFG_BSSID_LEN;
5144 freeBytes -= WNI_CFG_BSSID_LEN;
5145
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005146 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
5147 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005148
5149 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005150 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005151
5152 // send the event
5153 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5154}
5155
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005156void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005157{
5158 union iwreq_data wrqu;
5159 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005160 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005161
5162 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5163 return;
5164
5165 // create the event
5166 memset(&wrqu, '\0', sizeof(wrqu));
5167 memset(buf, '\0', sizeof(buf));
5168
5169 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
5170
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005171 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005172
5173 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005174 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005175
5176 // send the event
5177 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5178}
5179
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005180void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
5181 const tANI_U16 measurementToken,
5182 const tANI_BOOLEAN flag,
5183 const tANI_U8 numBss)
5184{
5185 union iwreq_data wrqu;
5186 char buf[IW_CUSTOM_MAX];
5187 char *pos = buf;
5188 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5189
5190 memset(&wrqu, '\0', sizeof(wrqu));
5191 memset(buf, '\0', sizeof(buf));
5192
5193 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
5194 numBss);
5195
5196 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
5197 flag, numBss);
5198
5199 wrqu.data.pointer = buf;
5200 wrqu.data.length = nBytes;
5201 // send the event
5202 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5203}
5204
5205
5206static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005207 const tCsrRoamInfo *pRoamInfo)
5208{
5209 union iwreq_data wrqu;
5210 char buf[IW_CUSTOM_MAX + 1];
5211 char *pos = buf;
5212 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5213 tANI_U8 i = 0, len = 0;
5214 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
5215 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005216 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
5217 tANI_U8 ieLenByte = 1;
5218 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
5219#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005220
5221 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5222 return;
5223
5224 /* Custom event can pass maximum of 256 bytes of data,
5225 based on the IE len we need to identify how many BSS info can
5226 be filled in to custom event data */
5227 /*
5228 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
5229 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
5230 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
5231 */
5232
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005233 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005234 {
5235 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
5236 /* If the measurement is none and no scan results found,
5237 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005238 hdd_indicateEseBcnReportNoResults(pAdapter,
5239 pRoamInfo->pEseBcnReportRsp->measurementToken,
5240 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005241 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005242 }
5243 else
5244 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005245 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005246 {
5247 memset(&wrqu, '\0', sizeof(wrqu));
5248 memset(buf, '\0', sizeof(buf));
5249 tot_bcn_ieLen = 0;
5250 sendBss = 0;
5251 pos = buf;
5252 freeBytes = IW_CUSTOM_MAX;
5253
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005254 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005255 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005256 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
5257 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005258 {
5259 break;
5260 }
5261 tot_bcn_ieLen += len;
5262 sendBss++;
5263 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
5264 "IeLength(%d) Length of Ie(%d) totLen(%d)",
5265 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005266 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005267 tot_bcn_ieLen);
5268 }
5269
5270 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
5271 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005272 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5273 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005274
5275 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005276 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5277 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005278 pos += nBytes;
5279 freeBytes -= nBytes;
5280
5281 /* Copy total Beacon report data length */
5282 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
5283 pos += sizeof(tot_bcn_ieLen);
5284 freeBytes -= sizeof(tot_bcn_ieLen);
5285
5286 for (i = 0; i < sendBss; i++)
5287 {
5288 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305289 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
5290 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005291 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005292 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
5293 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
5294 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
5295 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
5296 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
5297 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
5298 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
5299 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
5300 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
5301 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
5302 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
5303 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
5304 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
5305 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
5306 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
5307 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005308
5309 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005310 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
5311 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005312 pos += len;
5313 freeBytes -= len;
5314
5315 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005316 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005317 vos_mem_copy(pos, (char*)&len, sizeof(len));
5318 pos += sizeof(len);
5319 freeBytes -= sizeof(len);
5320
5321 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005322 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005323 pos += len;
5324 freeBytes -= len;
5325 }
5326
5327 wrqu.data.pointer = buf;
5328 wrqu.data.length = strlen(buf);
5329
5330 // send the event
5331 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5332 lastSent += sendBss;
5333 }
5334 }
5335}
5336
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005337#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005338