blob: 0bcc98a702d52ed39f699460af15dc8b91020b08 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028/**========================================================================
29
30 \file wlan_hdd_assoc.c
31 \brief WLAN Host Device Driver implementation
Shailender Karmuchia734f332013-04-19 14:02:48 -070032
Jeff Johnson295189b2012-06-20 16:38:30 -070033 ========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070034/**=========================================================================
35 EDIT HISTORY FOR FILE
36
37
38 This section contains comments describing changes made to the module.
39 Notice that changes are listed in reverse chronological order.
40
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070046 -------- --- --------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -070047 05/06/09 Shailender Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070048 ==========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070049
Jeff Johnson295189b2012-06-20 16:38:30 -070050#include "wlan_hdd_includes.h"
51#include <aniGlobal.h>
52#include "dot11f.h"
53#include "wlan_nlink_common.h"
54#include "wlan_btc_svc.h"
55#include "wlan_hdd_power.h"
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +053056#include "wlan_hdd_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070057#include <linux/ieee80211.h>
58#include <linux/wireless.h>
59#include <net/cfg80211.h>
60#include "wlan_hdd_cfg80211.h"
61#include "csrInsideApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include "wlan_hdd_p2p.h"
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053063#include <vos_sched.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080064#ifdef FEATURE_WLAN_TDLS
65#include "wlan_hdd_tdls.h"
66#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070067#include "sme_Api.h"
Sushant Kaushikba6764e2014-06-30 19:52:09 +053068#include "wlan_hdd_hostapd.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053069#include "vos_utils.h"
Siddharth Bhalda0d1622015-04-24 15:47:49 +053070#include <wlan_hdd_wext.h>
Mukul Sharma84f27252014-07-14 18:11:42 +053071
Jeff Johnson295189b2012-06-20 16:38:30 -070072v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
73
Shailender Karmuchia734f332013-04-19 14:02:48 -070074struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -070075{
76 u_char ether_addr_octet[6];
77};
78// These are needed to recognize WPA and RSN suite types
79#define HDD_WPA_OUI_SIZE 4
80v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
81v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
82v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
83v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
84v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
85v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080086#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070087v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080088#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070089#define HDD_RSN_OUI_SIZE 4
90v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
91v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
92v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
93v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
94v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
95v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080096#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070097v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080098#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -070099#ifdef WLAN_FEATURE_11W
100v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
Abhishek Singhae408032014-09-25 17:22:04 +0530101/* RSN-8021X-SHA256 */
102v_U8_t ccpRSNOui08[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 };
Chet Lanctot186b5732013-03-18 10:26:30 -0700103#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700104
Shailender Karmuchia734f332013-04-19 14:02:48 -0700105#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700106// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700107#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
108#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700109#endif
110
111#define BEACON_FRAME_IES_OFFSET 12
112
Chet Lanctot186b5732013-03-18 10:26:30 -0700113#ifdef WLAN_FEATURE_11W
114void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
115 tANI_U32 nFrameLength,
116 tANI_U8* pbFrames,
117 tANI_U8 frameType );
118#endif
119
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800120#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700121static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
122 tANI_U8 state,
123 tANI_U16 measInterval );
124static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800125static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
126static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700127
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800128#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700129
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530130static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
131 tCsrRoamInfo *pRoamInfo,
132 tANI_U32 roamId,
133 eRoamCmdStatus roamStatus,
134 eCsrRoamResult roamResult );
135
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530136v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
137 eConnectionState connState )
138{
139 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530140 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
141 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700142 pHddStaCtx->conn_info.connState = connState;
143}
144
145// returns FALSE if not connected.
146// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
147// returns the connection state. Can specify NULL if you dont' want to get the actual state.
148
Shailender Karmuchia734f332013-04-19 14:02:48 -0700149static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
150 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700151{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700152 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700153 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700154
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 // get the connection state.
156 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700157 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700158 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700159 eConnectionState_IbssConnected == connState ||
160 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 {
162 fConnected = VOS_TRUE;
163 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700164 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700165 {
166 fConnected = VOS_FALSE;
167 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700168
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 if ( pConnState )
170 {
171 *pConnState = connState;
172 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700173
Jeff Johnson295189b2012-06-20 16:38:30 -0700174 return( fConnected );
175}
176
177v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
178{
179 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700180}
Jeff Johnson295189b2012-06-20 16:38:30 -0700181
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530182eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
183{
184 v_U8_t staChannel = 0;
185
186 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
187 {
188 staChannel = pHddStaCtx->conn_info.operationChannel;
189 }
190
191 if ( staChannel > 0 && staChannel < 14 )
192 return eCSR_BAND_24;
193 else if (staChannel >= 36 && staChannel <= 165 )
194 return eCSR_BAND_5G;
195 else /* If station is not connected return as eCSR_BAND_ALL */
196 return eCSR_BAND_ALL;
197}
198
199
Jeff Johnson295189b2012-06-20 16:38:30 -0700200//TODO - Not used anyhwere. Can be removed.
201#if 0
202//
203v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
204{
205 v_BOOL_t fConnectedInfra = FALSE;
206 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700207
Jeff Johnson295189b2012-06-20 16:38:30 -0700208 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700209 {
210 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700211 {
212 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700213 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700215
Jeff Johnson295189b2012-06-20 16:38:30 -0700216 return( fConnectedInfra );
217}
218#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700219
Jeff Johnson295189b2012-06-20 16:38:30 -0700220static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
221{
222 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700223
Jeff Johnson295189b2012-06-20 16:38:30 -0700224 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700225
226 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700227 {
228 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
229 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700230
Jeff Johnson295189b2012-06-20 16:38:30 -0700231 return( fConnected );
232}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700233
Jeff Johnson295189b2012-06-20 16:38:30 -0700234inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
235{
236 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700237
Jeff Johnson295189b2012-06-20 16:38:30 -0700238 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700239
240 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700241 {
242 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
243 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700244
Jeff Johnson295189b2012-06-20 16:38:30 -0700245 return( fConnected );
246}
247
248static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
249{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700250 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700251 {
252 case eCSR_BSS_TYPE_INFRASTRUCTURE:
253 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
254 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700255
Jeff Johnson295189b2012-06-20 16:38:30 -0700256 case eCSR_BSS_TYPE_IBSS:
257 case eCSR_BSS_TYPE_START_IBSS:
258 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
259 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700260
261 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700262 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700263 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700264 default:
265 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700266 break;
267 }
268
Jeff Johnson295189b2012-06-20 16:38:30 -0700269}
270
271void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
272{
273 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
274 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700275
Jeff Johnson295189b2012-06-20 16:38:30 -0700276 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700277
278 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700279 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700280 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
282 {
283 VOS_ASSERT( pRoamInfo->pBssDesc );
284 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
285
286 // Save the Station ID for this station from the 'Roam Info'.
287 //For IBSS mode, staId is assigned in NEW_PEER_IND
288 //For reassoc, the staID doesn't change and it may be invalid in this structure
289 //so no change here.
290 if( !pRoamInfo->fReassocReq )
291 {
292 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
293 }
294 }
295 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700296 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700298 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 else
300 {
301 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
302 // or we can't function.
303 VOS_ASSERT( 0 );
304 }
305
306 // notify WMM
307 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
308
309 if( !pRoamInfo->u.pConnectedProfile )
310 {
311 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
312 }
313 else
314 {
315 // Get Multicast Encryption Type
316 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
317 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
318 // Get Unicast Encrytion Type
319 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
320 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
321
322 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
323
324 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
325
326 // Save the ssid for the connection
327 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530328
329 // Save dot11mode in which STA associated to AP
330 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
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
Arif Hussain77d044f2014-01-03 19:56:04 -0800672 pr_info("wlan: " MAC_ADDRESS_STR " connected to " MAC_ADDRESS_STR "\n",
673 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
Kiet Lam34947452014-01-21 23:23:40 -0800674 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
676
677 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
678 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
679 * and fFTEnable is TRUE */
680#ifdef WLAN_FEATURE_VOWIFI_11R
681 // Send FT Keys to the supplicant when FT is enabled
682 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700683 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800684#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700685 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
686 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
687#endif
688 )
689 {
690 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
691 }
692#endif
693 }
694 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
695 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530696 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -0700697 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 type = WLAN_STA_ASSOC_DONE_IND;
Arif Hussain24bafea2013-11-15 15:10:03 -0800699 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR"\n",
700 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700701 }
702 else /* Not Associated */
703 {
704 pr_info("wlan: disconnected\n");
705 type = WLAN_STA_DISASSOC_DONE_IND;
706 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
707 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700708 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700709
710 msg = NULL;
711 /*During the WLAN uninitialization,supplicant is stopped before the
712 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530713 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 {
715 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800716#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700718 {
719 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
720 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
722 }
723#endif
724 }
725 send_btc_nlink_msg(type, 0);
726}
727
728void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
729{
730 // Remove staId, bssId and peerMacAddress
731 pHddStaCtx->conn_info.staId [ 0 ] = 0;
732 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
733 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
734
735 // Clear all security settings
736 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
737 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
738 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
739
740 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700741 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700742
743 // Set not-connected state
744 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700745
746 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
747}
Katya Nigam47528772015-02-11 12:24:49 +0530748
749VOS_STATUS hdd_ibss_deinit_tx_rx_sta ( hdd_adapter_t *pAdapter, v_U8_t STAId )
750{
Katya Nigam1fd24402015-02-16 14:52:19 +0530751 v_U8_t ac;
752 /**Track whether OS TX queue has been disabled.*/
753 v_BOOL_t txSuspended[NUM_TX_QUEUES];
754 v_U8_t tlAC;
Katya Nigam47528772015-02-11 12:24:49 +0530755 v_U8_t i;
756 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
757 hdd_ibss_peer_info_t *pPeerInfo;
758
759 if( NULL == pHddStaCtx )
760 {
761 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
762 "%s: HDD station context NULL ",__func__);
763 return VOS_STATUS_E_FAILURE;
764 }
Katya Nigam1fd24402015-02-16 14:52:19 +0530765
Katya Nigam47528772015-02-11 12:24:49 +0530766 pPeerInfo = &pHddStaCtx->ibss_peer_info;
767 if (FALSE == pPeerInfo->ibssStaInfo[STAId].isUsed)
768 {
769 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
770 "%s: Deinit station not inited %d", __func__, STAId );
771 return VOS_STATUS_E_FAILURE;
772 }
773
774 hdd_flush_ibss_tx_queues(pAdapter, STAId);
Katya Nigam1fd24402015-02-16 14:52:19 +0530775
776 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
777 {
778 tlAC = hdd_QdiscAcToTlAC[ac];
779 txSuspended[ac] = pPeerInfo->ibssStaInfo[STAId].txSuspended[tlAC];
780 }
781
Katya Nigam47528772015-02-11 12:24:49 +0530782 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
783
Katya Nigam1fd24402015-02-16 14:52:19 +0530784 /* re-init hdd list, since netdev can still open adapter until
785 * driver gets unloaded
786 */
787 for (i = 0; i < NUM_TX_QUEUES; i ++)
788 {
789 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i],
790 HDD_TX_QUEUE_MAX_LEN);
791 }
792
793 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
794 {
795 if (txSuspended[ac])
796 {
797 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
798 "%s: TX queue re-enabled", __func__);
799 netif_wake_subqueue(pAdapter->dev, ac);
800 }
801 }
Katya Nigam47528772015-02-11 12:24:49 +0530802 return VOS_STATUS_SUCCESS;
803}
804
805static VOS_STATUS hdd_ibss_DeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
806{
807 VOS_STATUS vosStatus;
808
809 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
810 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
811 {
812 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
813 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
814 "Status= %d [0x%08X]",
815 __func__, staId, vosStatus, vosStatus );
816 }
817
818 vosStatus = hdd_ibss_deinit_tx_rx_sta ( pAdapter, staId );
819 if( VOS_STATUS_E_FAILURE == vosStatus )
820 {
821 VOS_TRACE ( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
822 "hdd_ibss_deinit_tx_rx_sta() failed for staID %d. "
823 "Status = %d [0x%08X]",
824 staId, vosStatus, vosStatus );
825 }
826
827 return( vosStatus );
828}
829
830VOS_STATUS hdd_ibss_init_tx_rx_sta( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA)
831{
832 v_U8_t i = 0;
833 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
834 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
835
836 if (pPeerInfo->ibssStaInfo[STAId].isUsed)
837 {
838 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
839 "%s: Reinit station %d", __func__, STAId );
840 return VOS_STATUS_E_FAILURE;
841 }
842
843 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
844 for (i = 0; i < NUM_TX_QUEUES; i ++)
845 {
846 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i], HDD_TX_QUEUE_MAX_LEN);
847 }
848
849 pPeerInfo->ibssStaInfo[STAId].isUsed = VOS_TRUE;
850 pPeerInfo->ibssStaInfo[STAId].isDeauthInProgress = VOS_FALSE;
851 vos_copy_macaddr( &pPeerInfo->ibssStaInfo[STAId].macAddrSTA, pmacAddrSTA);
852
853 return VOS_STATUS_SUCCESS;
854}
855
856static VOS_STATUS hdd_ibss_RegisterSTA( hdd_adapter_t *pAdapter,
857 tCsrRoamInfo *pRoamInfo,
858 v_U8_t staId,
859 v_MACADDR_t *pPeerMacAddress,
860 tSirBssDescription *pBssDesc )
861{
862 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
863 WLAN_STADescType staDesc = {0};
864 eCsrEncryptionType connectedCipherAlgo;
865 v_BOOL_t fConnected;
866 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
867 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
868 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
869
870 if ( pPeerInfo->ibssStaInfo[staId].isUsed )
871 {
872 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
873 "clean up old entry for STA %d", staId);
874 hdd_ibss_DeregisterSTA( pAdapter, staId );
875 }
876
877 staDesc.ucSTAId = staId;
878 staDesc.wSTAType = WLAN_STA_IBSS;
879
880 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
881 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
882 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
883 // pass when making an Infrastructure connection.
884 vos_mem_copy(staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes));
885 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId, 6 );
886 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
887
888 if (hdd_wmm_is_active(pAdapter))
889 {
890 staDesc.ucQosEnabled = 1;
891 }
892 else
893 {
894 staDesc.ucQosEnabled = 0;
895 }
896 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
897 "HDD SOFTAP register TL QoS_enabled=%d",
898 staDesc.ucQosEnabled );
899
900 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
901 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
902 {
903 staDesc.ucProtectedFrame = 1;
904 }
905 else
906 {
907 staDesc.ucProtectedFrame = 0;
908
909 }
910
911 hdd_ibss_init_tx_rx_sta(pAdapter, staId, &staDesc.vSTAMACAddress);
912
913 // UMA is Not ready yet, Xlation will be done by TL
914 staDesc.ucSwFrameTXXlation = 1;
915 staDesc.ucSwFrameRXXlation = 1;
916 staDesc.ucAddRmvLLC = 1;
917 // Initialize signatures and state
918 staDesc.ucUcastSig = pRoamInfo->ucastSig;
919 staDesc.ucBcastSig = pRoamInfo->bcastSig;
920 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED;
921
922 staDesc.ucIsReplayCheckValid = VOS_FALSE;
923
924 // Register the Station with TL.
925 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
926 hdd_rx_packet_cbk,
927 hdd_tx_complete_cbk,
928 hdd_ibss_tx_fetch_packet_cbk, &staDesc,
929 pBssDesc->rssi );
930 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
931 {
932 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
933 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
934 vosStatus, vosStatus );
935 return vosStatus;
936 }
937
938 //Timer value should be in milliseconds
939 if ( pHddCtx->cfg_ini->dynSplitscan &&
940 ( VOS_TIMER_STATE_RUNNING !=
941 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
942 {
943 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
944 pHddCtx->cfg_ini->trafficMntrTmrForSplitScan);
945 }
946
947 pPeerInfo->ibssStaInfo[staId].ucSTAId = staId;
948 pPeerInfo->ibssStaInfo[staId].isQosEnabled = staDesc.ucQosEnabled;
949
950 vosStatus = WLANTL_ChangeSTAState( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId,
951 WLANTL_STA_AUTHENTICATED );
952
953 pPeerInfo->ibssStaInfo[staId].tlSTAState = WLANTL_STA_AUTHENTICATED;
954 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
955
956 return( vosStatus );
957}
958
Jeff Johnson295189b2012-06-20 16:38:30 -0700959/* TODO Revist this function. and data path */
960static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
961{
962 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700963
Katya Nigam47528772015-02-11 12:24:49 +0530964 hdd_disconnect_tx_rx(pAdapter);
Ravi Joshif9520d62013-10-18 04:11:46 -0700965
Jeff Johnson295189b2012-06-20 16:38:30 -0700966 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
967 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
968 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530969 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700971 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700972 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700973 }
974 return( vosStatus );
975}
976
977
978static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
979 tANI_U32 roamId, eRoamCmdStatus roamStatus,
980 eCsrRoamResult roamResult )
981{
982 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700983 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 struct net_device *dev = pAdapter->dev;
985 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
986 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700987 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530988 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700989
990 // Sanity check
991 if(dev == NULL)
992 {
Agarwal Ashish971c2882013-10-30 20:11:12 +0530993 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700994 "%s: net_dev is released return", __func__);
995 return eHAL_STATUS_FAILURE;
996 }
997
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530999 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 netif_tx_disable(dev);
1001 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +05301002 //TxTimeoutCount need to reset in case of disconnect handler
1003 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001004
Jeff Johnsone7245742012-09-05 17:12:55 -07001005 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301006 /* HDD has initiated disconnect, do not send disconnect indication
1007 * to kernel as it will be handled by __cfg80211_disconnect.
1008 */
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301009 /* If only STA mode is on */
1010 if((pHddCtx->concurrency_mode <= 1) &&
1011 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
1012 {
1013 pHddCtx->isAmpAllowed = VOS_TRUE;
1014 }
1015
Agarwal Ashish47d18112014-08-04 19:55:07 +05301016 /* Need to apply spin lock before decreasing active sessions
1017 * as there can be chance for double decrement if context switch
1018 * Calls wlan_hdd_disconnect.
1019 */
1020
1021 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301022 if ( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState )
1023 {
1024 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1025 FL(" HDD has initiated a disconnect, no need to send"
1026 " disconnect indication to kernel"));
1027 sendDisconInd = FALSE;
1028 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301029 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301031 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +05301032 FL(" Set HDD connState to eConnectionState_Disconnecting from %d "),
1033 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301034 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
1035 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 }
Agarwal Ashish47d18112014-08-04 19:55:07 +05301037 spin_unlock_bh(&pAdapter->lock_for_active_session);
1038
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -07001040
1041 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07001042
1043 // indicate 'disconnect' status to wpa_supplicant...
1044 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 /* indicate disconnected event to nl80211 */
1046 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
1047 {
1048 /*During the WLAN uninitialization,supplicant is stopped before the
1049 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301050 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001051 {
Sushant Kaushik0b343422015-05-25 17:15:55 +05301052 if (sendDisconInd)
1053 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1054 "%s: sent disconnected event to nl80211",
1055 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001056#ifdef WLAN_FEATURE_P2P_DEBUG
1057 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1058 {
1059 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
1060 {
1061 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
1062 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
1063 "and moved to disconnected state");
1064 }
1065 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
1066 {
1067 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
1068 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
1069 "and moved to inactive state");
1070 }
1071 }
1072#endif
Sushant Kaushikbad61892015-07-10 16:43:28 +05301073 if ((roamStatus == eCSR_ROAM_LOSTLINK) &&
1074 !pRoamInfo->reasonCode)
1075 wlan_hdd_get_frame_logs(pAdapter,
1076 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301077 /*Only send indication to kernel if not initiated by kernel*/
1078 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301080 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
1081 if ( eCSR_ROAM_LOSTLINK == roamStatus )
1082 {
1083 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
1084 }
1085 else
1086 {
1087 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
1088 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001089 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301090 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
Masti, Narayanraddi70e5b472015-08-04 12:54:16 +05301091 (TRUE == sme_IsFeatureSupportedByFW(TDLS)) &&
1092 (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode_last ||
1093 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY ==
1094 pHddCtx->tdls_mode_last)) {
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301095 if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION)
1096 /* Enable TDLS support Once P2P session ends since
1097 * upond detection of concurrency TDLS would be disabled
1098 */
Masti, Narayanraddi70e5b472015-08-04 12:54:16 +05301099 wlan_hdd_tdls_set_mode(pHddCtx, pHddCtx->tdls_mode_last,
1100 FALSE);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001102 //If the Device Mode is Station
1103 // and the P2P Client is Connected
1104 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001105
1106 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001107 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001108 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001109 {
1110 //Enable BMPS only of other Session is P2P Client
1111 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001112 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001113
1114 if (NULL != pVosContext)
1115 {
1116 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1117
1118 if(NULL != pHddCtx)
1119 {
1120 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301121 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1122 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301124 if (pHddCtx->hdd_wlan_suspended)
1125 {
1126 hdd_set_pwrparams(pHddCtx);
1127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301129 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 }
1131 }
1132 }
1133 }
1134 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001135
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301136 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +05301137#if defined(WLAN_FEATURE_VOWIFI_11R)
1138 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1139#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301140
1141 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1142 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301143 v_U8_t i;
1144
Katya Nigam63ce1772014-09-26 15:53:49 +05301145 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301146 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301147 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1148 {
1149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301150 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1151 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301152 sta_id, status, status );
1153
1154 status = eHAL_STATUS_FAILURE;
1155 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301156 pHddCtx->sta_to_adapter[sta_id] = NULL;
1157
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301158 /*Clear all the peer sta register with TL.*/
1159 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1160 {
1161 if (0 != pHddStaCtx->conn_info.staId[i])
1162 {
1163 sta_id = pHddStaCtx->conn_info.staId[i];
1164
1165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1166 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301167 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301168 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1169 {
1170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1171 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1172 "Status= %d [0x%x]"),
1173 sta_id, status, status );
1174 status = eHAL_STATUS_FAILURE;
1175 }
1176
Nirav Shah7e3c8132015-06-22 23:51:42 +05301177 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1178 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1179 if (vstatus != VOS_STATUS_SUCCESS) {
1180 hddLog(VOS_TRACE_LEVEL_ERROR,
1181 FL("Not able to remove staid hash %d"),
1182 sta_id);
1183 status = eHAL_STATUS_FAILURE;
1184 } else {
1185 hddLog(VOS_TRACE_LEVEL_INFO,
1186 FL("ibss station removed sta_id %d mac:"
1187 MAC_ADDRESS_STR), sta_id,
1188 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1189 }
1190
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301191 /*set the staid and peer mac as 0, all other reset are
1192 * done in hdd_connRemoveConnectInfo.
1193 */
1194 pHddStaCtx->conn_info.staId[i]= 0;
1195 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1196
1197 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1198 pHddCtx->sta_to_adapter[sta_id] = NULL;
1199 }
1200 }
1201
Katya Nigam63ce1772014-09-26 15:53:49 +05301202 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301203 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001204 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301205 sta_id = pHddStaCtx->conn_info.staId[0];
1206
1207 //We should clear all sta register with TL, for now, only one.
1208 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1209 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1210 {
1211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1212 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1213 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001214 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001215
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301216 status = eHAL_STATUS_FAILURE;
1217 }
1218
1219 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301221
1222#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1223 if (VOS_STATUS_SUCCESS !=
1224 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1225 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1226 {
1227 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1228 "WLANTL_ClearInterfaceStats Failed", __func__);
1229 }
1230 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1231 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1232 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1233 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1234#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1235
Jeff Johnson295189b2012-06-20 16:38:30 -07001236 // Clear saved connection information in HDD
1237 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +05301238 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1239 "%s: Set HDD connState to eConnectionState_NotConnected",
1240 __func__);
1241 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301242#ifdef WLAN_FEATURE_GTK_OFFLOAD
1243 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1244 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1245 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301246 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1247 sizeof (tSirGtkOffloadParams));
1248 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301249 }
1250#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001251
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001252#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001253 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1254 {
1255 wlan_hdd_tdls_disconnection_callback(pAdapter);
1256 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001257#endif
1258
Jeff Johnson295189b2012-06-20 16:38:30 -07001259 //Unblock anyone waiting for disconnect to complete
1260 complete(&pAdapter->disconnect_comp_var);
1261 return( status );
1262}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301263
1264static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
1265 v_U8_t staId)
1266{
1267 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1268 v_SINT_t i;
1269 v_SIZE_t size;
1270 VOS_STATUS status;
1271 v_BOOL_t granted = VOS_FALSE;
1272
1273 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1274 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
1275 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
1276 {
1277 //Indicate to TL that there is pending data if a queue is non empty
1278 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
1279 {
1280 size = 0;
1281 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
1282 if (size > 0)
1283 {
1284 if (i != WLANTL_AC_HIGH_PRIO)
1285 {
1286 if (VOS_FALSE ==
1287 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
1288 {
1289 hdd_wmm_acquire_access(pAdapter,
1290 (WLANTL_ACEnumType)i, &granted);
1291 pAdapter->psbChanged |= (1 << i);
1292 }
1293 else
1294 granted = VOS_TRUE;
1295 }
1296
1297 if (granted || (i == WLANTL_AC_HIGH_PRIO))
1298 {
1299 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
1300 staId, (WLANTL_ACEnumType)i);
1301 if (!VOS_IS_STATUS_SUCCESS(status))
1302 {
1303 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1304 "%s: Failure in indicating pkt to TL for QID=%d",
1305 __func__, i);
1306 }
1307 }
1308 }
1309 }
1310 }
1311}
1312
Jeff Johnson295189b2012-06-20 16:38:30 -07001313static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
1314 tCsrRoamInfo *pRoamInfo,
1315 v_U8_t staId,
1316 v_MACADDR_t *pPeerMacAddress,
1317 tSirBssDescription *pBssDesc )
1318{
1319 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1320 WLAN_STADescType staDesc = {0};
1321 eCsrEncryptionType connectedCipherAlgo;
1322 v_BOOL_t fConnected;
1323 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1324 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001325 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001326
1327 if ( NULL == pBssDesc)
1328 {
1329 return VOS_STATUS_E_FAILURE;
1330 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 // Get the Station ID from the one saved during the assocation.
1332 staDesc.ucSTAId = staId;
1333
Katya Nigam47528772015-02-11 12:24:49 +05301334 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001335
Katya Nigam47528772015-02-11 12:24:49 +05301336 // grab the bssid from the connection info in the adapter structure and hand that
1337 // over to TL when registering.
1338 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
1339 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001340
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1342
1343 // set the QoS field appropriately
1344 if (hdd_wmm_is_active(pAdapter))
1345 {
1346 staDesc.ucQosEnabled = 1;
1347 }
1348 else
1349 {
1350 staDesc.ucQosEnabled = 0;
1351 }
1352
1353 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1354 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1355 {
1356 staDesc.ucProtectedFrame = 1;
1357 }
1358 else
1359 {
1360 staDesc.ucProtectedFrame = 0;
1361
1362 }
1363
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001364#ifdef FEATURE_WLAN_ESE
1365 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1366#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001367
1368#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1369 /* check whether replay check is valid for the station or not */
1370 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1371 {
1372 /* Encryption mode is either TKIP or AES
1373 and replay check is valid for only these
1374 two encryption modes */
1375 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1376 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1377 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1378 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001379
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 else
1381 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001382 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001384 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1386 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1387 }
1388#endif
1389
1390#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001391 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 if (pAdapter->wapi_info.fIsWapiSta)
1393 {
1394 staDesc.ucIsWapiSta = 1;
1395 }
1396 else
1397 {
1398 staDesc.ucIsWapiSta = 0;
1399 }
1400#endif /* FEATURE_WLAN_WAPI */
1401
1402 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1403 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1404
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 // UMA is Not ready yet, Xlation will be done by TL
1406 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 staDesc.ucSwFrameRXXlation = 1;
1408 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001409 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 staDesc.ucQosEnabled );
1411 // Initialize signatures and state
1412 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1413 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1414 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1415 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001416 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001417 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 -07001418 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1419 hdd_rx_packet_cbk,
1420 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 hdd_tx_fetch_packet_cbk, &staDesc,
1422 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001423
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1425 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001426 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001427 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001429 return vosStatus;
1430 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001431
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001432 if ( cfg_param->dynSplitscan &&
1433 ( VOS_TIMER_STATE_RUNNING !=
1434 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1435 {
1436 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1437 cfg_param->trafficMntrTmrForSplitScan);
1438 }
1439
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301440 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1441 // then go to 'authenticated'. For all other authentication types
1442 // (those that donot require upper layer authentication) we can put
1443 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001444 if (staDesc.wSTAType != WLAN_STA_IBSS)
1445 VOS_ASSERT( fConnected );
1446
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301447 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001448 {
1449 // Connections that do not need Upper layer auth, transition TL directly
1450 // to 'Authenticated' state.
1451 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1452 WLANTL_STA_AUTHENTICATED );
1453
1454 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301455
1456 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001457 }
1458 else
1459 {
1460 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301461 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1462 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001463 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301464 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001465 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1466 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001467 return( vosStatus );
1468}
1469
Jeff Johnson295189b2012-06-20 16:38:30 -07001470static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1471 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1472{
1473 unsigned int len = 0;
1474 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001475 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 tANI_U32 rspRsnLength = 0;
1477 struct ieee80211_channel *chan;
1478
Agarwal Ashish51325b52014-06-16 16:50:49 +05301479 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001480 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001481 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001482 }
1483
Agarwal Ashish51325b52014-06-16 16:50:49 +05301484 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001485 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1486 goto done;
1487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001488
Agarwal Ashish51325b52014-06-16 16:50:49 +05301489 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001490 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1491 goto done;
1492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001493
1494 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1495 pCsrRoamInfo->nAssocReqLength);
1496 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001497 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001498
1499 //pFTAssocRsp needs to point to the IEs
1500 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001501 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001502 (unsigned int)pFTAssocRsp[0],
1503 (unsigned int)pFTAssocRsp[1]);
1504
1505 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001506 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001509 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001510
1511 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1512 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1513 reqRsnIe, reqRsnLength,
1514 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001515
1516done:
1517 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001518}
Jeff Johnson295189b2012-06-20 16:38:30 -07001519
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301520void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1521{
1522 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1523 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1524 tCsrRoamInfo roamInfo;
1525 roamInfo.fAuthRequired = FALSE;
1526 vos_mem_copy(roamInfo.bssid,
1527 pHddStaCtx->roam_info.bssid,
1528 WNI_CFG_BSSID_LEN);
1529 vos_mem_copy(roamInfo.peerMac,
1530 pHddStaCtx->roam_info.peerMac,
1531 WNI_CFG_BSSID_LEN);
1532
1533 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1534 &roamInfo,
1535 pHddStaCtx->roam_info.roamId,
1536 pHddStaCtx->roam_info.roamStatus,
1537 eCSR_ROAM_RESULT_AUTHENTICATED);
1538 if (halStatus != eHAL_STATUS_SUCCESS)
1539 {
1540 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1541 }
1542 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1543}
1544
Shailender Karmuchia734f332013-04-19 14:02:48 -07001545static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1546 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 eCsrRoamResult roamResult )
1548{
1549 struct net_device *dev = pAdapter->dev;
1550 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1551 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301552 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05301553 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001554 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1555 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001556#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 int ft_carrier_on = FALSE;
1558#endif
1559 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301560 v_BOOL_t hddDisconInProgress = FALSE;
1561
1562 /* HDD has initiated disconnect, do not send connect result indication
1563 * to kernel as it will be handled by __cfg80211_disconnect.
1564 */
1565 if(( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) &&
1566 (( eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1567 ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)) )
1568 {
1569 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1570 FL(" Disconnect from HDD in progress "));
1571 hddDisconInProgress = TRUE;
1572 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001573
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1575 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301576 if ( !hddDisconInProgress )
1577 {
1578 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301579 "%s: Set HDD connState to eConnectionState_Associated",
1580 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301581 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001583
c_hpothu44ff4e02014-05-08 00:13:57 +05301584 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 // Save the connection info from CSR...
1586 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1587#ifdef FEATURE_WLAN_WAPI
1588 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1589 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1590 {
1591 pAdapter->wapi_info.fIsWapiSta = 1;
1592 }
1593 else
1594 {
1595 pAdapter->wapi_info.fIsWapiSta = 0;
1596 }
1597#endif /* FEATURE_WLAN_WAPI */
1598
1599 // indicate 'connect' status to userspace
1600 hdd_SendAssociationEvent(dev,pRoamInfo);
1601
1602
Shailender Karmuchia734f332013-04-19 14:02:48 -07001603 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 INIT_COMPLETION(pAdapter->linkup_event_var);
1605
1606 /*
1607 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1608 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 -07001609 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 know that the device is getting activated properly.
1611 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001612#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05301613 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 {
1615#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001616 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 pAdapter->isLinkUpSvcNeeded = TRUE;
1618
Shailender Karmuchia734f332013-04-19 14:02:48 -07001619 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 pAdapter->isLinkUpSvcNeeded = TRUE;
1621
1622 // Switch on the Carrier to activate the device
1623 netif_carrier_on(dev);
1624
1625 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1626 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1627 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001628 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 {
1630 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1631 }
1632
1633 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1634 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001635#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001636 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001637 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001638 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001639 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001640 }
1641#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301642 /* Check for STAID */
1643 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1644 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1645 else
1646 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001647
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001648#ifdef FEATURE_WLAN_TDLS
1649 wlan_hdd_tdls_connection_callback(pAdapter);
1650#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001651 //For reassoc, the station is already registered, all we need is to change the state
1652 //of the STA in TL.
1653 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05301654 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 if( !pRoamInfo->fReassocReq )
1656 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001657 struct cfg80211_bss *bss;
1658#ifdef WLAN_FEATURE_VOWIFI_11R
1659 u8 *pFTAssocRsp = NULL;
1660 unsigned int assocRsplen = 0;
1661 u8 *pFTAssocReq = NULL;
1662 unsigned int assocReqlen = 0;
1663 struct ieee80211_channel *chan;
1664#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001667
1668 /* add bss_id to cfg80211 data base */
1669 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1670 if (NULL == bss)
1671 {
1672 pr_err("wlan: Not able to create BSS entry\n");
Katya Nigam346d4e92014-09-02 16:16:12 +05301673 netif_carrier_off(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 return eHAL_STATUS_FAILURE;
1675 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001676#ifdef WLAN_FEATURE_VOWIFI_11R
1677 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001678 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001679 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001680
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001681 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001682 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001683 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001684 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001685 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001686 // pFTAssocRsp needs to point to the IEs
1687 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1688 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1689 (unsigned int)pFTAssocRsp[0],
1690 (unsigned int)pFTAssocRsp[1]);
1691 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001692 }
1693 else
1694 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001695 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1696 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001697 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001698
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001699 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001700 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001701 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001702 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001703 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001704 if(!ft_carrier_on)
1705 {
1706 // pFTAssocReq needs to point to the IEs
1707 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1708 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1709 (unsigned int)pFTAssocReq[0],
1710 (unsigned int)pFTAssocReq[1]);
1711 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1712 }
1713 else
1714 {
1715 /* This should contain only the FTIEs */
1716 assocReqlen = pRoamInfo->nAssocReqLength;
1717 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001718 }
1719 else
1720 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001721 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1722 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001723 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001724
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001725 if(ft_carrier_on)
1726 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301727 if ( !hddDisconInProgress )
1728 {
1729 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001730 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301731 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001732 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301733 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001734 assocRsplen);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301735 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1736 {
1737 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1738 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301739 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001740 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1741 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301742 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301743 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1744 {
1745 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1746 pRoamInfo->fAuthRequired = FALSE;
1747
1748 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1749 pRoamInfo->bssid,
1750 HDD_MAC_ADDR_LEN);
1751 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1752 pRoamInfo->peerMac,
1753 HDD_MAC_ADDR_LEN);
1754 pHddStaCtx->roam_info.roamId = roamId;
1755 pHddStaCtx->roam_info.roamStatus = roamStatus;
1756 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1757 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001758 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301759 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001760 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001761 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001762 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001763 cfg80211_connect_result(dev, pRoamInfo->bssid,
1764 pFTAssocReq, assocReqlen,
1765 pFTAssocRsp, assocRsplen,
1766 WLAN_STATUS_SUCCESS,
1767 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001768 }
1769 }
1770 else
1771#endif
1772 {
1773 /* wpa supplicant expecting WPA/RSN IE in connect result */
1774 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1775 pAdapter->sessionId,
1776 &reqRsnLength,
1777 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001778
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001779 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1780 pAdapter->sessionId,
1781 &rspRsnLength,
1782 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301783 if ( !hddDisconInProgress )
1784 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001785#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301786 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301787 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301788 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301789 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1790 {
1791 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1792 }
Mukul Sharma84f27252014-07-14 18:11:42 +05301793 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301794 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001795#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001796
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301797 {
1798 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301799 "%s: sending connect indication to nl80211:"
1800 " for bssid " MAC_ADDRESS_STR
1801 " reason:%d and Status:%d\n",
1802 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1803 roamResult, roamStatus);
1804
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301805 /* inform connect result to nl80211 */
1806 cfg80211_connect_result(dev, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001807 reqRsnIe, reqRsnLength,
1808 rspRsnIe, rspRsnLength,
1809 WLAN_STATUS_SUCCESS,
1810 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301811 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001812 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001813 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301814 if ( !hddDisconInProgress )
1815 {
1816 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001817#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301818 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001819#endif
1820 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301821 // Register the Station with TL after associated...
1822 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001823 pRoamInfo,
1824 pHddStaCtx->conn_info.staId[ 0 ],
1825 NULL,
1826 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 }
1829 else
1830 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001831 /* wpa supplicant expecting WPA/RSN IE in connect result */
1832 /* in case of reassociation also need to indicate it to supplicant */
1833 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1834 pAdapter->sessionId,
1835 &reqRsnLength,
1836 reqRsnIe);
1837
1838 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301840 if( pRoamInfo->fAuthRequired )
1841 {
1842 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1843 pHddStaCtx->conn_info.staId[ 0 ],
1844 WLANTL_STA_CONNECTED );
1845 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1846 }
1847 else
1848 {
1849 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1850 "%s: staId: %d Changing TL state to AUTHENTICATED",
1851 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1852 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1853 pHddStaCtx->conn_info.staId[ 0 ],
1854 WLANTL_STA_AUTHENTICATED );
1855 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301856 hdd_postTLPacketPendingInd(pAdapter,
1857 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 }
1860
1861 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1862 {
1863 // perform any WMM-related association processing
1864 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1865 }
1866 else
1867 {
1868 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001869 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 vosStatus, vosStatus );
1871 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001872#ifdef WLAN_FEATURE_11W
1873 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1874 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1875#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301876
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05301878 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301879 {
1880 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05301881 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301882 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301883 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1884 {
1885 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1886 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001887 }
1888 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1891
1892 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001893 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001894 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1895 " reason:%d and Status:%d\n",
1896 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1897 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001898 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001899 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1900 " reason:%d and Status:%d\n",
1901 MAC_ADDR_ARRAY(pWextState->req_bssId),
1902 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001903
Abhishek Singh611295e2015-07-09 11:11:54 +05301904 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)
1905 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05301906 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
1907
Abhishek Singhf4669da2014-05-26 15:07:49 +05301908 /* Set connection state to eConnectionState_NotConnected only when CSR
1909 * has completed operation - with a ASSOCIATION_FAILURE status
1910 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301911 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301912 {
1913 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1914 "%s: Set HDD connState to eConnectionState_NotConnected",
1915 __func__);
1916 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1917 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05301918 if((pHddCtx->concurrency_mode <= 1) &&
1919 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 {
1921 pHddCtx->isAmpAllowed = VOS_TRUE;
1922 }
1923
1924 //If the Device Mode is Station
1925 // and the P2P Client is Connected
1926 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001927
1928 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001929 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001930 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1931 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05301932 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 {
1934 //Enable BMPS only of other Session is P2P Client
1935 hdd_context_t *pHddCtx = NULL;
1936 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1937
1938 if (NULL != pVosContext)
1939 {
1940 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1941
1942 if(NULL != pHddCtx)
1943 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301944 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301945 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1946 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301947 {
1948 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001949 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301950 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001951 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301952 hdd_enable_bmps_imps(pHddCtx);
1953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 }
1955 }
1956 }
1957
James Zmudafbf5ffc2013-03-25 12:45:35 -07001958 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001959 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301960 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07001961 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301962 if (pRoamInfo)
1963 hddLog(VOS_TRACE_LEVEL_ERROR,
1964 "%s: send connect failure to nl80211:"
1965 " for bssid " MAC_ADDRESS_STR
1966 " reason:%d and Status:%d\n" ,
1967 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1968 roamResult, roamStatus);
1969 else
1970 hddLog(VOS_TRACE_LEVEL_ERROR,
1971 "%s: connect failed:"
1972 " for bssid " MAC_ADDRESS_STR
1973 " reason:%d and Status:%d\n" ,
1974 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1975 roamResult, roamStatus);
1976
c_hpothudaa90e22014-06-24 17:23:43 +05301977 /*Clear the roam profile*/
1978 hdd_clearRoamProfileIe( pAdapter );
1979
James Zmudafbf5ffc2013-03-25 12:45:35 -07001980 /* inform association failure event to nl80211 */
1981 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1982 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001983 if (pRoamInfo)
1984 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1985 NULL, 0, NULL, 0,
1986 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1987 GFP_KERNEL );
1988 else
1989 cfg80211_connect_result ( dev, pWextState->req_bssId,
1990 NULL, 0, NULL, 0,
1991 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1992 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001993 }
1994 else
1995 {
Sushant Kaushik21f28232014-12-18 11:42:46 +05301996 if (pRoamInfo){
1997 eCsrAuthType authType =
1998 pWextState->roamProfile.AuthType.authType[0];
1999 v_BOOL_t isWep = (authType == eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
2000 (authType == eCSR_AUTH_TYPE_SHARED_KEY);
2001
2002 /* In case of OPEN-WEP or SHARED-WEP authentication,
2003 * send exact protocol reason code. This enables user
2004 * applications to reconnect the station with correct
2005 * configuration.
2006 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002007 cfg80211_connect_result ( dev, pRoamInfo->bssid,
2008 NULL, 0, NULL, 0,
Sushant Kaushik21f28232014-12-18 11:42:46 +05302009 isWep ? pRoamInfo->reasonCode :
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002010 WLAN_STATUS_UNSPECIFIED_FAILURE,
2011 GFP_KERNEL );
Sushant Kaushik21f28232014-12-18 11:42:46 +05302012 } else
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002013 cfg80211_connect_result ( dev, pWextState->req_bssId,
2014 NULL, 0, NULL, 0,
2015 WLAN_STATUS_UNSPECIFIED_FAILURE,
2016 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07002017 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002019
Kumar Anand82c009f2014-05-29 00:29:42 -07002020 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002021
c_hpothu24f40982014-04-18 18:00:36 +05302022 if (pRoamInfo)
2023 {
2024 WLANTL_AssocFailed(pRoamInfo->staId);
2025 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302026
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302027 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 netif_tx_disable(dev);
2029 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002030
Jeff Johnson295189b2012-06-20 16:38:30 -07002031 }
2032
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302033 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302034 {
2035 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2036 if (pHostapdAdapter != NULL)
2037 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302038 /* Restart SAP if its operating channel is different
2039 * from AP channel.
2040 */
2041 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2042 (int)pRoamInfo->pBssDesc->channelId)
2043 {
2044 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2045 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2046 (int)pRoamInfo->pBssDesc->channelId);
Deepthi Gowric9c777d2014-12-10 16:17:11 +05302047 hdd_hostapd_stop(pHostapdAdapter->dev);
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302048 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302049 }
2050 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002051 return eHAL_STATUS_SUCCESS;
2052}
2053
2054/**============================================================================
2055 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002056 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002058
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002060static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2061 tCsrRoamInfo *pRoamInfo,
2062 tANI_U32 roamId,
2063 eRoamCmdStatus roamStatus,
2064 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002065{
Katya Nigam47528772015-02-11 12:24:49 +05302066 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2067 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2068 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302069 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302070
Jeff Johnson81c17882013-05-03 09:53:35 -07002071 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2072 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2073
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 switch( roamResult )
2075 {
2076 // both IBSS Started and IBSS Join should come in here.
2077 case eCSR_ROAM_RESULT_IBSS_STARTED:
2078 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002079 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002080 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002081 if (NULL == pRoamInfo)
2082 {
2083 VOS_ASSERT(0);
2084 return;
2085 }
2086
2087 /* When IBSS Started comes from CSR, we need to move
2088 * connection state to IBSS Disconnected (meaning no peers
2089 * are in the IBSS).
2090 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302091 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2092 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2093 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002094 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2095 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302096 /*notify wmm */
2097 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002098 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002099
Jeff Johnson81c17882013-05-03 09:53:35 -07002100 if (pRoamInfo->pBssDesc)
2101 {
Anand N Sunkadfec40682015-07-29 09:51:17 +05302102#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2103 struct ieee80211_channel *chan;
2104 int chan_no;
2105 unsigned int freq;
2106#endif
Katya Nigam47528772015-02-11 12:24:49 +05302107 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2108 IBSS_BROADCAST_STAID,
2109 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002110
2111 /* we created the IBSS, notify supplicant */
2112 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2113 MAC_ADDRESS_STR,
2114 __func__, pAdapter->dev->name,
2115 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2116
2117 /* we must first give cfg80211 the BSS information */
2118 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2119 if (NULL == bss)
2120 {
2121 hddLog(VOS_TRACE_LEVEL_ERROR,
2122 "%s: %s: unable to create IBSS entry",
2123 __func__, pAdapter->dev->name);
2124 return;
2125 }
Anand N Sunkadfec40682015-07-29 09:51:17 +05302126#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2127 chan_no = pRoamInfo->pBssDesc->channelId;
Jeff Johnson81c17882013-05-03 09:53:35 -07002128
Anand N Sunkadfec40682015-07-29 09:51:17 +05302129 if (chan_no <= 14)
2130 freq = ieee80211_channel_to_frequency(chan_no,
2131 IEEE80211_BAND_2GHZ);
2132 else
2133 freq = ieee80211_channel_to_frequency(chan_no,
2134 IEEE80211_BAND_5GHZ);
2135
2136 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
2137
2138 if (chan)
2139 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
2140 chan, GFP_KERNEL);
2141 else
2142 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
2143 pAdapter->dev->name,
2144 (int)pRoamInfo->pBssDesc->channelId);
2145#else
Jeff Johnson81c17882013-05-03 09:53:35 -07002146 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302147#endif
Yue Maf49ba872013-08-19 12:04:25 -07002148 cfg80211_put_bss(
2149#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2150 pHddCtx->wiphy,
2151#endif
2152 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07002153 }
Katya Nigam47528772015-02-11 12:24:49 +05302154 else
2155 {
2156 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2157 "%s: NULL Bss Desc",__func__);
2158 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05302159
2160 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
2161 * in IBSS_COALESCED will remove the BC key.
2162 */
2163 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
2164 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
2165 == pHddStaCtx->ibss_enc_key.encType
2166 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
2167 == pHddStaCtx->ibss_enc_key.encType
2168 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2169 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
2170 {
2171 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2172 VOS_STATUS vosStatus;
2173
2174 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2175
2176 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2177 grpmacaddr, WNI_CFG_BSSID_LEN);
2178 hddLog(VOS_TRACE_LEVEL_INFO,
2179 FL(" SET GTK in case of COALESCED"));
2180 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2181 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2182 if ( VOS_STATUS_SUCCESS != vosStatus )
2183 {
2184 hddLog(VOS_TRACE_LEVEL_ERROR,
2185 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
2186 }
2187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002188 break;
2189 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002190
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
2192 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002193 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
2194 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 break;
2196 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002197
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07002199 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
2200 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002202 }
2203
Jeff Johnson81c17882013-05-03 09:53:35 -07002204 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002205}
2206
2207/**============================================================================
2208 *
2209 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
2210 This information is passed to iwconfig later. The peer that joined
2211 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002212 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002214
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05302216static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07002217{
2218 int fSuccess = FALSE;
2219 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302220 VOS_STATUS status;
2221 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002222
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2224 {
2225 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
2226 {
2227 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002228
Jeff Johnson295189b2012-06-20 16:38:30 -07002229 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002230
Jeff Johnson295189b2012-06-20 16:38:30 -07002231 fSuccess = TRUE;
2232 break;
2233 }
2234 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002235
Nirav Shah7e3c8132015-06-22 23:51:42 +05302236 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
2237 if (status != VOS_STATUS_SUCCESS) {
2238 hddLog(VOS_TRACE_LEVEL_ERROR,
2239 FL("Not able to add staid hash %d"), staId);
2240 return FALSE;
2241 }
2242
2243 hddLog(VOS_TRACE_LEVEL_INFO,
2244 FL("New station added sta_id %d mac:"
2245 MAC_ADDRESS_STR), staId,
2246 MAC_ADDR_ARRAY(peerMacAddress->bytes));
2247
Shailender Karmuchia734f332013-04-19 14:02:48 -07002248 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07002249}
2250/**============================================================================
2251 *
2252 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002253 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002255
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07002257static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07002258{
2259 int fSuccess = FALSE;
2260 int idx = 0;
2261 v_U8_t valid_idx = 0;
2262 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07002263 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002264 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05302265 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002266
Jeff Johnson295189b2012-06-20 16:38:30 -07002267 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2268 {
2269 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
2270 {
2271 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302272 status = hdd_sta_id_hash_remove_entry(pAdapter,
2273 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
2274 if (status != VOS_STATUS_SUCCESS) {
2275 hddLog(VOS_TRACE_LEVEL_ERROR,
2276 FL("Not able to remove staid hash %d"), staId );
2277 fSuccess = FALSE;
2278 } else {
2279 hddLog(VOS_TRACE_LEVEL_INFO,
2280 FL("station removed sta_id %d mac:"
2281 MAC_ADDRESS_STR), staId,
2282 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07002283
Nirav Shah7e3c8132015-06-22 23:51:42 +05302284 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002285
Nirav Shah7e3c8132015-06-22 23:51:42 +05302286 fSuccess = TRUE;
2287 // Note the deleted Index, if its 0 we need special handling
2288 del_idx = idx;
2289 empty_slots++;
2290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 }
2292 else
2293 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002294 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 {
2296 valid_idx = idx;
2297 }
Ravi Joshi8a934352013-09-25 16:46:58 -07002298 else
2299 {
2300 // Found an empty slot
2301 empty_slots++;
2302 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 }
2304 }
2305
Ravi Joshi8a934352013-09-25 16:46:58 -07002306 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
2307 {
2308 // Last peer departed, set the IBSS state appropriately
2309 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002310 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07002311 "Last IBSS Peer Departed!!!" );
2312 }
2313
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 // Find next active staId, to have a valid sta trigger for TL.
2315 if (fSuccess == TRUE)
2316 {
2317 if (del_idx == 0)
2318 {
2319 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
2320 {
2321 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
2322 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
2323 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
2324
2325 pHddStaCtx->conn_info.staId[valid_idx] = 0;
2326 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
2327 }
2328 }
2329 }
2330 return( fSuccess );
2331}
2332
2333/**============================================================================
2334 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002335 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07002336 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002337
Jeff Johnson295189b2012-06-20 16:38:30 -07002338 ===========================================================================*/
2339static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
2340{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002341 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05302342 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2343 "%s: IBSS Connect Indication from SME!!! "
2344 "Set HDD connState to eConnectionState_IbssConnected",
2345 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
2347 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
2348
2349 // Save the connection info from CSR...
2350 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
2351
2352 // Send the bssid address to the wext.
2353 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002354 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002355 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2356 if (NULL == bss)
2357 {
2358 hddLog(VOS_TRACE_LEVEL_ERROR,
2359 "%s: %s: unable to create IBSS entry",
2360 __func__, pAdapter->dev->name);
2361 return eHAL_STATUS_FAILURE;
2362 }
Yue Maf49ba872013-08-19 12:04:25 -07002363 cfg80211_put_bss(
2364#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2365 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
2366#endif
2367 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07002368
2369 return( eHAL_STATUS_SUCCESS );
2370}
2371/**============================================================================
2372 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05302373 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
2374 suspend related data which was cleared during roaming in FWR.
2375
2376 ===========================================================================*/
2377static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
2378{
2379 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
2380 hdd_adapter_t *pAdapter;
2381 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
2382 ENTER();
2383
2384 spin_lock(&pHddCtx->filter_lock);
2385 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
2386 {
2387 pHddCtx->sus_res_mcastbcast_filter =
2388 pHddCtx->configuredMcastBcastFilter;
2389 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
2390 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
2391 hddLog(VOS_TRACE_LEVEL_INFO,
2392 FL("saving configuredMcastBcastFilter = %d"),
2393 pHddCtx->configuredMcastBcastFilter);
2394 hddLog(VOS_TRACE_LEVEL_INFO,
2395 FL("offload: calling hdd_conf_mcastbcast_filter"));
2396 }
2397 spin_unlock(&pHddCtx->filter_lock);
2398
2399 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
2400 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
2401 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
2402
2403 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
2404 //No need to configure GTK Offload from here because it might possible
2405 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
2406 //be handled as part of cfg80211_set_rekey_data processing.
2407 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
2408 {
2409 pAdapter = pAdapterNode->pAdapter;
2410 if( pAdapter &&
2411 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
2412 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
2413 {
2414 if (pHddCtx->cfg_ini->fhostArpOffload)
2415 {
2416 //Configure ARPOFFLOAD
2417 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
2418 if (!VOS_IS_STATUS_SUCCESS(vstatus))
2419 {
2420 hddLog(VOS_TRACE_LEVEL_ERROR,
2421 FL("Failed to disable ARPOffload Feature %d"), vstatus);
2422 }
2423 }
2424#ifdef WLAN_NS_OFFLOAD
2425 //Configure NSOFFLOAD
2426 if (pHddCtx->cfg_ini->fhostNSOffload)
2427 {
2428 hdd_conf_ns_offload(pAdapter, TRUE);
2429 }
2430#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05302431#ifdef WLAN_FEATURE_PACKET_FILTERING
2432 /* During suspend, configure MC Addr list filter to the firmware
2433 * function takes care of checking necessary conditions before
2434 * configuring.
2435 */
2436 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
2437#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05302438 }
2439 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2440 pAdapterNode = pNext;
2441 }
2442 EXIT();
2443}
2444
2445/**============================================================================
2446 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002448
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002450static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2451 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 eCsrRoamResult roamResult )
2453{
2454 eCsrEncryptionType connectedCipherAlgo;
2455 v_BOOL_t fConnected = FALSE;
2456 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2457 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302458 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302460 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002462
2463 if (NULL == pRoamInfo)
2464 {
2465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2466 return eHAL_STATUS_FAILURE;
2467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002468 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002469 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 // not require upper layer authentication) we can put TL directly into 'authenticated'
2471 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2473 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2474 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002475
Jeff Johnson295189b2012-06-20 16:38:30 -07002476 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2477 if( fConnected )
2478 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002479 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2480 {
2481 v_U8_t staId;
2482
2483 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2484
2485 if ( 0 == memcmp( pRoamInfo->peerMac,
2486 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2487 {
2488 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2489 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05302490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2491 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002492 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2493 }
2494 else
2495 {
2496 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2497 (v_MACADDR_t*)pRoamInfo->peerMac,
2498 &staId);
2499 if ( VOS_STATUS_SUCCESS == vosStatus )
2500 {
2501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2502 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2503 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2504 staId);
2505 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2506 }
2507 }
2508 }
2509 else
2510 {
Bhargav Shaha805ef22015-07-29 17:31:38 +05302511 WLANTL_GetSTAState(pHddCtx->pvosContext,
2512 pHddStaCtx->conn_info.staId[0],
2513 &prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302514 // TODO: Considering getting a state machine in HDD later.
2515 // This routine is invoked twice. 1)set PTK 2)set GTK.
2516 // The folloing if statement will be TRUE when setting GTK.
2517 // At this time we don't handle the state in detail.
2518 // Related CR: 174048 - TL not in authenticated state
2519 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2520 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2521 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302522
2523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2524 "for StaId=%d. Changing TL state to AUTHENTICATED from"
2525 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302526
2527 // Connections that do not need Upper layer authentication,
2528 // transition TL to 'Authenticated' state after the keys are set.
2529 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2530 pHddStaCtx->conn_info.staId[ 0 ],
2531 WLANTL_STA_AUTHENTICATED );
2532
2533 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302534
2535 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2536 hdd_postTLPacketPendingInd(pAdapter,
2537 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05302538 //Need to call offload because when roaming happen at that time fwr
2539 //clean offload info as part of the DelBss
2540 // No need to configure offload if host was not suspended
2541 spin_lock(&pHddCtx->filter_lock);
2542 if(pHddCtx->hdd_wlan_suspended)
2543 {
2544 spin_unlock(&pHddCtx->filter_lock);
2545 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2546 }
2547 else
2548 {
2549 spin_unlock(&pHddCtx->filter_lock);
2550 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302551 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2552 {
2553 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2554 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302555 }
2556 else
2557 {
2558 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2559 pHddStaCtx->conn_info.staId[ 0 ]);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302560
2561 /* In case of OSEN move TL to 'Authenticated' after PTK is set */
2562 if (pWextState->roamProfile.bOSENAssociation == VOS_TRUE)
2563 {
2564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "PTK set"
2565 " for StaId=%d. Due to OSEN, Changing TL state to"
2566 "AUTHENTICATED from state:%d",
2567 pHddStaCtx->conn_info.staId[0], prevTLState);
2568
2569 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2570 pHddStaCtx->conn_info.staId[ 0 ],
2571 WLANTL_STA_AUTHENTICATED );
2572
2573 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
2574
2575 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2576 hdd_postTLPacketPendingInd(pAdapter,
2577 pHddStaCtx->conn_info.staId[0]);
2578 }
2579
2580
2581
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302582 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2583 {
2584 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2585 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302586 }
2587
2588 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302591 else
2592 {
2593 // possible disassoc after issuing set key and waiting set key complete
2594 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2595 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002596
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 EXIT();
2598 return( eHAL_STATUS_SUCCESS );
2599}
2600/**============================================================================
2601 *
2602 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2603 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002604static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002606{
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2608
2609 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2610 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2611 {
2612 struct iw_michaelmicfailure msg;
2613 union iwreq_data wreq;
2614 memset(&msg, '\0', sizeof(msg));
2615 msg.src_addr.sa_family = ARPHRD_ETHER;
2616 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002617 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2618 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002619
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2621 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002622 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 msg.flags = IW_MICFAILURE_PAIRWISE;
2624 memset(&wreq, 0, sizeof(wreq));
2625 wreq.data.length = sizeof(msg);
2626 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002628 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2630 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2631 NL80211_KEYTYPE_GROUP :
2632 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002633 pRoamInfo->u.pMICFailureInfo->keyId,
2634 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002635 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002636
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002638
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 return( eHAL_STATUS_SUCCESS );
2640}
2641
2642/**============================================================================
2643 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002644 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002646
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002648static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2649 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 eCsrRoamResult roamResult )
2651{
2652 VOS_STATUS vosStatus;
2653
2654 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2655 switch( roamResult )
2656 {
2657 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2658 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002659 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002660 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002661
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002662 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002663 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2664 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2665 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002667
Nirav Shah7e3c8132015-06-22 23:51:42 +05302668 if ( !roamSaveIbssStation( pAdapter, pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 {
2670 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2671 "New IBSS peer but we already have the max we can handle. Can't register this one" );
2672 break;
2673 }
2674
2675 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2676
Shailender Karmuchia734f332013-04-19 14:02:48 -07002677 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2678 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2679 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2680
2681 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05302682 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 pRoamInfo,
2684 pRoamInfo->staId,
2685 (v_MACADDR_t *)pRoamInfo->peerMac,
2686 pRoamInfo->pBssDesc );
2687 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2688 {
2689 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002690 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 vosStatus, vosStatus );
2692 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002693 pHddStaCtx->ibss_sta_generation++;
2694 memset(&staInfo, 0, sizeof(staInfo));
2695 staInfo.filled = 0;
2696 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2697
2698 cfg80211_new_sta(pAdapter->dev,
2699 (const u8 *)pRoamInfo->peerMac,
2700 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002701
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002702 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2703 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2704 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2705 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2706 {
2707 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302708
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002709 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2710 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2711
2712 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002713 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002714 pHddStaCtx->ibss_enc_key.encType);
2715
2716 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2717 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2718
2719 if ( VOS_STATUS_SUCCESS != vosStatus )
2720 {
2721 hddLog(VOS_TRACE_LEVEL_ERROR,
2722 "%s: sme_RoamSetKey failed, returned %d",
2723 __func__, vosStatus);
2724 return VOS_STATUS_E_FAILURE;
2725 }
2726 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302728 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002729 netif_tx_start_all_queues(pAdapter->dev);
2730 break;
2731 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002732
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2734 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002735
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002737
Jeff Johnson295189b2012-06-20 16:38:30 -07002738 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2741 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002742 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002743
Ravi Joshicc57ed42013-10-12 16:31:25 -07002744 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 {
2746 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2747 "IBSS peer departed by cannot find peer in our registration table with TL" );
2748 }
2749
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002750 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002751 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2752 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2753 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2754 pRoamInfo->staId );
2755
Katya Nigam47528772015-02-11 12:24:49 +05302756 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002757
2758 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002759 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002760
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002761 cfg80211_del_sta(pAdapter->dev,
2762 (const u8 *)&pRoamInfo->peerMac,
2763 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 break;
2765 }
2766 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2767 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002768 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2769 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302771 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 netif_tx_disable(pAdapter->dev);
2773 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302774 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2775 "%s: Set HDD connState to eConnectionState_NotConnected",
2776 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002778
Jeff Johnson295189b2012-06-20 16:38:30 -07002779 // Send the bssid address to the wext.
2780 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2781 // clean up data path
2782 hdd_disconnect_tx_rx(pAdapter);
2783 break;
2784 }
2785 default:
2786 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002787
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002789
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 return( eHAL_STATUS_SUCCESS );
2791}
2792
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002793#ifdef FEATURE_WLAN_TDLS
2794/**============================================================================
2795 *
2796 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2797 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2798 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002799
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002800 ===========================================================================*/
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05302801VOS_STATUS hdd_roamRegisterTDLSSTA(hdd_adapter_t *pAdapter,
2802#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
2803 const tANI_U8 *peerMac,
2804#else
2805 tANI_U8 *peerMac,
2806#endif
2807 tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002808{
2809 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002810 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002811 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2812 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002813 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2814 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002815 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2816 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002817
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002818 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2819 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002820 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002821 "%s not connected. ignored", __func__);
2822 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002823 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002824
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002825 /*
2826 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2827 * be peer MAC, here we are wokrking on direct Link
2828 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002829 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002830
2831 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002832
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002833 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002834 sizeof(tSirMacAddr) );
2835
2836 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2837 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2838
2839 /* set the QoS field appropriately ..*/
2840 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2841 : (staDesc.ucQosEnabled = 0) ;
2842
2843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002844 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002845
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002846 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002847
2848 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002849 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002850
Shailender Karmuchia734f332013-04-19 14:02:48 -07002851 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002852 * UMA is ready we inform TL to do frame translation.
2853 */
2854 staDesc.ucSwFrameTXXlation = 1;
2855 staDesc.ucSwFrameRXXlation = 1;
2856 staDesc.ucAddRmvLLC = 1;
2857
2858 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002859 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002860
2861 /* tdls Direct Link do not need bcastSig */
2862 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002863
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002864#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2865 if(staDesc.ucProtectedFrame)
2866 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2867 else
2868 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2869#endif
2870
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302871 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002872
Shailender Karmuchia734f332013-04-19 14:02:48 -07002873 /* Register the Station with TL... */
2874 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2875 hdd_rx_packet_cbk,
2876 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002877 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002878
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002879 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2880 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002881 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002882 "%s: WLANTL_RegisterSTAClient() failed to register. "
2883 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002884 return vosStatus;
2885 }
2886
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002887 if ( cfg_param->dynSplitscan &&
2888 ( VOS_TIMER_STATE_RUNNING !=
2889 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2890 {
2891 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2892 cfg_param->trafficMntrTmrForSplitScan);
2893 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002894 return( vosStatus );
2895}
2896
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05302897VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002898{
2899 VOS_STATUS vosStatus;
2900 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2901 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2902 {
2903 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2904 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002905 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002906 __func__, staId, vosStatus, vosStatus );
2907 }
2908 return( vosStatus );
2909}
2910
2911
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002912/*
2913 * HDD interface between SME and TL to ensure TDLS client registration with
2914 * TL in case of new TDLS client is added and deregistration at the time
2915 * TDLS client is deleted.
2916 */
2917
Shailender Karmuchia734f332013-04-19 14:02:48 -07002918eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2919 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002920 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002921 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002922 eCsrRoamResult roamResult)
2923{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002924 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002925 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002926 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002927
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002929 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2930 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2931 "ADD_TDLS_PEER" :
2932 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2933 "DEL_TDLS_PEER" :
2934 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2935 "DEL_TDLS_PEER_IND" :
2936 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2937 "DEL_ALL_TDLS_PEER_IND" :
2938 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2939 "UPDATE_TDLS_PEER" :
2940 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2941 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2942 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002943 switch( roamResult )
2944 {
2945 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2946 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002947 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2948 {
2949 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002950 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05302951 wlan_hdd_tdls_check_bmps(pAdapter);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002952 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002953 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002954 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002955
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002956 /* check if there is available index for this new TDLS STA */
2957 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2958 {
2959 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2960 {
2961 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2962 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2963
2964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002965 ("TDLS: STA IDX at %d is %d "
2966 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002967 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002968 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002969
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002970 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002971 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2972 status = eHAL_STATUS_SUCCESS ;
2973 break ;
2974 }
2975 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002976 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002977 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002978 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002979 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2980 "wlan_hdd_tdls_set_sta_id() failed");
2981 return VOS_FALSE;
2982 }
2983
2984 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302985 /* store the ucast signature , if required for further reference. */
2986
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002987 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302988 /* start TDLS client registration with TL */
2989 status = hdd_roamRegisterTDLSSTA( pAdapter,
2990 pRoamInfo->peerMac,
2991 pRoamInfo->staId,
2992 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05302993 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002994 }
2995 else
2996 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002997 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002999 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003000 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003001 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003002 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003003 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003004 break ;
3005 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003006 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3007 {
3008 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3009 {
3010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3011 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3012 }
3013 /* store the ucast signature which will be used later when
3014 * registering to TL
3015 */
3016 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3017 complete(&pAdapter->tdls_add_station_comp);
3018 break;
3019 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303020 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3021 {
3022 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3023 {
3024 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3025 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
3026 }
3027 complete(&pAdapter->tdls_link_establish_req_comp);
3028 break;
3029 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003030 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003031 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003032 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003033 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003034 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003035 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3036 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003037 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003039 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3040
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303041 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303042 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003043 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3045 " Current status for peer" MAC_ADDRESS_STR "is %d",
3046 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303047 if (TDLS_IS_CONNECTED(curr_peer) ||
3048 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303049 {
3050 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3051 }
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303052 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003053 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003054 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003055
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003056 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3057 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3058 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003059 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003060 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003061 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003062 break ;
3063 }
3064 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003065 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003066 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003067 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003068 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3069 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003070 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003071 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3072 "%s: Sending teardown to supplicant with reason code %u",
3073 __func__, pRoamInfo->reasonCode);
3074
3075#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303076 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003077 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003078#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003079 status = eHAL_STATUS_SUCCESS ;
3080 break ;
3081 }
3082 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3083 {
3084 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003085 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003086 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003087 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3088 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003089 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003091 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003092 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003093 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003094 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
3095 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3096 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003097
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003098 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003099 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003100 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3101 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003102
3103 status = eHAL_STATUS_SUCCESS ;
3104 }
3105 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303106 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003107 break ;
3108 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003109 default:
3110 {
3111 break ;
3112 }
3113 }
3114
3115 return status ;
3116}
3117#endif
3118
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003119static void iw_full_power_cbfn (void *pContext, eHalStatus status)
3120{
3121 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3122 hdd_context_t *pHddCtx = NULL;
3123 int ret;
3124
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303125 ENTER();
3126
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003127 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3128 {
3129 hddLog(VOS_TRACE_LEVEL_ERROR,
3130 "%s: Bad param, pAdapter [%p]",
3131 __func__, pAdapter);
3132 return;
3133 }
3134
3135 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3136 ret = wlan_hdd_validate_context(pHddCtx);
3137 if (0 != ret)
3138 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003139 return;
3140 }
3141
3142 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3143 {
3144 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3145 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303146
3147 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003148}
3149
Shailender Karmuchia734f332013-04-19 14:02:48 -07003150eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3152{
3153 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
3154 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303155 hdd_wext_state_t *pWextState = NULL;
3156 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003157 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07003158 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003159
3160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003161 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003162 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003163
3164 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303165 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003166 {
3167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303168 "invalid adapter or adapter has invalid magic");
3169 return eHAL_STATUS_FAILURE;
3170 }
3171
3172 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3173 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3174
3175 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3176 {
3177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3178 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003179 return eHAL_STATUS_FAILURE;
3180 }
3181
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05303182
3183 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
3184 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 switch( roamStatus )
3186 {
3187 case eCSR_ROAM_SESSION_OPENED:
3188 if(pAdapter != NULL)
3189 {
3190 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
3191 complete(&pAdapter->session_open_comp_var);
3192 }
3193 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003194
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003195#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
3196 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07003198 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07003199 * interface down */
3200 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303201 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
3202 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05303203 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3205 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
3206 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3208 }
3209 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05303210 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 break;
3212
3213 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003214 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07003216 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 // eCSR_ROAM_SHOULD_ROAM will be received.
3218 // Where in we will not mark the link down
3219 // Also we want to stop tx at this point when we will be
3220 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003221 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 {
3223 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303224 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303226 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3227 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3228 {
3229 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
3230 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003231 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303232 * Deregister this STA with TL, but do not flush the packets
3233 * for this STA from wmm_tx_queue. Since there is no valid STA
3234 * for these packets they will not be transmitted. Eventually
3235 * after the reassociation is successful, these packets will be
3236 * transmitted after registering STA with TL again. This ensures
3237 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003238 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303239 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
3240 pHddStaCtx->conn_info.staId[0]);
3241 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003242 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3244 FL("WLANTL_ClearSTAClient failed for staID %d."
3245 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
3246 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003247 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003248 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 }
3250 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003251 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 break;
3253#endif
3254
3255 case eCSR_ROAM_SHOULD_ROAM:
3256 // Dont need to do anything
3257 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 struct net_device *dev = pAdapter->dev;
3259 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3260 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303261 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003262 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003263#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 if (pHddStaCtx->ft_carrier_on == FALSE)
3265 {
3266#endif
3267 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003268#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 }
3270#endif
3271
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003272#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 //We should clear all sta register with TL, for now, only one.
3274 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
3275 if ( !VOS_IS_STATUS_SUCCESS(status ) )
3276 {
3277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3278 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
3279 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003280 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003281 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003282#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003283 }
3284 break;
3285 case eCSR_ROAM_LOSTLINK:
3286 case eCSR_ROAM_DISASSOCIATED:
3287 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3289 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05303290 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3292 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07003293 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3294 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303295 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07003296 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08003297
3298 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
3299 pHddCtx->configuredMcastBcastFilter =
3300 pHddCtx->sus_res_mcastbcast_filter;
3301 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
3302 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303303
Amar Singhald53568e2013-09-26 11:03:45 -07003304 hddLog(VOS_TRACE_LEVEL_INFO,
3305 "offload: disassociation happening, restoring configuredMcastBcastFilter");
3306 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
3307 pHddCtx->configuredMcastBcastFilter);
3308 hddLog(VOS_TRACE_LEVEL_INFO,
3309 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3311 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003312#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303313 /* Call to clear any MC Addr List filter applied after
3314 * successful connection.
3315 */
3316 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003317#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 }
3319 break;
3320 case eCSR_ROAM_IBSS_LEAVE:
3321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3322 "****eCSR_ROAM_IBSS_LEAVE****");
3323 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3324 break;
3325 case eCSR_ROAM_ASSOCIATION_COMPLETION:
3326 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3327 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303328 // To Do - address probable memory leak with WEP encryption upon successful association
3329 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303331 //Clear saved connection information in HDD
3332 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303334 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003335
3336 break;
3337 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003338 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 pRoamInfo, roamId, roamStatus, roamResult );
3340 break;
3341 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07003342 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
3343 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 break;
3345
3346 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
3347 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003348 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003349
3350 case eCSR_ROAM_MIC_ERROR_IND:
3351 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3352 break;
3353
3354 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003355 {
3356 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3357
3358 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003359 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
3360 (TRUE == pHddCtx->hdd_wlan_suspended) &&
3361 (eCSR_ROAM_RESULT_NONE == roamResult))
3362 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003363 /* Send DTIM period to the FW; only if the wlan is already
3364 in suspend. This is the case with roaming (reassoc),
3365 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
3366 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
3367 before the ENTER_BMPS_REQ ensures Listen Interval is
3368 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003369 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003370
3371 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003372 if due to unexpected scenario, if we are in BMPS,
3373 then trigger Exit and Enter BMPS to take DTIM period
3374 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003375 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
3376 {
3377 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
3378
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003379 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3380 iw_full_power_cbfn, pAdapter,
3381 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003382 }
3383 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303384
3385 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303386 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
3387 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
3388 (eCSR_ROAM_RESULT_NONE == roamResult))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303389 {
3390 hddLog( LOG1, FL("Device in full power."
3391 "Stop and start traffic timer for roaming"));
3392 pmcStopTrafficTimer(pHddCtx->hHal);
3393 if (pmcStartTrafficTimer(pHddCtx->hHal,
3394 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
3395 {
3396 hddLog(LOGP, FL("Cannot start traffic timer"));
3397 }
3398 }
3399
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003400 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303401 if (eCSR_ROAM_RESULT_NONE == roamResult)
3402 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 break;
3405#ifdef WLAN_FEATURE_VOWIFI_11R
3406 case eCSR_ROAM_FT_RESPONSE:
3407 hdd_SendFTEvent(pAdapter);
3408 break;
3409#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07003410#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003411 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003412 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07003413 {
3414 /* Notify the supplicant of a new candidate */
3415 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
3416 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003417 break;
3418#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003419
Yue Maef608272013-04-08 23:09:17 -07003420#ifdef FEATURE_WLAN_LFR_METRICS
3421 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
3422 /* This event is to notify pre-auth initiation */
3423 if (VOS_STATUS_SUCCESS !=
3424 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
3425 {
3426 halStatus = eHAL_STATUS_FAILURE;
3427 }
3428 break;
3429 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
3430 /* This event will notify pre-auth completion in case of success */
3431 if (VOS_STATUS_SUCCESS !=
3432 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3433 pRoamInfo, 1))
3434 {
3435 halStatus = eHAL_STATUS_FAILURE;
3436 }
3437 break;
3438 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
3439 /* This event will notify pre-auth completion in case of failure. */
3440 if (VOS_STATUS_SUCCESS !=
3441 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3442 pRoamInfo, 0))
3443 {
3444 halStatus = eHAL_STATUS_FAILURE;
3445 }
3446 break;
3447 case eCSR_ROAM_HANDOVER_SUCCESS:
3448 /* This event is to notify handover success.
3449 It will be only invoked on success */
3450 if (VOS_STATUS_SUCCESS !=
3451 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
3452 {
3453 halStatus = eHAL_STATUS_FAILURE;
3454 }
3455 break;
3456#endif
3457
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 case eCSR_ROAM_INDICATE_MGMT_FRAME:
3459 hdd_indicateMgmtFrame( pAdapter,
3460 pRoamInfo->nFrameLength,
3461 pRoamInfo->pbFrames,
3462 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05303463 pRoamInfo->rxChan,
3464 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 break;
3466 case eCSR_ROAM_REMAIN_CHAN_READY:
3467 hdd_remainChanReadyHandler( pAdapter );
3468 break;
3469 case eCSR_ROAM_SEND_ACTION_CNF:
3470 hdd_sendActionCnf( pAdapter,
3471 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
3472 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003473#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08003474 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003475 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08003476 roamId, roamStatus, roamResult );
3477 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003478 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
3479 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
3480 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003481#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003482#ifdef WLAN_FEATURE_11W
3483 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
3484 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
3485 pRoamInfo->pbFrames,
3486 pRoamInfo->frameType);
3487 break;
3488#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003489#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003490 case eCSR_ROAM_TSM_IE_IND:
3491 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
3492 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
3493 break;
3494
3495 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
3496 {
3497 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
3498 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
3499 {
3500 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
3501 }
3502 break;
3503 }
3504
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003505 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003506 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003507 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003508 break;
3509 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003510
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003511 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003512 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003513 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003514 break;
3515 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003516#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05303517 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
3518 {
3519 pAdapter->maxRateFlags = roamResult;
3520 break;
3521 }
3522 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07003523 break;
3524 }
3525 return( halStatus );
3526}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003527eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003528{
3529 eCsrAuthType auth_type;
3530 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003531 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 {
3533 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003534 } else
3535 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003536 {
3537 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003538 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003539#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003540 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 {
3542 // Check for 11r FT Authentication with PSK
3543 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003544 } else
3545 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 {
3547 // Check for 11R FT Authentication with 802.1X
3548 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003549 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003550#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003551#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003552 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 {
3554 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3555 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003556#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003557#ifdef WLAN_FEATURE_11W
3558 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3559 {
3560 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3561 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303562 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
3563 {
3564 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3565 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003566#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003567 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3569 }
3570 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003571}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003572
Shailender Karmuchia734f332013-04-19 14:02:48 -07003573eCsrAuthType
3574hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003575{
3576 eCsrAuthType auth_type;
3577 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003578 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003579 {
3580 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003581 } else
3582 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 {
3584 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003585 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003586#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003587 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003588 {
3589 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003590 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003591#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003592 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003593 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3594 }
3595 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3596 return auth_type;
3597}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003598
Shailender Karmuchia734f332013-04-19 14:02:48 -07003599eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003600hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003601{
3602 eCsrEncryptionType cipher_type;
3603 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003604 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 {
3606 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003607 }
3608 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003609 {
3610 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003611 }
3612 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003613 {
3614 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003615 }
3616 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003617 {
3618 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003619 }
3620 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3621 {
3622 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3623 }
3624 else
3625 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3627 }
3628 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3629 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003630}
Jeff Johnson295189b2012-06-20 16:38:30 -07003631/* To find if the MAC address is NULL */
3632static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3633{
3634 int i;
3635 for (i = 0; i < length; i++)
3636 {
3637 if (0x00 != (macAddr[i]))
3638 {
3639 return FALSE;
3640 }
3641 }
3642 return TRUE;
3643} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003644
Shailender Karmuchia734f332013-04-19 14:02:48 -07003645eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003646hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003647{
3648 eCsrEncryptionType cipher_type;
3649 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003650 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003651 {
3652 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003653 } else
3654 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 {
3656 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003657 } else
3658 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 {
3660 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003661 } else
3662 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 {
3664 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003665 } else
3666 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003667 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003668 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3669 } else
3670 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003671 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3672 }
3673 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3674 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003675}
Jeff Johnson295189b2012-06-20 16:38:30 -07003676
Shailender Karmuchia734f332013-04-19 14:02:48 -07003677static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3678 struct ether_addr *pBssid,
3679 eCsrEncryptionType *pEncryptType,
3680 eCsrEncryptionType *mcEncryptType,
3681 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003682#ifdef WLAN_FEATURE_11W
3683 u_int8_t *pMfpRequired,
3684 u_int8_t *pMfpCapable,
3685#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003686 u_int16_t gen_ie_len,
3687 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003688{
3689 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003690 eHalStatus result;
3691 tDot11fIERSN dot11RSNIE;
3692 tDot11fIEWPA dot11WPAIE;
3693 tANI_U32 i;
3694 tANI_U8 *pRsnIe;
3695 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003697 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003698
3699 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3700 flag to 0 */
3701 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3702 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3703
Jeff Johnson295189b2012-06-20 16:38:30 -07003704 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003705 if ( gen_ie[0] == DOT11F_EID_RSN)
3706 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003708 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3710 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303711 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3712 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 return -EINVAL;
3714 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003715 // Skip past the EID byte and length byte
3716 pRsnIe = gen_ie + 2;
3717 RSNIeLen = gen_ie_len - 2;
3718 // Unpack the RSN IE
3719 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3720 pRsnIe,
3721 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003722 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003723 // Copy out the encryption and authentication types
3724 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003725 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003726 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003727 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003728 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 but probably I suspect we can do something different*/
3730 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003731 // Just translate the FIRST one
3732 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3733 //dot11RSNIE.pwise_cipher_suite_count
3734 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3735 //dot11RSNIE.gp_cipher_suite_count
3736 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003737#ifdef WLAN_FEATURE_11W
3738 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3739 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3740#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003742 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003744 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303746 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003747 break;
3748 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003749 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303751 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 break;
3753 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003754 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003755 // For right now, I assume setASSOCIATE() has passed in the bssid.
3756 vos_mem_copy(PMKIDCache[i].BSSID,
3757 pBssid, ETHER_ADDR_LEN);
3758 vos_mem_copy(PMKIDCache[i].PMKID,
3759 dot11RSNIE.pmkid[i],
3760 CSR_RSN_PMKID_SIZE);
3761 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003762
3763 if (updatePMKCache)
3764 {
3765 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003766 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003767 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003768 // Finally set the PMKSA ID Cache in CSR
3769 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3770 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303771 dot11RSNIE.pmkid_count,
3772 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07003773 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003774 }
3775 else if (gen_ie[0] == DOT11F_EID_WPA)
3776 {
3777 // Validity checks
3778 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3779 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3780 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303781 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3782 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 return -EINVAL;
3784 }
3785 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003786 pRsnIe = gen_ie + 2 + 4;
3787 RSNIeLen = gen_ie_len - (2 + 4);
3788 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3790 pRsnIe,
3791 RSNIeLen,
3792 &dot11WPAIE);
3793 // Copy out the encryption and authentication types
3794 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003795 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003797 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 //dot11WPAIE.auth_suite_count
3799 // Just translate the FIRST one
3800 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3801 //dot11WPAIE.unicast_cipher_count
3802 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3803 //dot11WPAIE.unicast_cipher_count
3804 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3805 }
3806 else
3807 {
3808 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003809 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 }
3811 return 0;
3812}
3813int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3814{
3815 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3816 v_U32_t status = 0;
3817 eCsrEncryptionType RSNEncryptType;
3818 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003819#ifdef WLAN_FEATURE_11W
3820 u_int8_t RSNMfpRequired;
3821 u_int8_t RSNMfpCapable;
3822#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 struct ether_addr bSsid; // MAC address of assoc peer
3824 // MAC address of assoc peer
3825 // But, this routine is only called when we are NOT associated.
3826 vos_mem_copy(bSsid.ether_addr_octet,
3827 pWextState->roamProfile.BSSIDs.bssid,
3828 sizeof(bSsid.ether_addr_octet));
3829 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3830 {
3831 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003832 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003833 else
3834 {
3835 return 0;
3836 }
3837 // The actual processing may eventually be more extensive than this.
3838 // Right now, just consume any PMKIDs that are sent in by the app.
3839 status = hdd_ProcessGENIE(pAdapter,
3840 &bSsid, // MAC address of assoc peer
3841 &RSNEncryptType,
3842 &mcRSNEncryptType,
3843 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003844#ifdef WLAN_FEATURE_11W
3845 &RSNMfpRequired,
3846 &RSNMfpCapable,
3847#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 pWextState->WPARSNIE[1]+2,
3849 pWextState->WPARSNIE);
3850 if (status == 0)
3851 {
3852 // Now copy over all the security attributes you have parsed out
3853 pWextState->roamProfile.EncryptionType.numEntries = 1;
3854 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003855
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3857 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003858
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003859 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3860 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3861 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3862 {
3863 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3864 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3865 either AES/TKIP based on group cipher configuration
3866 mentioned in the wpa_supplicant.conf.*/
3867
3868 /*Set the unicast cipher same as multicast cipher*/
3869 pWextState->roamProfile.EncryptionType.encryptionType[0]
3870 = mcRSNEncryptType;
3871 }
3872
Chet Lanctot186b5732013-03-18 10:26:30 -07003873#ifdef WLAN_FEATURE_11W
3874 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3875 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3876#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003877 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003878 }
3879 return 0;
3880}
3881int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3882{
3883 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3884 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3885 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3886 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003887
Jeff Johnson295189b2012-06-20 16:38:30 -07003888 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003889 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003890
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 switch( pHddStaCtx->conn_info.authType)
3892 {
3893 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003894#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 case eCSR_AUTH_TYPE_CCKM_WPA:
3896 case eCSR_AUTH_TYPE_CCKM_RSN:
3897#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003898 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3899
Jeff Johnson295189b2012-06-20 16:38:30 -07003900 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003901 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003903
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003904#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003905 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3906 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3907 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003908 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003909 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3910 } else
3911 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003912 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003913 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 } else
3915#endif
3916 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3917 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003918 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3919 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3921 == IW_AUTH_KEY_MGMT_PSK) {
3922 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003923 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003925 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 }
3927 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003928#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003929 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3930 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3931 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003932 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003933 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003935 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003936 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003937 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 } else
3939#endif
3940
3941#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003942 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3943 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003945 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003946 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003947 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3949 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003950 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003951 } else
3952#endif
3953
Chet Lanctot186b5732013-03-18 10:26:30 -07003954#ifdef WLAN_FEATURE_11W
3955 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3956 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3957 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303958 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
3959 pRoamProfile->AuthType.authType[0] =
3960 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3961 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003962#endif
3963
Shailender Karmuchia734f332013-04-19 14:02:48 -07003964 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003966 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3967 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003968 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3969 == IW_AUTH_KEY_MGMT_PSK) {
3970 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003971 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003973 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003975 break;
3976
Jeff Johnson295189b2012-06-20 16:38:30 -07003977 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003978
3979 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003980 break;
3981 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003982
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003983#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08003984 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003985#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3987 break;
3988 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003989
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003991 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003992
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 EXIT();
3994 return 0;
3995}
3996
3997/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003998
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303999 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07004001 to the CSR roam profile.
4002
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 \param - dev - Pointer to the net device.
4004 - info - Pointer to the iw_request_info.
4005 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004006 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004008
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 --------------------------------------------------------------------------*/
4010
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304011int __iw_set_essid(struct net_device *dev,
4012 struct iw_request_info *info,
4013 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004014{
4015 v_U32_t status = 0;
4016 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304017 hdd_adapter_t *pAdapter;
4018 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 v_U32_t roamId;
4020 tCsrRoamProfile *pRoamProfile;
4021 eMib_dot11DesiredBssType connectedBssType;
4022 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304023 tHalHandle hHal;
4024 hdd_station_ctx_t *pHddStaCtx;
4025 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004026
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304028 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4029 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304032 "%s: Adapter is NULL",__func__);
4033 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 }
4035
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304036 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4037 ret = wlan_hdd_validate_context(pHddCtx);
4038 if (0 != ret)
4039 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304040 return ret;
4041 }
4042
4043 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4044 if (NULL == hHal)
4045 {
4046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4047 "%s: Hal Context is NULL",__func__);
4048 return -EINVAL;
4049 }
4050 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4051 if (NULL == pHddStaCtx)
4052 {
4053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4054 "%s: STA Context is NULL",__func__);
4055 return -EINVAL;
4056 }
4057 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4058 if (NULL == pWextState)
4059 {
4060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4061 "%s: pWextState is NULL",__func__);
4062 return -EINVAL;
4063 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
4065 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
4066 return -EBUSY;
4067 }
4068 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
4069 return -EINVAL;
4070 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004071 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 {
4073 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
4074 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
4075 {
4076 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004077 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07004078 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4079 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
4080
4081 if(VOS_STATUS_SUCCESS == vosStatus)
4082 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
4083 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4084 }
4085 }
4086 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004087 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 {
4089 return -EINVAL;
4090 }
4091 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004092 /** when cfg80211 defined, wpa_supplicant wext driver uses
4093 zero-length, null-string ssid for force disconnection.
4094 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07004095 driver MUST return success */
4096 if ( 0 == wrqu->essid.length ) {
4097 return 0;
4098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004099
4100 status = hdd_wmm_get_uapsd_mask(pAdapter,
4101 &pWextState->roamProfile.uapsd_mask);
4102 if (VOS_STATUS_SUCCESS != status)
4103 {
4104 pWextState->roamProfile.uapsd_mask = 0;
4105 }
4106 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004107
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004109
4110 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
4112 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
4113 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004114
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 //set gen ie
4116 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
4117
4118 //set auth
4119 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
4120 }
4121#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004122 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 if (pAdapter->wapi_info.nWapiMode)
4124 {
4125 switch (pAdapter->wapi_info.wapiAuthMode)
4126 {
4127 case WAPI_AUTH_MODE_PSK:
4128 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004129 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 pRoamProfile->AuthType.numEntries = 1;
4131 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4132 break;
4133 }
4134 case WAPI_AUTH_MODE_CERT:
4135 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004136 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 pRoamProfile->AuthType.numEntries = 1;
4138 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4139 break;
4140 }
4141 } // End of switch
4142 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
4143 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
4144 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004145 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 pRoamProfile->EncryptionType.numEntries = 1;
4147 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4148 pRoamProfile->mcEncryptionType.numEntries = 1;
4149 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4150 }
4151 }
4152#endif /* FEATURE_WLAN_WAPI */
4153 /* if previous genIE is not NULL, update AssocIE */
4154 if (0 != pWextState->genIE.length)
4155 {
4156 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
4157 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
4158 pWextState->genIE.length);
4159 pWextState->assocAddIE.length = pWextState->genIE.length;
4160 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
4161 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
4162
4163 /* clear previous genIE after use it */
4164 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
4165 }
4166
4167 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
4168 pWextState->roamProfile.bWPSAssociation = FALSE;
4169
4170 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
4171 pWextState->roamProfile.nAddIEAssocLength))
4172 pWextState->roamProfile.bWPSAssociation = TRUE;
4173
4174
4175 // Disable auto BMPS entry by PMC until DHCP is done
4176 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
4177
Shailender Karmuchia734f332013-04-19 14:02:48 -07004178 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004180
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004181 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
4182 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004183 hdd_select_cbmode(pAdapter,
4184 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
4185 }
4186 status = sme_RoamConnect( hHal,pAdapter->sessionId,
4187 &(pWextState->roamProfile), &roamId);
4188 pRoamProfile->ChannelInfo.ChannelList = NULL;
4189 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004190
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004191 EXIT();
4192 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004193}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004194
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304195int iw_set_essid(struct net_device *dev,
4196 struct iw_request_info *info,
4197 union iwreq_data *wrqu, char *extra)
4198{
4199 int ret;
4200
4201 vos_ssr_protect(__func__);
4202 ret = __iw_set_essid(dev, info, wrqu, extra);
4203 vos_ssr_unprotect(__func__);
4204
4205 return ret;
4206}
4207
Jeff Johnson295189b2012-06-20 16:38:30 -07004208/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004209
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304210 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004211 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004212
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 \param - dev - Pointer to the net device.
4214 - info - Pointer to the iw_request_info.
4215 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004216 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004217 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004218
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304220int __iw_get_essid(struct net_device *dev,
4221 struct iw_request_info *info,
4222 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004223{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304224 hdd_adapter_t *pAdapter;
4225 hdd_context_t *pHddCtx;
4226 hdd_wext_state_t *wextBuf;
4227 hdd_station_ctx_t *pHddStaCtx;
4228 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304229
Jeff Johnson295189b2012-06-20 16:38:30 -07004230 ENTER();
4231
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304232 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4233 if (NULL == pAdapter)
4234 {
4235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4236 "%s: Adapter is NULL",__func__);
4237 return -EINVAL;
4238 }
4239
4240 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4241 ret = wlan_hdd_validate_context(pHddCtx);
4242 if (0 != ret)
4243 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304244 return ret;
4245 }
4246
4247 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4248 if (NULL == pHddStaCtx)
4249 {
4250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4251 "%s: STA Context is NULL",__func__);
4252 return -EINVAL;
4253 }
4254
4255 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4256 if (NULL == wextBuf)
4257 {
4258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4259 "%s: wextBuf is NULL",__func__);
4260 return -EINVAL;
4261 }
4262
Jeff Johnson295189b2012-06-20 16:38:30 -07004263 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
4264 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
4265 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
4266 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
4267 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
4268 {
4269 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
4270 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
4271 dwrq->flags = 1;
4272 } else {
4273 memset(extra, 0, dwrq->length);
4274 dwrq->length = 0;
4275 dwrq->flags = 0;
4276 }
4277 EXIT();
4278 return 0;
4279}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304280
4281int iw_get_essid(struct net_device *dev,
4282 struct iw_request_info *info,
4283 struct iw_point *dwrq, char *extra)
4284{
4285 int ret;
4286
4287 vos_ssr_protect(__func__);
4288 ret = __iw_get_essid(dev, info, dwrq, extra);
4289 vos_ssr_unprotect(__func__);
4290
4291 return ret;
4292}
Jeff Johnson295189b2012-06-20 16:38:30 -07004293/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004294
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304295 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004297
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 \param - dev - Pointer to the net device.
4299 - info - Pointer to the iw_request_info.
4300 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004301 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004303
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304305int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
4306 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004307{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304308 hdd_adapter_t *pAdapter;
4309 hdd_context_t *pHddCtx;
4310 hdd_wext_state_t *pWextState;
4311 hdd_station_ctx_t *pHddStaCtx;
4312 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004313 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304315 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004316
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004318
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304319 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4320 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004321 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4323 "%s: Adapter is NULL",__func__);
4324 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004325 }
4326
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304327 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4328 ret = wlan_hdd_validate_context(pHddCtx);
4329 if (0 != ret)
4330 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304331 return ret;
4332 }
4333
4334 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4335 if (NULL == pHddStaCtx)
4336 {
4337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4338 "%s: STA Context is NULL",__func__);
4339 return -EINVAL;
4340 }
4341
4342 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4343 if (NULL == pWextState)
4344 {
4345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4346 "%s: pWextState is NULL",__func__);
4347 return -EINVAL;
4348 }
4349
4350 pRoamProfile = &pWextState->roamProfile;
4351
Jeff Johnson295189b2012-06-20 16:38:30 -07004352 switch(wrqu->param.flags & IW_AUTH_INDEX)
4353 {
4354 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004355
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004357
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004359
Jeff Johnson295189b2012-06-20 16:38:30 -07004360 case IW_AUTH_CIPHER_PAIRWISE:
4361 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004362 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004363 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004364 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004365 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4366 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004368 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
4369 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004370 }
4371
Jeff Johnson295189b2012-06-20 16:38:30 -07004372 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004373
4374 if( (IW_AUTH_KEY_MGMT_802_1X
4375 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
4377 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004378 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 else
4380 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004381 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004384
4385 if( ( IW_AUTH_KEY_MGMT_802_1X
4386 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4388 /*Dynamic WEP key*/
4389 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4390 else
4391 /*Static WEP key*/
4392 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004393
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 }
4395 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004396
Jeff Johnson295189b2012-06-20 16:38:30 -07004397 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004398 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 return -EINVAL;
4400 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004401
Jeff Johnson295189b2012-06-20 16:38:30 -07004402 pRoamProfile->EncryptionType.numEntries = 1;
4403 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004404 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004405 break;
4406 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004407 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
4409 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4410 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004411
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4413 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
4414 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004415
4416 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004417 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
4418 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004419
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004421
4422 if( ( IW_AUTH_KEY_MGMT_802_1X
4423 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
4424 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4425
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004427
4428 else
4429 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004430 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004431
4432 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
4433 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004434 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004435 if( ( IW_AUTH_KEY_MGMT_802_1X
4436 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4438 {
4439 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4440 }
4441 else
4442 {
4443 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4444 }
4445 }
4446 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004447
Jeff Johnson295189b2012-06-20 16:38:30 -07004448 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004449 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 return -EINVAL;
4451 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004452
Jeff Johnson295189b2012-06-20 16:38:30 -07004453 pRoamProfile->mcEncryptionType.numEntries = 1;
4454 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
4455 }
4456 break;
4457
4458 case IW_AUTH_80211_AUTH_ALG:
4459 {
4460 /*Save the auth algo here and set auth type to SME Roam profile
4461 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004462 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004464
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
4466 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
4467
4468 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
4469 /*Not supported*/
4470 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4471 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4472 }
4473 break;
4474
4475 case IW_AUTH_KEY_MGMT:
4476 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004477#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004478#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
4479 /*Check for CCKM AKM type */
4480 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004481 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
4482 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004483 /* Set the CCKM bit in authKeyMgmt */
4484 /* Right now, this breaks all ref to authKeyMgmt because our
4485 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 */
4487 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
4488 /*Set the key management to 802.1X*/
4489 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004490 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4492 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
4493 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
4494 /*Save the key management*/
4495 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
4496 //pWextState->authKeyMgmt = wrqu->param.value;
4497 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4498 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4499 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
4500 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
4501 /*Save the key management anyway*/
4502 pWextState->authKeyMgmt = wrqu->param.value;
4503 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
4504 /*Save the key management*/
4505 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
4506 //pWextState->authKeyMgmt = wrqu->param.value;
4507 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4508 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4509 }
4510#else
4511 /*Save the key management*/
4512 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004513#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 }
4515 break;
4516
4517 case IW_AUTH_TKIP_COUNTERMEASURES:
4518 {
4519 if(wrqu->param.value) {
4520 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4521 "Counter Measure started %d", wrqu->param.value);
4522 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
4523 }
4524 else {
4525 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4526 "Counter Measure stopped=%d", wrqu->param.value);
4527 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4528 }
4529 }
4530 break;
4531 case IW_AUTH_DROP_UNENCRYPTED:
4532 case IW_AUTH_WPA_ENABLED:
4533 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
4534 case IW_AUTH_ROAMING_CONTROL:
4535 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004536
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004538
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004539 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 wrqu->param.flags & IW_AUTH_INDEX);
4541 break;
4542 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004543
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 EXIT();
4545 return 0;
4546}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304547
4548int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
4549 union iwreq_data *wrqu, char *extra)
4550{
4551 int ret;
4552
4553 vos_ssr_protect(__func__);
4554 ret = __iw_set_auth(dev, info, wrqu, extra);
4555 vos_ssr_unprotect(__func__);
4556
4557 return ret;
4558}
4559
Jeff Johnson295189b2012-06-20 16:38:30 -07004560/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004561
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304562 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004564
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 \param - dev - Pointer to the net device.
4566 - info - Pointer to the iw_request_info.
4567 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004568 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004570
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304572int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4573 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004574{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304575 hdd_adapter_t* pAdapter;
4576 hdd_wext_state_t *pWextState;
4577 tCsrRoamProfile *pRoamProfile;
4578 hdd_context_t *pHddCtx;
4579 int ret = 0;
4580
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004582
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304583 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4584 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004585 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304586 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4587 "%s: Adapter is NULL",__func__);
4588 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004589 }
4590
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304591 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4592 ret = wlan_hdd_validate_context(pHddCtx);
4593 if (0 != ret)
4594 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304595 return ret;
4596 }
4597
4598 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4599 if (NULL == pWextState)
4600 {
4601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4602 "%s: pWextState is NULL",__func__);
4603 return -EINVAL;
4604 }
4605 pRoamProfile = &pWextState->roamProfile;
4606
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 switch(pRoamProfile->negotiatedAuthType)
4608 {
4609 case eCSR_AUTH_TYPE_WPA_NONE:
4610 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4611 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
4612 break;
4613 case eCSR_AUTH_TYPE_WPA:
4614 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4615 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
4616 break;
4617#ifdef WLAN_FEATURE_VOWIFI_11R
4618 case eCSR_AUTH_TYPE_FT_RSN:
4619#endif
4620 case eCSR_AUTH_TYPE_RSN:
4621 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4622 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
4623 break;
4624 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4625 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4626 break;
4627 case eCSR_AUTH_TYPE_SHARED_KEY:
4628 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
4629 break;
4630 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004631 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4633 break;
4634 case eCSR_AUTH_TYPE_AUTOSWITCH:
4635 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4636 break;
4637 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304638 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4640 return -EIO;
4641#ifdef WLAN_FEATURE_VOWIFI_11R
4642 case eCSR_AUTH_TYPE_FT_RSN_PSK:
4643#endif
4644 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07004645#ifdef WLAN_FEATURE_11W
4646 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05304647 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07004648#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05304649 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004650 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4651 return -EIO;
4652 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304653 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4655 return -EIO;
4656 }
4657 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
4658 {
4659 switch(pRoamProfile->negotiatedUCEncryptionType)
4660 {
4661 case eCSR_ENCRYPT_TYPE_NONE:
4662 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4663 break;
4664 case eCSR_ENCRYPT_TYPE_WEP40:
4665 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4666 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4667 break;
4668 case eCSR_ENCRYPT_TYPE_TKIP:
4669 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4670 break;
4671 case eCSR_ENCRYPT_TYPE_WEP104:
4672 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4673 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4674 break;
4675 case eCSR_ENCRYPT_TYPE_AES:
4676 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4677 break;
4678 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304679 hddLog(LOG1, "%s called with unknown auth type %d ",
4680 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 return -EIO;
4682 }
4683 }
4684
Shailender Karmuchia734f332013-04-19 14:02:48 -07004685 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004686 {
4687 switch(pRoamProfile->negotiatedMCEncryptionType)
4688 {
4689 case eCSR_ENCRYPT_TYPE_NONE:
4690 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4691 break;
4692 case eCSR_ENCRYPT_TYPE_WEP40:
4693 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4694 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4695 break;
4696 case eCSR_ENCRYPT_TYPE_TKIP:
4697 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4698 break;
4699 case eCSR_ENCRYPT_TYPE_WEP104:
4700 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4701 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4702 break;
4703 case eCSR_ENCRYPT_TYPE_AES:
4704 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4705 break;
4706 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304707 hddLog(LOG1, "%s called with unknown auth type %d ",
4708 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 return -EIO;
4710 }
4711 }
4712
4713 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004714 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 EXIT();
4716 return 0;
4717}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304718
4719int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4720 union iwreq_data *wrqu,char *extra)
4721{
4722 int ret;
4723
4724 vos_ssr_protect(__func__);
4725 ret = __iw_get_auth(dev, info, wrqu, extra);
4726 vos_ssr_unprotect(__func__);
4727
4728 return ret;
4729}
4730
Jeff Johnson295189b2012-06-20 16:38:30 -07004731/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004732
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304733 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07004734 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004735 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004736
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 \param - dev - Pointer to the net device.
4738 - info - Pointer to the iw_request_info.
4739 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004740 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004741 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004742
Jeff Johnson295189b2012-06-20 16:38:30 -07004743 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304744int __iw_set_ap_address(struct net_device *dev,
4745 struct iw_request_info *info,
4746 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004747{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304748 hdd_station_ctx_t *pHddStaCtx;
4749 hdd_adapter_t *pAdapter;
4750 hdd_context_t *pHddCtx;
4751 v_U8_t *pMacAddress = NULL;
4752 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304753
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304755
4756 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4757 if (NULL == pAdapter)
4758 {
4759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4760 "%s: Adapter is NULL", __func__);
4761 return -EINVAL;
4762 }
4763 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4764 ret = wlan_hdd_validate_context(pHddCtx);
4765 if (0 != ret)
4766 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304767 return ret;
4768 }
4769 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4770 if (NULL == pHddStaCtx)
4771 {
4772 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4773 "%s: pHddStaCtx is NULL", __func__);
4774 return -EINVAL;
4775 }
4776
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4779 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07004781
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304782 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004783 return 0;
4784}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304785
4786int iw_set_ap_address(struct net_device *dev,
4787 struct iw_request_info *info,
4788 union iwreq_data *wrqu, char *extra)
4789{
4790 int ret;
4791
4792 vos_ssr_protect(__func__);
4793 ret = __iw_set_ap_address(dev, info, wrqu, extra);
4794 vos_ssr_unprotect(__func__);
4795
4796 return ret;
4797}
4798
Jeff Johnson295189b2012-06-20 16:38:30 -07004799/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004800
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304801 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 This function returns the BSSID to the wpa_supplicant
4803 \param - dev - Pointer to the net device.
4804 - info - Pointer to the iw_request_info.
4805 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004806 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004807 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004808
Jeff Johnson295189b2012-06-20 16:38:30 -07004809 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304810int __iw_get_ap_address(struct net_device *dev,
4811 struct iw_request_info *info,
4812 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004813{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304814 hdd_station_ctx_t *pHddStaCtx;
4815 hdd_adapter_t *pAdapter;
4816 hdd_context_t *pHddCtx;
4817 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304818
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 ENTER();
4820
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304821 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4822 if (NULL == pAdapter)
4823 {
4824 hddLog(VOS_TRACE_LEVEL_ERROR,
4825 "%s: Adapter is NULL", __func__);
4826 return -EINVAL;
4827 }
4828 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4829 ret = wlan_hdd_validate_context(pHddCtx);
4830 if (0 != ret)
4831 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304832 return ret;
4833 }
4834 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4835 if (NULL == pHddStaCtx)
4836 {
4837 hddLog(VOS_TRACE_LEVEL_ERROR,
4838 "%s: pHddStaCtx is NULL", __func__);
4839 return -EINVAL;
4840 }
4841
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4843 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4844 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004845 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004846 }
4847 else
4848 {
4849 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4850 }
4851 EXIT();
4852 return 0;
4853}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004854
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304855int iw_get_ap_address(struct net_device *dev,
4856 struct iw_request_info *info,
4857 union iwreq_data *wrqu, char *extra)
4858{
4859 int ret;
4860
4861 vos_ssr_protect(__func__);
4862 ret = __iw_get_ap_address(dev, info, wrqu, extra);
4863 vos_ssr_unprotect(__func__);
4864
4865 return ret;
4866}
4867
Chet Lanctot186b5732013-03-18 10:26:30 -07004868#ifdef WLAN_FEATURE_11W
4869/**---------------------------------------------------------------------------
4870
4871 \brief hdd_indicateUnprotMgmtFrame -
4872 This function forwards the unprotected management frame to the supplicant
4873 \param - pAdapter - Pointer to HDD adapter
4874 - nFrameLength - Length of the unprotected frame being passed
4875 - pbFrames - Pointer to the frame buffer
4876 - frameType - 802.11 frame type
4877 \return - nothing
4878
4879 --------------------------------------------------------------------------*/
4880void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4881 tANI_U32 nFrameLength,
4882 tANI_U8* pbFrames,
4883 tANI_U8 frameType )
4884{
4885 tANI_U8 type = 0;
4886 tANI_U8 subType = 0;
4887
4888 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4889 __func__, frameType, nFrameLength);
4890
4891 /* Sanity Checks */
4892 if (NULL == pAdapter)
4893 {
4894 hddLog( LOGE, FL("pAdapter is NULL"));
4895 return;
4896 }
4897
4898 if (NULL == pAdapter->dev)
4899 {
4900 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4901 return;
4902 }
4903
4904 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4905 {
4906 hddLog( LOGE, FL("pAdapter has invalid magic"));
4907 return;
4908 }
4909
4910 if( !nFrameLength )
4911 {
4912 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4913 return;
4914 }
4915
4916 if (NULL == pbFrames) {
4917 hddLog( LOGE, FL("pbFrames is NULL"));
4918 return;
4919 }
4920
4921 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4922 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4923
4924 /* Get pAdapter from Destination mac address of the frame */
4925 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
4926 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05304927#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4928 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
4929#else
Chet Lanctot186b5732013-03-18 10:26:30 -07004930 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05304931#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004932 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4933 }
4934 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
4935 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05304936#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4937 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
4938#else
Chet Lanctot186b5732013-03-18 10:26:30 -07004939 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05304940#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004941 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4942 }
4943 else
4944 {
4945 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
4946 return;
4947 }
4948}
4949#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004950
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004951#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004952void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
4953 tANI_U8 state,
4954 tANI_U16 measInterval )
4955{
4956 union iwreq_data wrqu;
4957 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004958 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004959
4960 if (NULL == pAdapter)
4961 return;
4962
4963 // create the event
4964 memset(&wrqu, '\0', sizeof(wrqu));
4965 memset(buf, '\0', sizeof(buf));
4966
4967 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
4968 tid, state, measInterval);
4969
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004970 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004971
4972 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004973 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004974 // send the event
4975 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4976}
4977
4978void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4979{
4980 union iwreq_data wrqu;
4981 char buf[IW_CUSTOM_MAX + 1];
4982 char *pos = buf;
4983 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4984
4985 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4986 return;
4987
4988 // create the event
4989 memset(&wrqu, '\0', sizeof(wrqu));
4990 memset(buf, '\0', sizeof(buf));
4991
4992 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304993 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
4994 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
4995 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
4996 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004997
4998 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4999 pos += nBytes;
5000 freeBytes -= nBytes;
5001
5002 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
5003 pos += WNI_CFG_BSSID_LEN;
5004 freeBytes -= WNI_CFG_BSSID_LEN;
5005
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005006 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
5007 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005008
5009 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005010 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005011
5012 // send the event
5013 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5014}
5015
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005016void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005017{
5018 union iwreq_data wrqu;
5019 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005020 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005021
5022 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5023 return;
5024
5025 // create the event
5026 memset(&wrqu, '\0', sizeof(wrqu));
5027 memset(buf, '\0', sizeof(buf));
5028
5029 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
5030
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005031 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005032
5033 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005034 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005035
5036 // send the event
5037 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5038}
5039
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005040void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
5041 const tANI_U16 measurementToken,
5042 const tANI_BOOLEAN flag,
5043 const tANI_U8 numBss)
5044{
5045 union iwreq_data wrqu;
5046 char buf[IW_CUSTOM_MAX];
5047 char *pos = buf;
5048 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5049
5050 memset(&wrqu, '\0', sizeof(wrqu));
5051 memset(buf, '\0', sizeof(buf));
5052
5053 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
5054 numBss);
5055
5056 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
5057 flag, numBss);
5058
5059 wrqu.data.pointer = buf;
5060 wrqu.data.length = nBytes;
5061 // send the event
5062 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5063}
5064
5065
5066static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005067 const tCsrRoamInfo *pRoamInfo)
5068{
5069 union iwreq_data wrqu;
5070 char buf[IW_CUSTOM_MAX + 1];
5071 char *pos = buf;
5072 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5073 tANI_U8 i = 0, len = 0;
5074 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
5075 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005076 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
5077 tANI_U8 ieLenByte = 1;
5078 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
5079#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005080
5081 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5082 return;
5083
5084 /* Custom event can pass maximum of 256 bytes of data,
5085 based on the IE len we need to identify how many BSS info can
5086 be filled in to custom event data */
5087 /*
5088 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
5089 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
5090 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
5091 */
5092
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005093 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005094 {
5095 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
5096 /* If the measurement is none and no scan results found,
5097 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005098 hdd_indicateEseBcnReportNoResults(pAdapter,
5099 pRoamInfo->pEseBcnReportRsp->measurementToken,
5100 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005101 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005102 }
5103 else
5104 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005105 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005106 {
5107 memset(&wrqu, '\0', sizeof(wrqu));
5108 memset(buf, '\0', sizeof(buf));
5109 tot_bcn_ieLen = 0;
5110 sendBss = 0;
5111 pos = buf;
5112 freeBytes = IW_CUSTOM_MAX;
5113
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005114 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005115 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005116 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
5117 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005118 {
5119 break;
5120 }
5121 tot_bcn_ieLen += len;
5122 sendBss++;
5123 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
5124 "IeLength(%d) Length of Ie(%d) totLen(%d)",
5125 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005126 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005127 tot_bcn_ieLen);
5128 }
5129
5130 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
5131 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005132 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5133 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005134
5135 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005136 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5137 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005138 pos += nBytes;
5139 freeBytes -= nBytes;
5140
5141 /* Copy total Beacon report data length */
5142 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
5143 pos += sizeof(tot_bcn_ieLen);
5144 freeBytes -= sizeof(tot_bcn_ieLen);
5145
5146 for (i = 0; i < sendBss; i++)
5147 {
5148 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305149 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
5150 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005151 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005152 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
5153 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
5154 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
5155 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
5156 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
5157 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
5158 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
5159 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
5160 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
5161 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
5162 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
5163 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
5164 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
5165 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
5166 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
5167 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005168
5169 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005170 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
5171 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005172 pos += len;
5173 freeBytes -= len;
5174
5175 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005176 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005177 vos_mem_copy(pos, (char*)&len, sizeof(len));
5178 pos += sizeof(len);
5179 freeBytes -= sizeof(len);
5180
5181 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005182 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005183 pos += len;
5184 freeBytes -= len;
5185 }
5186
5187 wrqu.data.pointer = buf;
5188 wrqu.data.length = strlen(buf);
5189
5190 // send the event
5191 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5192 lastSent += sendBss;
5193 }
5194 }
5195}
5196
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005197#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005198