blob: a1b8189f60d112a75f677907ab673e059084992f [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);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002951 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002952 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002953 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002954
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002955 /* check if there is available index for this new TDLS STA */
2956 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2957 {
2958 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2959 {
2960 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2961 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2962
2963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002964 ("TDLS: STA IDX at %d is %d "
2965 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002966 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002967 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002968
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002969 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002970 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2971 status = eHAL_STATUS_SUCCESS ;
2972 break ;
2973 }
2974 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002975 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002976 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002977 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002978 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2979 "wlan_hdd_tdls_set_sta_id() failed");
2980 return VOS_FALSE;
2981 }
2982
2983 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302984 /* store the ucast signature , if required for further reference. */
2985
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002986 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302987 /* start TDLS client registration with TL */
2988 status = hdd_roamRegisterTDLSSTA( pAdapter,
2989 pRoamInfo->peerMac,
2990 pRoamInfo->staId,
2991 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05302992 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002993 }
2994 else
2995 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002996 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002998 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002999 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003000 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003001 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003002 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003003 break ;
3004 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003005 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3006 {
3007 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3008 {
3009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3010 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3011 }
3012 /* store the ucast signature which will be used later when
3013 * registering to TL
3014 */
3015 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3016 complete(&pAdapter->tdls_add_station_comp);
3017 break;
3018 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303019 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3020 {
3021 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3022 {
3023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3024 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
3025 }
3026 complete(&pAdapter->tdls_link_establish_req_comp);
3027 break;
3028 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003029 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003030 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003031 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003032 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003033 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003034 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3035 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003036 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003038 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3039
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303040 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303041 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003042 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3044 " Current status for peer" MAC_ADDRESS_STR "is %d",
3045 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303046 if (TDLS_IS_CONNECTED(curr_peer) ||
3047 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303048 {
3049 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3050 }
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303051 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003052 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003053 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003054
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003055 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3056 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3057 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003058 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003059 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003060 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003061 break ;
3062 }
3063 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003064 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003065 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003066 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003067 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3068 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003069 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003070 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3071 "%s: Sending teardown to supplicant with reason code %u",
3072 __func__, pRoamInfo->reasonCode);
3073
3074#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303075 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003076 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003077#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003078 status = eHAL_STATUS_SUCCESS ;
3079 break ;
3080 }
3081 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3082 {
3083 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003084 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003085 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003086 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3087 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003088 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003090 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003091 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003092 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003093 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
3094 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3095 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003096
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003097 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003098 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003099 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3100 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003101
3102 status = eHAL_STATUS_SUCCESS ;
3103 }
3104 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303105 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003106 break ;
3107 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003108 default:
3109 {
3110 break ;
3111 }
3112 }
3113
3114 return status ;
3115}
3116#endif
3117
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003118static void iw_full_power_cbfn (void *pContext, eHalStatus status)
3119{
3120 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3121 hdd_context_t *pHddCtx = NULL;
3122 int ret;
3123
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303124 ENTER();
3125
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003126 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3127 {
3128 hddLog(VOS_TRACE_LEVEL_ERROR,
3129 "%s: Bad param, pAdapter [%p]",
3130 __func__, pAdapter);
3131 return;
3132 }
3133
3134 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3135 ret = wlan_hdd_validate_context(pHddCtx);
3136 if (0 != ret)
3137 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003138 return;
3139 }
3140
3141 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3142 {
3143 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3144 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303145
3146 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003147}
3148
Shailender Karmuchia734f332013-04-19 14:02:48 -07003149eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003150 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3151{
3152 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
3153 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303154 hdd_wext_state_t *pWextState = NULL;
3155 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003156 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07003157 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003158
3159 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003160 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003161 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003162
3163 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303164 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003165 {
3166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303167 "invalid adapter or adapter has invalid magic");
3168 return eHAL_STATUS_FAILURE;
3169 }
3170
3171 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3172 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3173
3174 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3175 {
3176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3177 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003178 return eHAL_STATUS_FAILURE;
3179 }
3180
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05303181
3182 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
3183 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 switch( roamStatus )
3185 {
3186 case eCSR_ROAM_SESSION_OPENED:
3187 if(pAdapter != NULL)
3188 {
3189 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
3190 complete(&pAdapter->session_open_comp_var);
3191 }
3192 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003193
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003194#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
3195 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07003197 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 * interface down */
3199 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303200 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
3201 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05303202 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3204 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
3205 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003206 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3207 }
3208 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05303209 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 break;
3211
3212 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003213 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07003214 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07003215 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 // eCSR_ROAM_SHOULD_ROAM will be received.
3217 // Where in we will not mark the link down
3218 // Also we want to stop tx at this point when we will be
3219 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003220 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 {
3222 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303223 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303225 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3226 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3227 {
3228 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
3229 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003230 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303231 * Deregister this STA with TL, but do not flush the packets
3232 * for this STA from wmm_tx_queue. Since there is no valid STA
3233 * for these packets they will not be transmitted. Eventually
3234 * after the reassociation is successful, these packets will be
3235 * transmitted after registering STA with TL again. This ensures
3236 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003237 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303238 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
3239 pHddStaCtx->conn_info.staId[0]);
3240 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003241 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3243 FL("WLANTL_ClearSTAClient failed for staID %d."
3244 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
3245 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003246 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003247 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003248 }
3249 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003250 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 break;
3252#endif
3253
3254 case eCSR_ROAM_SHOULD_ROAM:
3255 // Dont need to do anything
3256 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003257 struct net_device *dev = pAdapter->dev;
3258 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3259 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303260 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003262#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003263 if (pHddStaCtx->ft_carrier_on == FALSE)
3264 {
3265#endif
3266 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003267#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003268 }
3269#endif
3270
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003271#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 //We should clear all sta register with TL, for now, only one.
3273 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
3274 if ( !VOS_IS_STATUS_SUCCESS(status ) )
3275 {
3276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3277 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
3278 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003279 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 }
3283 break;
3284 case eCSR_ROAM_LOSTLINK:
3285 case eCSR_ROAM_DISASSOCIATED:
3286 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3288 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05303289 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003290 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3291 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07003292 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3293 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303294 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07003295 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08003296
3297 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
3298 pHddCtx->configuredMcastBcastFilter =
3299 pHddCtx->sus_res_mcastbcast_filter;
3300 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
3301 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303302
Amar Singhald53568e2013-09-26 11:03:45 -07003303 hddLog(VOS_TRACE_LEVEL_INFO,
3304 "offload: disassociation happening, restoring configuredMcastBcastFilter");
3305 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
3306 pHddCtx->configuredMcastBcastFilter);
3307 hddLog(VOS_TRACE_LEVEL_INFO,
3308 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3310 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003311#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303312 /* Call to clear any MC Addr List filter applied after
3313 * successful connection.
3314 */
3315 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003316#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003317 }
3318 break;
3319 case eCSR_ROAM_IBSS_LEAVE:
3320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3321 "****eCSR_ROAM_IBSS_LEAVE****");
3322 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3323 break;
3324 case eCSR_ROAM_ASSOCIATION_COMPLETION:
3325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3326 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303327 // To Do - address probable memory leak with WEP encryption upon successful association
3328 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303330 //Clear saved connection information in HDD
3331 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303333 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003334
3335 break;
3336 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003337 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 pRoamInfo, roamId, roamStatus, roamResult );
3339 break;
3340 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07003341 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
3342 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 break;
3344
3345 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
3346 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003347 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003348
3349 case eCSR_ROAM_MIC_ERROR_IND:
3350 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3351 break;
3352
3353 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003354 {
3355 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3356
3357 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003358 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
3359 (TRUE == pHddCtx->hdd_wlan_suspended) &&
3360 (eCSR_ROAM_RESULT_NONE == roamResult))
3361 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003362 /* Send DTIM period to the FW; only if the wlan is already
3363 in suspend. This is the case with roaming (reassoc),
3364 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
3365 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
3366 before the ENTER_BMPS_REQ ensures Listen Interval is
3367 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003368 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003369
3370 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003371 if due to unexpected scenario, if we are in BMPS,
3372 then trigger Exit and Enter BMPS to take DTIM period
3373 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003374 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
3375 {
3376 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
3377
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003378 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3379 iw_full_power_cbfn, pAdapter,
3380 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003381 }
3382 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303383
3384 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303385 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
3386 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
3387 (eCSR_ROAM_RESULT_NONE == roamResult))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303388 {
3389 hddLog( LOG1, FL("Device in full power."
3390 "Stop and start traffic timer for roaming"));
3391 pmcStopTrafficTimer(pHddCtx->hHal);
3392 if (pmcStartTrafficTimer(pHddCtx->hHal,
3393 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
3394 {
3395 hddLog(LOGP, FL("Cannot start traffic timer"));
3396 }
3397 }
3398
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003399 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303400 if (eCSR_ROAM_RESULT_NONE == roamResult)
3401 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003403 break;
3404#ifdef WLAN_FEATURE_VOWIFI_11R
3405 case eCSR_ROAM_FT_RESPONSE:
3406 hdd_SendFTEvent(pAdapter);
3407 break;
3408#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07003409#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003410 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003411 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07003412 {
3413 /* Notify the supplicant of a new candidate */
3414 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
3415 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003416 break;
3417#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003418
Yue Maef608272013-04-08 23:09:17 -07003419#ifdef FEATURE_WLAN_LFR_METRICS
3420 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
3421 /* This event is to notify pre-auth initiation */
3422 if (VOS_STATUS_SUCCESS !=
3423 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
3424 {
3425 halStatus = eHAL_STATUS_FAILURE;
3426 }
3427 break;
3428 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
3429 /* This event will notify pre-auth completion in case of success */
3430 if (VOS_STATUS_SUCCESS !=
3431 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3432 pRoamInfo, 1))
3433 {
3434 halStatus = eHAL_STATUS_FAILURE;
3435 }
3436 break;
3437 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
3438 /* This event will notify pre-auth completion in case of failure. */
3439 if (VOS_STATUS_SUCCESS !=
3440 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3441 pRoamInfo, 0))
3442 {
3443 halStatus = eHAL_STATUS_FAILURE;
3444 }
3445 break;
3446 case eCSR_ROAM_HANDOVER_SUCCESS:
3447 /* This event is to notify handover success.
3448 It will be only invoked on success */
3449 if (VOS_STATUS_SUCCESS !=
3450 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
3451 {
3452 halStatus = eHAL_STATUS_FAILURE;
3453 }
3454 break;
3455#endif
3456
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 case eCSR_ROAM_INDICATE_MGMT_FRAME:
3458 hdd_indicateMgmtFrame( pAdapter,
3459 pRoamInfo->nFrameLength,
3460 pRoamInfo->pbFrames,
3461 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05303462 pRoamInfo->rxChan,
3463 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 break;
3465 case eCSR_ROAM_REMAIN_CHAN_READY:
3466 hdd_remainChanReadyHandler( pAdapter );
3467 break;
3468 case eCSR_ROAM_SEND_ACTION_CNF:
3469 hdd_sendActionCnf( pAdapter,
3470 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
3471 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003472#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08003473 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003474 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08003475 roamId, roamStatus, roamResult );
3476 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003477 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
3478 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
3479 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003480#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003481#ifdef WLAN_FEATURE_11W
3482 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
3483 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
3484 pRoamInfo->pbFrames,
3485 pRoamInfo->frameType);
3486 break;
3487#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003488#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003489 case eCSR_ROAM_TSM_IE_IND:
3490 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
3491 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
3492 break;
3493
3494 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
3495 {
3496 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
3497 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
3498 {
3499 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
3500 }
3501 break;
3502 }
3503
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003504 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003505 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003506 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003507 break;
3508 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003509
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003510 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003511 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003512 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003513 break;
3514 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003515#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05303516 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
3517 {
3518 pAdapter->maxRateFlags = roamResult;
3519 break;
3520 }
3521 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07003522 break;
3523 }
3524 return( halStatus );
3525}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003526eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003527{
3528 eCsrAuthType auth_type;
3529 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003530 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 {
3532 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003533 } else
3534 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 {
3536 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003537 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003538#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003539 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 {
3541 // Check for 11r FT Authentication with PSK
3542 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003543 } else
3544 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003545 {
3546 // Check for 11R FT Authentication with 802.1X
3547 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003548 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003549#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003550#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003551 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003552 {
3553 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3554 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003555#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003556#ifdef WLAN_FEATURE_11W
3557 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3558 {
3559 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3560 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303561 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
3562 {
3563 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3564 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003565#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003566 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003567 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3568 }
3569 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003570}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003571
Shailender Karmuchia734f332013-04-19 14:02:48 -07003572eCsrAuthType
3573hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003574{
3575 eCsrAuthType auth_type;
3576 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003577 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 {
3579 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003580 } else
3581 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 {
3583 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003584 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003585#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003586 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 {
3588 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003589 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003590#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003591 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003592 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3593 }
3594 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3595 return auth_type;
3596}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003597
Shailender Karmuchia734f332013-04-19 14:02:48 -07003598eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003599hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003600{
3601 eCsrEncryptionType cipher_type;
3602 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003603 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 {
3605 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003606 }
3607 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003608 {
3609 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003610 }
3611 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 {
3613 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003614 }
3615 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003616 {
3617 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003618 }
3619 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3620 {
3621 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3622 }
3623 else
3624 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3626 }
3627 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3628 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003629}
Jeff Johnson295189b2012-06-20 16:38:30 -07003630/* To find if the MAC address is NULL */
3631static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3632{
3633 int i;
3634 for (i = 0; i < length; i++)
3635 {
3636 if (0x00 != (macAddr[i]))
3637 {
3638 return FALSE;
3639 }
3640 }
3641 return TRUE;
3642} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003643
Shailender Karmuchia734f332013-04-19 14:02:48 -07003644eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003645hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003646{
3647 eCsrEncryptionType cipher_type;
3648 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003649 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 {
3651 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003652 } else
3653 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 {
3655 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003656 } else
3657 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 {
3659 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003660 } else
3661 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003662 {
3663 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003664 } else
3665 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003667 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3668 } else
3669 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3671 }
3672 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3673 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003674}
Jeff Johnson295189b2012-06-20 16:38:30 -07003675
Shailender Karmuchia734f332013-04-19 14:02:48 -07003676static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3677 struct ether_addr *pBssid,
3678 eCsrEncryptionType *pEncryptType,
3679 eCsrEncryptionType *mcEncryptType,
3680 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003681#ifdef WLAN_FEATURE_11W
3682 u_int8_t *pMfpRequired,
3683 u_int8_t *pMfpCapable,
3684#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003685 u_int16_t gen_ie_len,
3686 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003687{
3688 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003689 eHalStatus result;
3690 tDot11fIERSN dot11RSNIE;
3691 tDot11fIEWPA dot11WPAIE;
3692 tANI_U32 i;
3693 tANI_U8 *pRsnIe;
3694 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003696 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003697
3698 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3699 flag to 0 */
3700 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3701 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3702
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003704 if ( gen_ie[0] == DOT11F_EID_RSN)
3705 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003707 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3709 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303710 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3711 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 return -EINVAL;
3713 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003714 // Skip past the EID byte and length byte
3715 pRsnIe = gen_ie + 2;
3716 RSNIeLen = gen_ie_len - 2;
3717 // Unpack the RSN IE
3718 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3719 pRsnIe,
3720 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003721 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003722 // Copy out the encryption and authentication types
3723 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003724 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003725 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003726 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003727 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003728 but probably I suspect we can do something different*/
3729 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003730 // Just translate the FIRST one
3731 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3732 //dot11RSNIE.pwise_cipher_suite_count
3733 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3734 //dot11RSNIE.gp_cipher_suite_count
3735 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003736#ifdef WLAN_FEATURE_11W
3737 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3738 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3739#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003741 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003743 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303745 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003746 break;
3747 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003748 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303750 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 break;
3752 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003753 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003754 // For right now, I assume setASSOCIATE() has passed in the bssid.
3755 vos_mem_copy(PMKIDCache[i].BSSID,
3756 pBssid, ETHER_ADDR_LEN);
3757 vos_mem_copy(PMKIDCache[i].PMKID,
3758 dot11RSNIE.pmkid[i],
3759 CSR_RSN_PMKID_SIZE);
3760 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003761
3762 if (updatePMKCache)
3763 {
3764 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003765 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003766 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003767 // Finally set the PMKSA ID Cache in CSR
3768 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3769 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303770 dot11RSNIE.pmkid_count,
3771 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07003772 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003773 }
3774 else if (gen_ie[0] == DOT11F_EID_WPA)
3775 {
3776 // Validity checks
3777 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3778 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3779 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303780 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3781 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003782 return -EINVAL;
3783 }
3784 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003785 pRsnIe = gen_ie + 2 + 4;
3786 RSNIeLen = gen_ie_len - (2 + 4);
3787 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3789 pRsnIe,
3790 RSNIeLen,
3791 &dot11WPAIE);
3792 // Copy out the encryption and authentication types
3793 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003794 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003796 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003797 //dot11WPAIE.auth_suite_count
3798 // Just translate the FIRST one
3799 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3800 //dot11WPAIE.unicast_cipher_count
3801 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3802 //dot11WPAIE.unicast_cipher_count
3803 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3804 }
3805 else
3806 {
3807 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003808 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 }
3810 return 0;
3811}
3812int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3813{
3814 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3815 v_U32_t status = 0;
3816 eCsrEncryptionType RSNEncryptType;
3817 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003818#ifdef WLAN_FEATURE_11W
3819 u_int8_t RSNMfpRequired;
3820 u_int8_t RSNMfpCapable;
3821#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003822 struct ether_addr bSsid; // MAC address of assoc peer
3823 // MAC address of assoc peer
3824 // But, this routine is only called when we are NOT associated.
3825 vos_mem_copy(bSsid.ether_addr_octet,
3826 pWextState->roamProfile.BSSIDs.bssid,
3827 sizeof(bSsid.ether_addr_octet));
3828 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3829 {
3830 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003831 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 else
3833 {
3834 return 0;
3835 }
3836 // The actual processing may eventually be more extensive than this.
3837 // Right now, just consume any PMKIDs that are sent in by the app.
3838 status = hdd_ProcessGENIE(pAdapter,
3839 &bSsid, // MAC address of assoc peer
3840 &RSNEncryptType,
3841 &mcRSNEncryptType,
3842 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003843#ifdef WLAN_FEATURE_11W
3844 &RSNMfpRequired,
3845 &RSNMfpCapable,
3846#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 pWextState->WPARSNIE[1]+2,
3848 pWextState->WPARSNIE);
3849 if (status == 0)
3850 {
3851 // Now copy over all the security attributes you have parsed out
3852 pWextState->roamProfile.EncryptionType.numEntries = 1;
3853 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003854
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3856 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003857
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003858 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3859 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3860 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3861 {
3862 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3863 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3864 either AES/TKIP based on group cipher configuration
3865 mentioned in the wpa_supplicant.conf.*/
3866
3867 /*Set the unicast cipher same as multicast cipher*/
3868 pWextState->roamProfile.EncryptionType.encryptionType[0]
3869 = mcRSNEncryptType;
3870 }
3871
Chet Lanctot186b5732013-03-18 10:26:30 -07003872#ifdef WLAN_FEATURE_11W
3873 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3874 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3875#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003876 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 }
3878 return 0;
3879}
3880int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3881{
3882 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3883 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3884 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3885 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003886
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003888 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003889
Jeff Johnson295189b2012-06-20 16:38:30 -07003890 switch( pHddStaCtx->conn_info.authType)
3891 {
3892 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003893#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 case eCSR_AUTH_TYPE_CCKM_WPA:
3895 case eCSR_AUTH_TYPE_CCKM_RSN:
3896#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003897 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3898
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003900 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003902
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003903#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003904 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3905 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3906 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003907 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003908 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3909 } else
3910 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003911 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003912 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 } else
3914#endif
3915 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3916 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003917 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3918 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3920 == IW_AUTH_KEY_MGMT_PSK) {
3921 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003922 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 }
3926 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003927#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003928 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3929 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3930 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003931 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003932 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003934 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003935 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003936 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 } else
3938#endif
3939
3940#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003941 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3942 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003943 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003944 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003945 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003946 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3948 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003949 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 } else
3951#endif
3952
Chet Lanctot186b5732013-03-18 10:26:30 -07003953#ifdef WLAN_FEATURE_11W
3954 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3955 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3956 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303957 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
3958 pRoamProfile->AuthType.authType[0] =
3959 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3960 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003961#endif
3962
Shailender Karmuchia734f332013-04-19 14:02:48 -07003963 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003964 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003965 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3966 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3968 == IW_AUTH_KEY_MGMT_PSK) {
3969 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003970 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003971 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003974 break;
3975
Jeff Johnson295189b2012-06-20 16:38:30 -07003976 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003977
3978 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 break;
3980 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003981
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003982#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08003983 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003984#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3986 break;
3987 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003988
Jeff Johnson295189b2012-06-20 16:38:30 -07003989 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003990 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003991
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 EXIT();
3993 return 0;
3994}
3995
3996/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003997
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303998 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003999 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07004000 to the CSR roam profile.
4001
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 \param - dev - Pointer to the net device.
4003 - info - Pointer to the iw_request_info.
4004 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004005 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004007
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 --------------------------------------------------------------------------*/
4009
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304010int __iw_set_essid(struct net_device *dev,
4011 struct iw_request_info *info,
4012 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004013{
4014 v_U32_t status = 0;
4015 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304016 hdd_adapter_t *pAdapter;
4017 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 v_U32_t roamId;
4019 tCsrRoamProfile *pRoamProfile;
4020 eMib_dot11DesiredBssType connectedBssType;
4021 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304022 tHalHandle hHal;
4023 hdd_station_ctx_t *pHddStaCtx;
4024 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004025
Jeff Johnson295189b2012-06-20 16:38:30 -07004026 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304027 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4028 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304031 "%s: Adapter is NULL",__func__);
4032 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 }
4034
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304035 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4036 ret = wlan_hdd_validate_context(pHddCtx);
4037 if (0 != ret)
4038 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304039 return ret;
4040 }
4041
4042 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4043 if (NULL == hHal)
4044 {
4045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4046 "%s: Hal Context is NULL",__func__);
4047 return -EINVAL;
4048 }
4049 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4050 if (NULL == pHddStaCtx)
4051 {
4052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4053 "%s: STA Context is NULL",__func__);
4054 return -EINVAL;
4055 }
4056 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4057 if (NULL == pWextState)
4058 {
4059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4060 "%s: pWextState is NULL",__func__);
4061 return -EINVAL;
4062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
4064 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
4065 return -EBUSY;
4066 }
4067 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
4068 return -EINVAL;
4069 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004070 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 {
4072 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
4073 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
4074 {
4075 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004076 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4078 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
4079
4080 if(VOS_STATUS_SUCCESS == vosStatus)
4081 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
4082 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4083 }
4084 }
4085 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004086 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 {
4088 return -EINVAL;
4089 }
4090 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004091 /** when cfg80211 defined, wpa_supplicant wext driver uses
4092 zero-length, null-string ssid for force disconnection.
4093 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 driver MUST return success */
4095 if ( 0 == wrqu->essid.length ) {
4096 return 0;
4097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004098
4099 status = hdd_wmm_get_uapsd_mask(pAdapter,
4100 &pWextState->roamProfile.uapsd_mask);
4101 if (VOS_STATUS_SUCCESS != status)
4102 {
4103 pWextState->roamProfile.uapsd_mask = 0;
4104 }
4105 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004106
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004108
4109 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
4111 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
4112 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004113
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 //set gen ie
4115 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
4116
4117 //set auth
4118 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
4119 }
4120#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004121 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 if (pAdapter->wapi_info.nWapiMode)
4123 {
4124 switch (pAdapter->wapi_info.wapiAuthMode)
4125 {
4126 case WAPI_AUTH_MODE_PSK:
4127 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004128 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004129 pRoamProfile->AuthType.numEntries = 1;
4130 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4131 break;
4132 }
4133 case WAPI_AUTH_MODE_CERT:
4134 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004135 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 pRoamProfile->AuthType.numEntries = 1;
4137 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4138 break;
4139 }
4140 } // End of switch
4141 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
4142 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
4143 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004144 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 pRoamProfile->EncryptionType.numEntries = 1;
4146 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4147 pRoamProfile->mcEncryptionType.numEntries = 1;
4148 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4149 }
4150 }
4151#endif /* FEATURE_WLAN_WAPI */
4152 /* if previous genIE is not NULL, update AssocIE */
4153 if (0 != pWextState->genIE.length)
4154 {
4155 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
4156 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
4157 pWextState->genIE.length);
4158 pWextState->assocAddIE.length = pWextState->genIE.length;
4159 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
4160 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
4161
4162 /* clear previous genIE after use it */
4163 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
4164 }
4165
4166 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
4167 pWextState->roamProfile.bWPSAssociation = FALSE;
4168
4169 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
4170 pWextState->roamProfile.nAddIEAssocLength))
4171 pWextState->roamProfile.bWPSAssociation = TRUE;
4172
4173
4174 // Disable auto BMPS entry by PMC until DHCP is done
4175 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
4176
Shailender Karmuchia734f332013-04-19 14:02:48 -07004177 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004179
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004180 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
4181 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004182 hdd_select_cbmode(pAdapter,
4183 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
4184 }
4185 status = sme_RoamConnect( hHal,pAdapter->sessionId,
4186 &(pWextState->roamProfile), &roamId);
4187 pRoamProfile->ChannelInfo.ChannelList = NULL;
4188 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004189
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004190 EXIT();
4191 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004192}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004193
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304194int iw_set_essid(struct net_device *dev,
4195 struct iw_request_info *info,
4196 union iwreq_data *wrqu, char *extra)
4197{
4198 int ret;
4199
4200 vos_ssr_protect(__func__);
4201 ret = __iw_set_essid(dev, info, wrqu, extra);
4202 vos_ssr_unprotect(__func__);
4203
4204 return ret;
4205}
4206
Jeff Johnson295189b2012-06-20 16:38:30 -07004207/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004208
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304209 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004211
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 \param - dev - Pointer to the net device.
4213 - info - Pointer to the iw_request_info.
4214 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004215 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004217
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304219int __iw_get_essid(struct net_device *dev,
4220 struct iw_request_info *info,
4221 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004222{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304223 hdd_adapter_t *pAdapter;
4224 hdd_context_t *pHddCtx;
4225 hdd_wext_state_t *wextBuf;
4226 hdd_station_ctx_t *pHddStaCtx;
4227 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304228
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 ENTER();
4230
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304231 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4232 if (NULL == pAdapter)
4233 {
4234 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4235 "%s: Adapter is NULL",__func__);
4236 return -EINVAL;
4237 }
4238
4239 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4240 ret = wlan_hdd_validate_context(pHddCtx);
4241 if (0 != ret)
4242 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304243 return ret;
4244 }
4245
4246 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4247 if (NULL == pHddStaCtx)
4248 {
4249 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4250 "%s: STA Context is NULL",__func__);
4251 return -EINVAL;
4252 }
4253
4254 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4255 if (NULL == wextBuf)
4256 {
4257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4258 "%s: wextBuf is NULL",__func__);
4259 return -EINVAL;
4260 }
4261
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
4263 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
4264 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
4265 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
4266 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
4267 {
4268 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
4269 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
4270 dwrq->flags = 1;
4271 } else {
4272 memset(extra, 0, dwrq->length);
4273 dwrq->length = 0;
4274 dwrq->flags = 0;
4275 }
4276 EXIT();
4277 return 0;
4278}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304279
4280int iw_get_essid(struct net_device *dev,
4281 struct iw_request_info *info,
4282 struct iw_point *dwrq, char *extra)
4283{
4284 int ret;
4285
4286 vos_ssr_protect(__func__);
4287 ret = __iw_get_essid(dev, info, dwrq, extra);
4288 vos_ssr_unprotect(__func__);
4289
4290 return ret;
4291}
Jeff Johnson295189b2012-06-20 16:38:30 -07004292/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004293
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304294 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004296
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 \param - dev - Pointer to the net device.
4298 - info - Pointer to the iw_request_info.
4299 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004300 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004301 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004302
Jeff Johnson295189b2012-06-20 16:38:30 -07004303 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304304int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
4305 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004306{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304307 hdd_adapter_t *pAdapter;
4308 hdd_context_t *pHddCtx;
4309 hdd_wext_state_t *pWextState;
4310 hdd_station_ctx_t *pHddStaCtx;
4311 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004312 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304314 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004315
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004317
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304318 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4319 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004320 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4322 "%s: Adapter is NULL",__func__);
4323 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004324 }
4325
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304326 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4327 ret = wlan_hdd_validate_context(pHddCtx);
4328 if (0 != ret)
4329 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304330 return ret;
4331 }
4332
4333 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4334 if (NULL == pHddStaCtx)
4335 {
4336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4337 "%s: STA Context is NULL",__func__);
4338 return -EINVAL;
4339 }
4340
4341 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4342 if (NULL == pWextState)
4343 {
4344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4345 "%s: pWextState is NULL",__func__);
4346 return -EINVAL;
4347 }
4348
4349 pRoamProfile = &pWextState->roamProfile;
4350
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 switch(wrqu->param.flags & IW_AUTH_INDEX)
4352 {
4353 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004354
Jeff Johnson295189b2012-06-20 16:38:30 -07004355 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004356
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004358
Jeff Johnson295189b2012-06-20 16:38:30 -07004359 case IW_AUTH_CIPHER_PAIRWISE:
4360 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004361 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004364 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4365 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004366 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004367 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
4368 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004369 }
4370
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004372
4373 if( (IW_AUTH_KEY_MGMT_802_1X
4374 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
4376 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004377 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 else
4379 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004380 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004382 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004383
4384 if( ( IW_AUTH_KEY_MGMT_802_1X
4385 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4387 /*Dynamic WEP key*/
4388 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4389 else
4390 /*Static WEP key*/
4391 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004392
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 }
4394 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004395
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004397 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 return -EINVAL;
4399 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004400
Jeff Johnson295189b2012-06-20 16:38:30 -07004401 pRoamProfile->EncryptionType.numEntries = 1;
4402 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004404 break;
4405 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004406 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004407 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
4408 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4409 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004410
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4412 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
4413 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004414
4415 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
4417 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004418
Jeff Johnson295189b2012-06-20 16:38:30 -07004419 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004420
4421 if( ( IW_AUTH_KEY_MGMT_802_1X
4422 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
4423 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4424
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004426
4427 else
4428 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004430
4431 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
4432 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004433 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004434 if( ( IW_AUTH_KEY_MGMT_802_1X
4435 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4437 {
4438 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4439 }
4440 else
4441 {
4442 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4443 }
4444 }
4445 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004446
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004448 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004449 return -EINVAL;
4450 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004451
Jeff Johnson295189b2012-06-20 16:38:30 -07004452 pRoamProfile->mcEncryptionType.numEntries = 1;
4453 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
4454 }
4455 break;
4456
4457 case IW_AUTH_80211_AUTH_ALG:
4458 {
4459 /*Save the auth algo here and set auth type to SME Roam profile
4460 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004461 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004463
Jeff Johnson295189b2012-06-20 16:38:30 -07004464 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
4465 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
4466
4467 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
4468 /*Not supported*/
4469 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4470 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4471 }
4472 break;
4473
4474 case IW_AUTH_KEY_MGMT:
4475 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004476#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004477#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
4478 /*Check for CCKM AKM type */
4479 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004480 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
4481 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004482 /* Set the CCKM bit in authKeyMgmt */
4483 /* Right now, this breaks all ref to authKeyMgmt because our
4484 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 */
4486 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
4487 /*Set the key management to 802.1X*/
4488 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004489 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4491 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
4492 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
4493 /*Save the key management*/
4494 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
4495 //pWextState->authKeyMgmt = wrqu->param.value;
4496 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4497 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4498 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
4499 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
4500 /*Save the key management anyway*/
4501 pWextState->authKeyMgmt = wrqu->param.value;
4502 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
4503 /*Save the key management*/
4504 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
4505 //pWextState->authKeyMgmt = wrqu->param.value;
4506 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4507 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4508 }
4509#else
4510 /*Save the key management*/
4511 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004512#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 }
4514 break;
4515
4516 case IW_AUTH_TKIP_COUNTERMEASURES:
4517 {
4518 if(wrqu->param.value) {
4519 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4520 "Counter Measure started %d", wrqu->param.value);
4521 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
4522 }
4523 else {
4524 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4525 "Counter Measure stopped=%d", wrqu->param.value);
4526 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4527 }
4528 }
4529 break;
4530 case IW_AUTH_DROP_UNENCRYPTED:
4531 case IW_AUTH_WPA_ENABLED:
4532 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
4533 case IW_AUTH_ROAMING_CONTROL:
4534 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004535
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004537
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004538 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 wrqu->param.flags & IW_AUTH_INDEX);
4540 break;
4541 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004542
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 EXIT();
4544 return 0;
4545}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304546
4547int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
4548 union iwreq_data *wrqu, char *extra)
4549{
4550 int ret;
4551
4552 vos_ssr_protect(__func__);
4553 ret = __iw_set_auth(dev, info, wrqu, extra);
4554 vos_ssr_unprotect(__func__);
4555
4556 return ret;
4557}
4558
Jeff Johnson295189b2012-06-20 16:38:30 -07004559/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004560
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304561 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004562 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004563
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 \param - dev - Pointer to the net device.
4565 - info - Pointer to the iw_request_info.
4566 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004567 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004569
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304571int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4572 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004573{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304574 hdd_adapter_t* pAdapter;
4575 hdd_wext_state_t *pWextState;
4576 tCsrRoamProfile *pRoamProfile;
4577 hdd_context_t *pHddCtx;
4578 int ret = 0;
4579
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004581
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304582 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4583 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004584 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304585 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4586 "%s: Adapter is NULL",__func__);
4587 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004588 }
4589
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304590 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4591 ret = wlan_hdd_validate_context(pHddCtx);
4592 if (0 != ret)
4593 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304594 return ret;
4595 }
4596
4597 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4598 if (NULL == pWextState)
4599 {
4600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4601 "%s: pWextState is NULL",__func__);
4602 return -EINVAL;
4603 }
4604 pRoamProfile = &pWextState->roamProfile;
4605
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 switch(pRoamProfile->negotiatedAuthType)
4607 {
4608 case eCSR_AUTH_TYPE_WPA_NONE:
4609 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4610 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
4611 break;
4612 case eCSR_AUTH_TYPE_WPA:
4613 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4614 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
4615 break;
4616#ifdef WLAN_FEATURE_VOWIFI_11R
4617 case eCSR_AUTH_TYPE_FT_RSN:
4618#endif
4619 case eCSR_AUTH_TYPE_RSN:
4620 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4621 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
4622 break;
4623 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4624 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4625 break;
4626 case eCSR_AUTH_TYPE_SHARED_KEY:
4627 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
4628 break;
4629 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004630 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4632 break;
4633 case eCSR_AUTH_TYPE_AUTOSWITCH:
4634 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4635 break;
4636 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304637 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4639 return -EIO;
4640#ifdef WLAN_FEATURE_VOWIFI_11R
4641 case eCSR_AUTH_TYPE_FT_RSN_PSK:
4642#endif
4643 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07004644#ifdef WLAN_FEATURE_11W
4645 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05304646 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07004647#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05304648 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4650 return -EIO;
4651 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304652 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4654 return -EIO;
4655 }
4656 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
4657 {
4658 switch(pRoamProfile->negotiatedUCEncryptionType)
4659 {
4660 case eCSR_ENCRYPT_TYPE_NONE:
4661 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4662 break;
4663 case eCSR_ENCRYPT_TYPE_WEP40:
4664 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4665 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4666 break;
4667 case eCSR_ENCRYPT_TYPE_TKIP:
4668 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4669 break;
4670 case eCSR_ENCRYPT_TYPE_WEP104:
4671 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4672 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4673 break;
4674 case eCSR_ENCRYPT_TYPE_AES:
4675 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4676 break;
4677 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304678 hddLog(LOG1, "%s called with unknown auth type %d ",
4679 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 return -EIO;
4681 }
4682 }
4683
Shailender Karmuchia734f332013-04-19 14:02:48 -07004684 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004685 {
4686 switch(pRoamProfile->negotiatedMCEncryptionType)
4687 {
4688 case eCSR_ENCRYPT_TYPE_NONE:
4689 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4690 break;
4691 case eCSR_ENCRYPT_TYPE_WEP40:
4692 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4693 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4694 break;
4695 case eCSR_ENCRYPT_TYPE_TKIP:
4696 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4697 break;
4698 case eCSR_ENCRYPT_TYPE_WEP104:
4699 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4700 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4701 break;
4702 case eCSR_ENCRYPT_TYPE_AES:
4703 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4704 break;
4705 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304706 hddLog(LOG1, "%s called with unknown auth type %d ",
4707 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 return -EIO;
4709 }
4710 }
4711
4712 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004713 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 EXIT();
4715 return 0;
4716}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304717
4718int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4719 union iwreq_data *wrqu,char *extra)
4720{
4721 int ret;
4722
4723 vos_ssr_protect(__func__);
4724 ret = __iw_get_auth(dev, info, wrqu, extra);
4725 vos_ssr_unprotect(__func__);
4726
4727 return ret;
4728}
4729
Jeff Johnson295189b2012-06-20 16:38:30 -07004730/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004731
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304732 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07004733 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004734 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004735
Jeff Johnson295189b2012-06-20 16:38:30 -07004736 \param - dev - Pointer to the net device.
4737 - info - Pointer to the iw_request_info.
4738 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004739 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004741
Jeff Johnson295189b2012-06-20 16:38:30 -07004742 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304743int __iw_set_ap_address(struct net_device *dev,
4744 struct iw_request_info *info,
4745 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004746{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304747 hdd_station_ctx_t *pHddStaCtx;
4748 hdd_adapter_t *pAdapter;
4749 hdd_context_t *pHddCtx;
4750 v_U8_t *pMacAddress = NULL;
4751 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304752
Jeff Johnson295189b2012-06-20 16:38:30 -07004753 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304754
4755 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4756 if (NULL == pAdapter)
4757 {
4758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4759 "%s: Adapter is NULL", __func__);
4760 return -EINVAL;
4761 }
4762 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4763 ret = wlan_hdd_validate_context(pHddCtx);
4764 if (0 != ret)
4765 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304766 return ret;
4767 }
4768 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4769 if (NULL == pHddStaCtx)
4770 {
4771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4772 "%s: pHddStaCtx is NULL", __func__);
4773 return -EINVAL;
4774 }
4775
Jeff Johnson295189b2012-06-20 16:38:30 -07004776 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4778 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004779 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07004780
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304781 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 return 0;
4783}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304784
4785int iw_set_ap_address(struct net_device *dev,
4786 struct iw_request_info *info,
4787 union iwreq_data *wrqu, char *extra)
4788{
4789 int ret;
4790
4791 vos_ssr_protect(__func__);
4792 ret = __iw_set_ap_address(dev, info, wrqu, extra);
4793 vos_ssr_unprotect(__func__);
4794
4795 return ret;
4796}
4797
Jeff Johnson295189b2012-06-20 16:38:30 -07004798/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004799
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304800 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004801 This function returns the BSSID to the wpa_supplicant
4802 \param - dev - Pointer to the net device.
4803 - info - Pointer to the iw_request_info.
4804 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004805 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004806 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004807
Jeff Johnson295189b2012-06-20 16:38:30 -07004808 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304809int __iw_get_ap_address(struct net_device *dev,
4810 struct iw_request_info *info,
4811 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004812{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304813 hdd_station_ctx_t *pHddStaCtx;
4814 hdd_adapter_t *pAdapter;
4815 hdd_context_t *pHddCtx;
4816 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304817
Jeff Johnson295189b2012-06-20 16:38:30 -07004818 ENTER();
4819
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304820 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4821 if (NULL == pAdapter)
4822 {
4823 hddLog(VOS_TRACE_LEVEL_ERROR,
4824 "%s: Adapter is NULL", __func__);
4825 return -EINVAL;
4826 }
4827 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4828 ret = wlan_hdd_validate_context(pHddCtx);
4829 if (0 != ret)
4830 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304831 return ret;
4832 }
4833 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4834 if (NULL == pHddStaCtx)
4835 {
4836 hddLog(VOS_TRACE_LEVEL_ERROR,
4837 "%s: pHddStaCtx is NULL", __func__);
4838 return -EINVAL;
4839 }
4840
Jeff Johnson295189b2012-06-20 16:38:30 -07004841 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4842 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4843 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004844 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 }
4846 else
4847 {
4848 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4849 }
4850 EXIT();
4851 return 0;
4852}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004853
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304854int iw_get_ap_address(struct net_device *dev,
4855 struct iw_request_info *info,
4856 union iwreq_data *wrqu, char *extra)
4857{
4858 int ret;
4859
4860 vos_ssr_protect(__func__);
4861 ret = __iw_get_ap_address(dev, info, wrqu, extra);
4862 vos_ssr_unprotect(__func__);
4863
4864 return ret;
4865}
4866
Chet Lanctot186b5732013-03-18 10:26:30 -07004867#ifdef WLAN_FEATURE_11W
4868/**---------------------------------------------------------------------------
4869
4870 \brief hdd_indicateUnprotMgmtFrame -
4871 This function forwards the unprotected management frame to the supplicant
4872 \param - pAdapter - Pointer to HDD adapter
4873 - nFrameLength - Length of the unprotected frame being passed
4874 - pbFrames - Pointer to the frame buffer
4875 - frameType - 802.11 frame type
4876 \return - nothing
4877
4878 --------------------------------------------------------------------------*/
4879void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4880 tANI_U32 nFrameLength,
4881 tANI_U8* pbFrames,
4882 tANI_U8 frameType )
4883{
4884 tANI_U8 type = 0;
4885 tANI_U8 subType = 0;
4886
4887 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4888 __func__, frameType, nFrameLength);
4889
4890 /* Sanity Checks */
4891 if (NULL == pAdapter)
4892 {
4893 hddLog( LOGE, FL("pAdapter is NULL"));
4894 return;
4895 }
4896
4897 if (NULL == pAdapter->dev)
4898 {
4899 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4900 return;
4901 }
4902
4903 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4904 {
4905 hddLog( LOGE, FL("pAdapter has invalid magic"));
4906 return;
4907 }
4908
4909 if( !nFrameLength )
4910 {
4911 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4912 return;
4913 }
4914
4915 if (NULL == pbFrames) {
4916 hddLog( LOGE, FL("pbFrames is NULL"));
4917 return;
4918 }
4919
4920 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4921 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4922
4923 /* Get pAdapter from Destination mac address of the frame */
4924 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
4925 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05304926#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4927 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
4928#else
Chet Lanctot186b5732013-03-18 10:26:30 -07004929 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05304930#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004931 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4932 }
4933 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
4934 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05304935#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4936 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
4937#else
Chet Lanctot186b5732013-03-18 10:26:30 -07004938 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05304939#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004940 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4941 }
4942 else
4943 {
4944 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
4945 return;
4946 }
4947}
4948#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004949
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004950#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004951void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
4952 tANI_U8 state,
4953 tANI_U16 measInterval )
4954{
4955 union iwreq_data wrqu;
4956 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004957 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004958
4959 if (NULL == pAdapter)
4960 return;
4961
4962 // create the event
4963 memset(&wrqu, '\0', sizeof(wrqu));
4964 memset(buf, '\0', sizeof(buf));
4965
4966 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
4967 tid, state, measInterval);
4968
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004969 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004970
4971 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004972 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004973 // send the event
4974 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4975}
4976
4977void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4978{
4979 union iwreq_data wrqu;
4980 char buf[IW_CUSTOM_MAX + 1];
4981 char *pos = buf;
4982 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4983
4984 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4985 return;
4986
4987 // create the event
4988 memset(&wrqu, '\0', sizeof(wrqu));
4989 memset(buf, '\0', sizeof(buf));
4990
4991 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304992 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
4993 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
4994 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
4995 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004996
4997 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4998 pos += nBytes;
4999 freeBytes -= nBytes;
5000
5001 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
5002 pos += WNI_CFG_BSSID_LEN;
5003 freeBytes -= WNI_CFG_BSSID_LEN;
5004
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005005 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
5006 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005007
5008 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005009 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005010
5011 // send the event
5012 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5013}
5014
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005015void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005016{
5017 union iwreq_data wrqu;
5018 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005019 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005020
5021 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5022 return;
5023
5024 // create the event
5025 memset(&wrqu, '\0', sizeof(wrqu));
5026 memset(buf, '\0', sizeof(buf));
5027
5028 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
5029
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005030 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005031
5032 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005033 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005034
5035 // send the event
5036 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5037}
5038
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005039void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
5040 const tANI_U16 measurementToken,
5041 const tANI_BOOLEAN flag,
5042 const tANI_U8 numBss)
5043{
5044 union iwreq_data wrqu;
5045 char buf[IW_CUSTOM_MAX];
5046 char *pos = buf;
5047 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5048
5049 memset(&wrqu, '\0', sizeof(wrqu));
5050 memset(buf, '\0', sizeof(buf));
5051
5052 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
5053 numBss);
5054
5055 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
5056 flag, numBss);
5057
5058 wrqu.data.pointer = buf;
5059 wrqu.data.length = nBytes;
5060 // send the event
5061 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5062}
5063
5064
5065static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005066 const tCsrRoamInfo *pRoamInfo)
5067{
5068 union iwreq_data wrqu;
5069 char buf[IW_CUSTOM_MAX + 1];
5070 char *pos = buf;
5071 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5072 tANI_U8 i = 0, len = 0;
5073 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
5074 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005075 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
5076 tANI_U8 ieLenByte = 1;
5077 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
5078#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005079
5080 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5081 return;
5082
5083 /* Custom event can pass maximum of 256 bytes of data,
5084 based on the IE len we need to identify how many BSS info can
5085 be filled in to custom event data */
5086 /*
5087 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
5088 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
5089 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
5090 */
5091
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005092 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005093 {
5094 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
5095 /* If the measurement is none and no scan results found,
5096 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005097 hdd_indicateEseBcnReportNoResults(pAdapter,
5098 pRoamInfo->pEseBcnReportRsp->measurementToken,
5099 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005100 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005101 }
5102 else
5103 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005104 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005105 {
5106 memset(&wrqu, '\0', sizeof(wrqu));
5107 memset(buf, '\0', sizeof(buf));
5108 tot_bcn_ieLen = 0;
5109 sendBss = 0;
5110 pos = buf;
5111 freeBytes = IW_CUSTOM_MAX;
5112
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005113 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005114 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005115 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
5116 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005117 {
5118 break;
5119 }
5120 tot_bcn_ieLen += len;
5121 sendBss++;
5122 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
5123 "IeLength(%d) Length of Ie(%d) totLen(%d)",
5124 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005125 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005126 tot_bcn_ieLen);
5127 }
5128
5129 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
5130 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005131 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5132 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005133
5134 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005135 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5136 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005137 pos += nBytes;
5138 freeBytes -= nBytes;
5139
5140 /* Copy total Beacon report data length */
5141 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
5142 pos += sizeof(tot_bcn_ieLen);
5143 freeBytes -= sizeof(tot_bcn_ieLen);
5144
5145 for (i = 0; i < sendBss; i++)
5146 {
5147 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305148 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
5149 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005150 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005151 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
5152 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
5153 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
5154 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
5155 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
5156 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
5157 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
5158 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
5159 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
5160 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
5161 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
5162 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
5163 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
5164 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
5165 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
5166 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005167
5168 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005169 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
5170 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005171 pos += len;
5172 freeBytes -= len;
5173
5174 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005175 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005176 vos_mem_copy(pos, (char*)&len, sizeof(len));
5177 pos += sizeof(len);
5178 freeBytes -= sizeof(len);
5179
5180 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005181 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005182 pos += len;
5183 freeBytes -= len;
5184 }
5185
5186 wrqu.data.pointer = buf;
5187 wrqu.data.length = strlen(buf);
5188
5189 // send the event
5190 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5191 lastSent += sendBss;
5192 }
5193 }
5194}
5195
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005196#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005197