blob: 56a9a61eaed47f71fc938d8732d43463562c2f55 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
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"
Jeff Johnson295189b2012-06-20 16:38:30 -070056#include <linux/ieee80211.h>
57#include <linux/wireless.h>
58#include <net/cfg80211.h>
59#include "wlan_hdd_cfg80211.h"
60#include "csrInsideApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070061#include "wlan_hdd_p2p.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080062#ifdef FEATURE_WLAN_TDLS
63#include "wlan_hdd_tdls.h"
64#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "sme_Api.h"
66
67v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
68
Shailender Karmuchia734f332013-04-19 14:02:48 -070069struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -070070{
71 u_char ether_addr_octet[6];
72};
73// These are needed to recognize WPA and RSN suite types
74#define HDD_WPA_OUI_SIZE 4
75v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
76v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
77v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
78v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
79v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
80v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080081#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070082v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080083#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070084#define HDD_RSN_OUI_SIZE 4
85v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
86v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
87v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
88v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
89v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
90v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080091#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070092v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080093#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -070094#ifdef WLAN_FEATURE_11W
95v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
96#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070097
Shailender Karmuchia734f332013-04-19 14:02:48 -070098#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -070099// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700100#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
101#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700102#endif
103
104#define BEACON_FRAME_IES_OFFSET 12
105
Chet Lanctot186b5732013-03-18 10:26:30 -0700106#ifdef WLAN_FEATURE_11W
107void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
108 tANI_U32 nFrameLength,
109 tANI_U8* pbFrames,
110 tANI_U8 frameType );
111#endif
112
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800113#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700114static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
115 tANI_U8 state,
116 tANI_U16 measInterval );
117static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800118static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
119static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700120
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800121#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700122
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530123static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
124 tCsrRoamInfo *pRoamInfo,
125 tANI_U32 roamId,
126 eRoamCmdStatus roamStatus,
127 eCsrRoamResult roamResult );
128
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530129v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
130 eConnectionState connState )
131{
132 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530133 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
134 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 pHddStaCtx->conn_info.connState = connState;
136}
137
138// returns FALSE if not connected.
139// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
140// returns the connection state. Can specify NULL if you dont' want to get the actual state.
141
Shailender Karmuchia734f332013-04-19 14:02:48 -0700142static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
143 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700144{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700145 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700146 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700147
Jeff Johnson295189b2012-06-20 16:38:30 -0700148 // get the connection state.
149 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700150 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700152 eConnectionState_IbssConnected == connState ||
153 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700154 {
155 fConnected = VOS_TRUE;
156 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700157 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700158 {
159 fConnected = VOS_FALSE;
160 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700161
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 if ( pConnState )
163 {
164 *pConnState = connState;
165 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700166
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 return( fConnected );
168}
169
170v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
171{
172 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700173}
Jeff Johnson295189b2012-06-20 16:38:30 -0700174
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530175eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
176{
177 v_U8_t staChannel = 0;
178
179 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
180 {
181 staChannel = pHddStaCtx->conn_info.operationChannel;
182 }
183
184 if ( staChannel > 0 && staChannel < 14 )
185 return eCSR_BAND_24;
186 else if (staChannel >= 36 && staChannel <= 165 )
187 return eCSR_BAND_5G;
188 else /* If station is not connected return as eCSR_BAND_ALL */
189 return eCSR_BAND_ALL;
190}
191
192
Jeff Johnson295189b2012-06-20 16:38:30 -0700193//TODO - Not used anyhwere. Can be removed.
194#if 0
195//
196v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
197{
198 v_BOOL_t fConnectedInfra = FALSE;
199 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700200
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700202 {
203 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700204 {
205 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700206 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700207 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700208
Jeff Johnson295189b2012-06-20 16:38:30 -0700209 return( fConnectedInfra );
210}
211#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700212
Jeff Johnson295189b2012-06-20 16:38:30 -0700213static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
214{
215 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700218
219 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700220 {
221 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
222 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700223
Jeff Johnson295189b2012-06-20 16:38:30 -0700224 return( fConnected );
225}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700226
Jeff Johnson295189b2012-06-20 16:38:30 -0700227inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
228{
229 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700230
Jeff Johnson295189b2012-06-20 16:38:30 -0700231 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700232
233 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700234 {
235 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
236 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700237
Jeff Johnson295189b2012-06-20 16:38:30 -0700238 return( fConnected );
239}
240
241static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
242{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700243 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700244 {
245 case eCSR_BSS_TYPE_INFRASTRUCTURE:
246 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
247 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700248
Jeff Johnson295189b2012-06-20 16:38:30 -0700249 case eCSR_BSS_TYPE_IBSS:
250 case eCSR_BSS_TYPE_START_IBSS:
251 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
252 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700253
254 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700256 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 default:
258 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700259 break;
260 }
261
Jeff Johnson295189b2012-06-20 16:38:30 -0700262}
263
264void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
265{
266 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
267 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700268
Jeff Johnson295189b2012-06-20 16:38:30 -0700269 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700270
271 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700273 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
275 {
276 VOS_ASSERT( pRoamInfo->pBssDesc );
277 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
278
279 // Save the Station ID for this station from the 'Roam Info'.
280 //For IBSS mode, staId is assigned in NEW_PEER_IND
281 //For reassoc, the staID doesn't change and it may be invalid in this structure
282 //so no change here.
283 if( !pRoamInfo->fReassocReq )
284 {
285 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
286 }
287 }
288 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700289 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700291 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700292 else
293 {
294 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
295 // or we can't function.
296 VOS_ASSERT( 0 );
297 }
298
299 // notify WMM
300 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
301
302 if( !pRoamInfo->u.pConnectedProfile )
303 {
304 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
305 }
306 else
307 {
308 // Get Multicast Encryption Type
309 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
310 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
311 // Get Unicast Encrytion Type
312 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
313 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
314
315 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
316
317 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
318
319 // Save the ssid for the connection
320 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530321
322 // Save dot11mode in which STA associated to AP
323 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700325 }
326
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700328 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
329
Jeff Johnson295189b2012-06-20 16:38:30 -0700330}
331
332#if defined(WLAN_FEATURE_VOWIFI_11R)
333/*
334 * Send the 11R key information to the supplicant.
335 * Only then can the supplicant generate the PMK-R1.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800336 * (BTW, the ESE supplicant also needs the Assoc Resp IEs
Jeff Johnson295189b2012-06-20 16:38:30 -0700337 * for the same purpose.)
338 *
339 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
340 * this contains the R1KHID, R0KHID and the MDID.
341 * For FT, this consists of the Reassoc Rsp FTIEs.
342 * This is the Assoc Response.
343 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700344static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 tCsrRoamInfo *pCsrRoamInfo)
346{
347 union iwreq_data wrqu;
348 char *buff;
349 unsigned int len = 0;
350 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700351
352 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700353 {
354 hddLog(LOGE,
355 "%s: pCsrRoamInfo->nAssocRspLength=%d",
356 __func__, (int)pCsrRoamInfo->nAssocRspLength);
357 return;
358 }
359
Shailender Karmuchia734f332013-04-19 14:02:48 -0700360 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700362 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700363 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700364 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 return;
366 }
367
368 // pFTAssocRsp needs to point to the IEs
369 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
370 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
371 (unsigned int)pFTAssocRsp[0],
372 (unsigned int)pFTAssocRsp[1]);
373
374 // We need to send the IEs to the supplicant.
375 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700376 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700377 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700378 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700379 return;
380 }
381
382 // Send the Assoc Resp, the supplicant needs this for initial Auth.
383 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700384 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700385 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700386 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
388
389 kfree(buff);
390}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700391#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700392
393#ifdef WLAN_FEATURE_VOWIFI_11R
394
395/*---------------------------------------------------
396 *
397 * Send the FTIEs, RIC IEs during FT. This is eventually
398 * used to send the FT events to the supplicant
399 *
400 * At the reception of Auth2 we send the RIC followed
401 * by the auth response IEs to the supplicant.
402 * Once both are received in the supplicant, an FT
403 * event is generated to the supplicant.
404 *
405 *---------------------------------------------------
406 */
407void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
408{
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 tANI_U16 auth_resp_len = 0;
410 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700411 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
412
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530413#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700414 struct cfg80211_ft_event_params ftEvent;
415 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
416 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
417 struct net_device *dev = pAdapter->dev;
418#else
419 char *buff;
420 union iwreq_data wrqu;
421 tANI_U16 str_len;
422#endif
423
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530424#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530425 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
426 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700427
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530428 sme_GetRICIEs( pHddCtx->hHal, (u8 *)ricIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800429 DOT11F_IE_FTINFO_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530430 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700431 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530432 hddLog(LOGW,
433 "%s: RIC IEs is of length 0 not sending RIC Information for now",
434 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700435 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700436
437 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530438 ftEvent.ric_ies_len = ric_ies_length;
439 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700440
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530441 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800442 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700443
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530444 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700445 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530446 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700447 return;
448 }
449
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530450 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530451
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530452 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700453
454 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
455 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
456
Jeff Johnson59a121e2013-11-30 09:46:08 -0800457 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
458 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
459 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530460 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800461 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
462 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
463 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700464
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530465 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700466
467#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530468 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530470 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530472 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 return;
474 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530475 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700476
Shailender Karmuchia734f332013-04-19 14:02:48 -0700477 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530479 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800480 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530481 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530483 hddLog(LOGW,
484 "%s: RIC IEs is of length 0 not sending RIC Information for now",
485 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 }
487 else
488 {
489 wrqu.data.length = str_len + ric_ies_length;
490 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
491 }
492
493 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530494 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700495 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530496 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
497 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700498
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530499 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700500 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530501 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 return;
503 }
504
505 wrqu.data.length = str_len + auth_resp_len;
506 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
507
508 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700509#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700510}
511
512#endif /* WLAN_FEATURE_VOWIFI_11R */
513
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800514#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700515
516/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800517 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 * (This keeps the supplicant "up to date" on the current channel.)
519 *
520 * The current (new AP) channel information is passed in.
521 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700522static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 tCsrRoamInfo *pCsrRoamInfo)
524{
525 union iwreq_data wrqu;
526 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700527
Shailender Karmuchia734f332013-04-19 14:02:48 -0700528
529 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700530 {
531 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800532 "%s: pCsrRoamInfo->pBssDesc=%p",
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 __func__, descriptor);
534 return;
535 }
536
537 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -0800538 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 memset(&wrqu, '\0', sizeof(wrqu));
540 wrqu.freq.m = descriptor->channelId;
541 wrqu.freq.e = 0;
542 wrqu.freq.i = 0;
543 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
544}
545
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800546#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700547
548void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
549{
550 union iwreq_data wrqu;
551 u8 *pBeaconIes;
552 u8 currentLen = 0;
553 char *buff;
554 int totalIeLen = 0, currentOffset = 0, strLen;
555
556 memset(&wrqu, '\0', sizeof(wrqu));
557
558 if (0 == pCsrRoamInfo->nBeaconLength)
559 {
560 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
561 return;
562 }
563 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700564 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700565 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700566 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700567 return;
568 }
569
570 // pBeaconIes needs to point to the IEs
571 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
572 (unsigned int)pBeaconIes[0],
573 (unsigned int)pBeaconIes[1]);
574 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700575
Jeff Johnson295189b2012-06-20 16:38:30 -0700576 // We need to send the IEs to the supplicant.
577 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700578 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700579 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700580 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700581 return;
582 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700583 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700584
585 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
586 currentLen = strLen + 1;
587
588 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
589 do
590 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700591 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700592 * max size and send it to supplicant. Changes are done in supplicant to handle this */
593 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
594 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
595 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
596 currentOffset += currentLen;
597 totalIeLen -= currentLen;
598 wrqu.data.length = strLen + 1 + currentLen;
599 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700600 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 else
602 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
603
604 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
605 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
606 } while (totalIeLen > 0);
607
608 kfree(buff);
609}
610
611static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
612{
613 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
614 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
615 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
616 union iwreq_data wrqu;
617 int we_event;
618 char *msg;
619 int type = -1;
620
Shailender Karmuchia734f332013-04-19 14:02:48 -0700621#if defined (WLAN_FEATURE_VOWIFI_11R)
622 // Added to find the auth type on the fly at run time
623 // rather than with cfg to see if FT is enabled
624 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
626#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700627
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700629 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700631
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
633 {
634 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
635 type = WLAN_STA_ASSOC_DONE_IND;
636
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700637#ifdef WLAN_FEATURE_P2P_DEBUG
638 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
639 {
640 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
641 {
642 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
643 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
644 "Connecting state to Connected State for 8-way "
645 "Handshake");
646 }
647 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
648 {
649 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
650 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
651 "Connecting state to P2P Client Connection Completed");
652 }
653 }
654#endif
Arif Hussain77d044f2014-01-03 19:56:04 -0800655 pr_info("wlan: " MAC_ADDRESS_STR " connected to " MAC_ADDRESS_STR "\n",
656 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
Kiet Lam34947452014-01-21 23:23:40 -0800657 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
659
660 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
661 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
662 * and fFTEnable is TRUE */
663#ifdef WLAN_FEATURE_VOWIFI_11R
664 // Send FT Keys to the supplicant when FT is enabled
665 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700666 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800667#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
669 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
670#endif
671 )
672 {
673 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
674 }
675#endif
676 }
677 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
678 {
Jeff Johnson4416a782013-03-25 14:17:50 -0700679 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 type = WLAN_STA_ASSOC_DONE_IND;
Arif Hussain24bafea2013-11-15 15:10:03 -0800681 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR"\n",
682 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 }
684 else /* Not Associated */
685 {
686 pr_info("wlan: disconnected\n");
687 type = WLAN_STA_DISASSOC_DONE_IND;
688 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
689 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700690 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700691
692 msg = NULL;
693 /*During the WLAN uninitialization,supplicant is stopped before the
694 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530695 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 {
697 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800698#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700700 {
701 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
702 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
704 }
705#endif
706 }
707 send_btc_nlink_msg(type, 0);
708}
709
710void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
711{
712 // Remove staId, bssId and peerMacAddress
713 pHddStaCtx->conn_info.staId [ 0 ] = 0;
714 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
715 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
716
717 // Clear all security settings
718 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
719 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
720 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
721
722 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700723 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700724
725 // Set not-connected state
726 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700727
728 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
729}
730/* TODO Revist this function. and data path */
731static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
732{
733 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700734 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
735
736 if (WLAN_HDD_IBSS != pAdapter->device_mode)
737 {
738 hdd_disconnect_tx_rx(pAdapter);
739 }
740 else
741 {
742 // Need to cleanup all queues only if the last peer leaves
743 if (eConnectionState_IbssDisconnected == pHddStaCtx->conn_info.connState)
744 {
745 netif_tx_disable(pAdapter->dev);
746 netif_carrier_off(pAdapter->dev);
747 hdd_disconnect_tx_rx(pAdapter);
748 }
749 else
750 {
751 // There is atleast one more peer, do not cleanup all queues
752 hdd_flush_ibss_tx_queues(pAdapter, staId);
753 }
754 }
755
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
757 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
758 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530759 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700760 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700761 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700762 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 }
764 return( vosStatus );
765}
766
767
768static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
769 tANI_U32 roamId, eRoamCmdStatus roamStatus,
770 eCsrRoamResult roamResult )
771{
772 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700773 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 struct net_device *dev = pAdapter->dev;
775 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
776 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700777 v_U8_t sta_id;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700778
779 // Sanity check
780 if(dev == NULL)
781 {
Agarwal Ashish971c2882013-10-30 20:11:12 +0530782 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700783 "%s: net_dev is released return", __func__);
784 return eHAL_STATUS_FAILURE;
785 }
786
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 // notify apps that we can't pass traffic anymore
788 netif_tx_disable(dev);
789 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700790
Jeff Johnsone7245742012-09-05 17:12:55 -0700791 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singhf4669da2014-05-26 15:07:49 +0530792 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
793 "%s: Set HDD connState to eConnectionState_Disconnecting",
794 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -0700795 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 /* If only STA mode is on */
797 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
798 {
799 pHddCtx->isAmpAllowed = VOS_TRUE;
800 }
801 hdd_clearRoamProfileIe( pAdapter );
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -0700802 if(pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
803 {
804 hdd_wmm_init( pHddCtx, hddWmmDscpToUpMapInfra );
805 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700806
807 // indicate 'disconnect' status to wpa_supplicant...
808 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 /* indicate disconnected event to nl80211 */
810 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
811 {
812 /*During the WLAN uninitialization,supplicant is stopped before the
813 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530814 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700815 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700816 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
817 "%s: sent disconnected event to nl80211",
Jeff Johnson295189b2012-06-20 16:38:30 -0700818 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700819#ifdef WLAN_FEATURE_P2P_DEBUG
820 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
821 {
822 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
823 {
824 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
825 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
826 "and moved to disconnected state");
827 }
828 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
829 {
830 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
831 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
832 "and moved to inactive state");
833 }
834 }
835#endif
836
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
838 if( eCSR_ROAM_LOSTLINK == roamStatus )
839 {
Mohit Khanna99d5fd02012-09-11 14:51:20 -0700840 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 }
842 else
843 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700844 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 }
846
847 //If the Device Mode is Station
848 // and the P2P Client is Connected
849 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700850
851 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -0700852 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -0700853 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 {
855 //Enable BMPS only of other Session is P2P Client
856 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700857 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -0700858
859 if (NULL != pVosContext)
860 {
861 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
862
863 if(NULL != pHddCtx)
864 {
865 //Only P2P Client is there Enable Bmps back
866 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700867 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530869 if (pHddCtx->hdd_wlan_suspended)
870 {
871 hdd_set_pwrparams(pHddCtx);
872 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530874 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 }
876 }
877 }
878 }
879 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700880
krunal soni3fc26642013-10-08 22:41:42 -0700881 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
882 {
883 sta_id = IBSS_BROADCAST_STAID;
884 }
885 else
886 {
887 sta_id = pHddStaCtx->conn_info.staId[0];
888 }
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +0530889 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +0530890#if defined(WLAN_FEATURE_VOWIFI_11R)
891 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
892#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 //We should clear all sta register with TL, for now, only one.
krunal soni3fc26642013-10-08 22:41:42 -0700894 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
Jeff Johnson43971f52012-07-17 12:26:56 -0700895 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 "hdd_roamDeregisterSTA() failed to for staID %d. "
899 "Status= %d [0x%x]",
krunal soni3fc26642013-10-08 22:41:42 -0700900 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700901
902 status = eHAL_STATUS_FAILURE;
903 }
904
krunal soni3fc26642013-10-08 22:41:42 -0700905 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700906 // Clear saved connection information in HDD
907 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +0530908 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
909 "%s: Set HDD connState to eConnectionState_NotConnected",
910 __func__);
911 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530912#ifdef WLAN_FEATURE_GTK_OFFLOAD
913 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
914 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
915 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +0530916 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
917 sizeof (tSirGtkOffloadParams));
918 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530919 }
920#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700921
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800922#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -0700923 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
924 {
925 wlan_hdd_tdls_disconnection_callback(pAdapter);
926 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800927#endif
928
Jeff Johnson295189b2012-06-20 16:38:30 -0700929 //Unblock anyone waiting for disconnect to complete
930 complete(&pAdapter->disconnect_comp_var);
931 return( status );
932}
933static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
934 tCsrRoamInfo *pRoamInfo,
935 v_U8_t staId,
936 v_MACADDR_t *pPeerMacAddress,
937 tSirBssDescription *pBssDesc )
938{
939 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
940 WLAN_STADescType staDesc = {0};
941 eCsrEncryptionType connectedCipherAlgo;
942 v_BOOL_t fConnected;
943 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
944 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -0700945 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700946
947 if ( NULL == pBssDesc)
948 {
949 return VOS_STATUS_E_FAILURE;
950 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 // Get the Station ID from the one saved during the assocation.
952 staDesc.ucSTAId = staId;
953
954 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700956 staDesc.wSTAType = WLAN_STA_INFRA;
957
958 // grab the bssid from the connection info in the adapter structure and hand that
959 // over to TL when registering.
960 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
961 }
962 else
963 {
964 // for an IBSS 'connect', setup the Station Descriptor for TL.
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 staDesc.wSTAType = WLAN_STA_IBSS;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700966
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
968 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
969 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
970 // pass when making an Infrastructure connection.
971 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
972 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
973 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700974
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
976
977 // set the QoS field appropriately
978 if (hdd_wmm_is_active(pAdapter))
979 {
980 staDesc.ucQosEnabled = 1;
981 }
982 else
983 {
984 staDesc.ucQosEnabled = 0;
985 }
986
987 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
988 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
989 {
990 staDesc.ucProtectedFrame = 1;
991 }
992 else
993 {
994 staDesc.ucProtectedFrame = 0;
995
996 }
997
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800998#ifdef FEATURE_WLAN_ESE
999 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1000#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001001
1002#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1003 /* check whether replay check is valid for the station or not */
1004 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1005 {
1006 /* Encryption mode is either TKIP or AES
1007 and replay check is valid for only these
1008 two encryption modes */
1009 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1010 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1011 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1012 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001013
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 else
1015 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001016 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001018 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1020 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1021 }
1022#endif
1023
1024#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001025 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001026 if (pAdapter->wapi_info.fIsWapiSta)
1027 {
1028 staDesc.ucIsWapiSta = 1;
1029 }
1030 else
1031 {
1032 staDesc.ucIsWapiSta = 0;
1033 }
1034#endif /* FEATURE_WLAN_WAPI */
1035
1036 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1037 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1038
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 // UMA is Not ready yet, Xlation will be done by TL
1040 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 staDesc.ucSwFrameRXXlation = 1;
1042 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001043 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 staDesc.ucQosEnabled );
1045 // Initialize signatures and state
1046 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1047 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1048 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1049 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001050 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001051 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 -07001052 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1053 hdd_rx_packet_cbk,
1054 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001055 hdd_tx_fetch_packet_cbk, &staDesc,
1056 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001057
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1059 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001060 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001061 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001063 return vosStatus;
1064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001065
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001066 if ( cfg_param->dynSplitscan &&
1067 ( VOS_TIMER_STATE_RUNNING !=
1068 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1069 {
1070 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1071 cfg_param->trafficMntrTmrForSplitScan);
1072 }
1073
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301074 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1075 // then go to 'authenticated'. For all other authentication types
1076 // (those that donot require upper layer authentication) we can put
1077 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001078 if (staDesc.wSTAType != WLAN_STA_IBSS)
1079 VOS_ASSERT( fConnected );
1080
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301081 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001082 {
1083 // Connections that do not need Upper layer auth, transition TL directly
1084 // to 'Authenticated' state.
1085 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1086 WLANTL_STA_AUTHENTICATED );
1087
1088 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1089 }
1090 else
1091 {
1092 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301093 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1094 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001095 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301096 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001097 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001099 return( vosStatus );
1100}
1101
Jeff Johnson295189b2012-06-20 16:38:30 -07001102static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1103 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1104{
1105 unsigned int len = 0;
1106 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001107 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 tANI_U32 rspRsnLength = 0;
1109 struct ieee80211_channel *chan;
1110
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001111 if (!rspRsnIe)
1112 {
1113 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001114 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001115 }
1116
Jeff Johnson295189b2012-06-20 16:38:30 -07001117 if (pCsrRoamInfo == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001118 {
1119 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1120 goto done;
1121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001122
1123 if (pCsrRoamInfo->nAssocRspLength == 0)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001124 {
1125 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1126 goto done;
1127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001128
1129 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1130 pCsrRoamInfo->nAssocReqLength);
1131 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001132 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001133
1134 //pFTAssocRsp needs to point to the IEs
1135 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001136 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001137 (unsigned int)pFTAssocRsp[0],
1138 (unsigned int)pFTAssocRsp[1]);
1139
1140 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001141 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001142 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001143 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001144 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001145
1146 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1147 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1148 reqRsnIe, reqRsnLength,
1149 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001150
1151done:
1152 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001153}
Jeff Johnson295189b2012-06-20 16:38:30 -07001154
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301155void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1156{
1157 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1158 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1159 tCsrRoamInfo roamInfo;
1160 roamInfo.fAuthRequired = FALSE;
1161 vos_mem_copy(roamInfo.bssid,
1162 pHddStaCtx->roam_info.bssid,
1163 WNI_CFG_BSSID_LEN);
1164 vos_mem_copy(roamInfo.peerMac,
1165 pHddStaCtx->roam_info.peerMac,
1166 WNI_CFG_BSSID_LEN);
1167
1168 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1169 &roamInfo,
1170 pHddStaCtx->roam_info.roamId,
1171 pHddStaCtx->roam_info.roamStatus,
1172 eCSR_ROAM_RESULT_AUTHENTICATED);
1173 if (halStatus != eHAL_STATUS_SUCCESS)
1174 {
1175 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1176 }
1177 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1178}
1179
Shailender Karmuchia734f332013-04-19 14:02:48 -07001180static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1181 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 eCsrRoamResult roamResult )
1183{
1184 struct net_device *dev = pAdapter->dev;
1185 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1186 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1187 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001188 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1189 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001190#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001191 int ft_carrier_on = FALSE;
1192#endif
1193 int status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001194
Jeff Johnson295189b2012-06-20 16:38:30 -07001195 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1196 {
Abhishek Singhf4669da2014-05-26 15:07:49 +05301197 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1198 "%s: Set HDD connState to eConnectionState_Associated",
1199 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1201
c_hpothu44ff4e02014-05-08 00:13:57 +05301202 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 // Save the connection info from CSR...
1204 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1205#ifdef FEATURE_WLAN_WAPI
1206 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1207 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1208 {
1209 pAdapter->wapi_info.fIsWapiSta = 1;
1210 }
1211 else
1212 {
1213 pAdapter->wapi_info.fIsWapiSta = 0;
1214 }
1215#endif /* FEATURE_WLAN_WAPI */
1216
1217 // indicate 'connect' status to userspace
1218 hdd_SendAssociationEvent(dev,pRoamInfo);
1219
1220
Shailender Karmuchia734f332013-04-19 14:02:48 -07001221 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 INIT_COMPLETION(pAdapter->linkup_event_var);
1223
1224 /*
1225 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1226 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 -07001227 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 know that the device is getting activated properly.
1229 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001230#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 if (pHddStaCtx->ft_carrier_on == FALSE)
1232 {
1233#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001234 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 pAdapter->isLinkUpSvcNeeded = TRUE;
1236
Shailender Karmuchia734f332013-04-19 14:02:48 -07001237 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001238 pAdapter->isLinkUpSvcNeeded = TRUE;
1239
1240 // Switch on the Carrier to activate the device
1241 netif_carrier_on(dev);
1242
1243 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1244 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1245 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001246 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001247 {
1248 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1249 }
1250
1251 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1252 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001253#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001255 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001257 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001258 }
1259#endif
1260 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1261
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001262#ifdef FEATURE_WLAN_TDLS
1263 wlan_hdd_tdls_connection_callback(pAdapter);
1264#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 //For reassoc, the station is already registered, all we need is to change the state
1266 //of the STA in TL.
1267 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
1268 if( !pRoamInfo->fReassocReq )
1269 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001270 struct cfg80211_bss *bss;
1271#ifdef WLAN_FEATURE_VOWIFI_11R
1272 u8 *pFTAssocRsp = NULL;
1273 unsigned int assocRsplen = 0;
1274 u8 *pFTAssocReq = NULL;
1275 unsigned int assocReqlen = 0;
1276 struct ieee80211_channel *chan;
1277#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001278 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001279 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001280
1281 /* add bss_id to cfg80211 data base */
1282 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1283 if (NULL == bss)
1284 {
1285 pr_err("wlan: Not able to create BSS entry\n");
1286 return eHAL_STATUS_FAILURE;
1287 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001288#ifdef WLAN_FEATURE_VOWIFI_11R
1289 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001290 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001291 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001292
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001293 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001294 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001295 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001296 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001297 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001298 // pFTAssocRsp needs to point to the IEs
1299 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1300 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1301 (unsigned int)pFTAssocRsp[0],
1302 (unsigned int)pFTAssocRsp[1]);
1303 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001304 }
1305 else
1306 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001307 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1308 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001309 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001310
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001311 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001312 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001313 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001314 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001315 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001316 if(!ft_carrier_on)
1317 {
1318 // pFTAssocReq needs to point to the IEs
1319 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1320 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1321 (unsigned int)pFTAssocReq[0],
1322 (unsigned int)pFTAssocReq[1]);
1323 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1324 }
1325 else
1326 {
1327 /* This should contain only the FTIEs */
1328 assocReqlen = pRoamInfo->nAssocReqLength;
1329 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001330 }
1331 else
1332 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001333 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1334 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001335 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001336
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001337 if(ft_carrier_on)
1338 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001339 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001340 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001341 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1342 (int)pRoamInfo->pBssDesc->channelId);
Arif Hussain6d2a3322013-11-17 19:50:10 -08001343 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001344 assocRsplen);
1345 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
1346 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1347 GFP_KERNEL);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301348 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1349 {
1350 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1351 pRoamInfo->fAuthRequired = FALSE;
1352
1353 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1354 pRoamInfo->bssid,
1355 HDD_MAC_ADDR_LEN);
1356 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1357 pRoamInfo->peerMac,
1358 HDD_MAC_ADDR_LEN);
1359 pHddStaCtx->roam_info.roamId = roamId;
1360 pHddStaCtx->roam_info.roamStatus = roamStatus;
1361 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1362 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001363 }
1364 else
1365 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001366 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001367 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001368 cfg80211_connect_result(dev, pRoamInfo->bssid,
1369 pFTAssocReq, assocReqlen,
1370 pFTAssocRsp, assocRsplen,
1371 WLAN_STATUS_SUCCESS,
1372 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001373 }
1374 }
1375 else
1376#endif
1377 {
1378 /* wpa supplicant expecting WPA/RSN IE in connect result */
1379 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1380 pAdapter->sessionId,
1381 &reqRsnLength,
1382 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001383
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001384 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1385 pAdapter->sessionId,
1386 &rspRsnLength,
1387 rspRsnIe);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001388#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001389 if(ft_carrier_on)
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001390 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001391 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001392#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001393
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001394 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301395 hddLog(VOS_TRACE_LEVEL_INFO,
1396 "%s: sending connect indication to nl80211:"
1397 " for bssid " MAC_ADDRESS_STR
1398 " reason:%d and Status:%d\n",
1399 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1400 roamResult, roamStatus);
1401
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001402 /* inform connect result to nl80211 */
1403 cfg80211_connect_result(dev, pRoamInfo->bssid,
1404 reqRsnIe, reqRsnLength,
1405 rspRsnIe, rspRsnLength,
1406 WLAN_STATUS_SUCCESS,
1407 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001408 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 }
Yue Maf49ba872013-08-19 12:04:25 -07001410 cfg80211_put_bss(
1411#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1412 pHddCtx->wiphy,
1413#endif
1414 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 // Register the Station with TL after associated...
1416 vosStatus = hdd_roamRegisterSTA( pAdapter,
1417 pRoamInfo,
1418 pHddStaCtx->conn_info.staId[ 0 ],
1419 NULL,
1420 pRoamInfo->pBssDesc );
1421 }
1422 else
1423 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001424 /* wpa supplicant expecting WPA/RSN IE in connect result */
1425 /* in case of reassociation also need to indicate it to supplicant */
1426 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1427 pAdapter->sessionId,
1428 &reqRsnLength,
1429 reqRsnIe);
1430
1431 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301433 if( pRoamInfo->fAuthRequired )
1434 {
1435 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1436 pHddStaCtx->conn_info.staId[ 0 ],
1437 WLANTL_STA_CONNECTED );
1438 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1439 }
1440 else
1441 {
1442 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1443 "%s: staId: %d Changing TL state to AUTHENTICATED",
1444 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1445 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1446 pHddStaCtx->conn_info.staId[ 0 ],
1447 WLANTL_STA_AUTHENTICATED );
1448 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1449 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 }
1451
1452 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1453 {
1454 // perform any WMM-related association processing
1455 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1456 }
1457 else
1458 {
1459 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001460 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 vosStatus, vosStatus );
1462 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001463#ifdef WLAN_FEATURE_11W
1464 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1465 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1466#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001467 // Start the Queue
1468 netif_tx_wake_all_queues(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001469 }
1470 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1473
1474 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001475 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001476 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1477 " reason:%d and Status:%d\n",
1478 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1479 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001480 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001481 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1482 " reason:%d and Status:%d\n",
1483 MAC_ADDR_ARRAY(pWextState->req_bssId),
1484 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001485
Abhishek Singhf4669da2014-05-26 15:07:49 +05301486 /* Set connection state to eConnectionState_NotConnected only when CSR
1487 * has completed operation - with a ASSOCIATION_FAILURE status
1488 */
1489 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus )
1490 {
1491 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1492 "%s: Set HDD connState to eConnectionState_NotConnected",
1493 __func__);
1494 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
1497 {
1498 pHddCtx->isAmpAllowed = VOS_TRUE;
1499 }
1500
1501 //If the Device Mode is Station
1502 // and the P2P Client is Connected
1503 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001504
1505 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001506 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001507 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1508 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001509 (vos_concurrent_sessions_running()))
1510 {
1511 //Enable BMPS only of other Session is P2P Client
1512 hdd_context_t *pHddCtx = NULL;
1513 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1514
1515 if (NULL != pVosContext)
1516 {
1517 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1518
1519 if(NULL != pHddCtx)
1520 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301521 //Only P2P Client is there Enable Bmps back
1522 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
1523 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
1524 {
1525 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001526 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301527 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001528 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301529 hdd_enable_bmps_imps(pHddCtx);
1530 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001531 }
1532 }
1533 }
1534
James Zmudafbf5ffc2013-03-25 12:45:35 -07001535 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001536 * completed operation - with a ASSOCIATION_FAILURE status.*/
1537 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus )
Jeff Johnsone7245742012-09-05 17:12:55 -07001538 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301539 if (pRoamInfo)
1540 hddLog(VOS_TRACE_LEVEL_ERROR,
1541 "%s: send connect failure to nl80211:"
1542 " for bssid " MAC_ADDRESS_STR
1543 " reason:%d and Status:%d\n" ,
1544 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1545 roamResult, roamStatus);
1546 else
1547 hddLog(VOS_TRACE_LEVEL_ERROR,
1548 "%s: connect failed:"
1549 " for bssid " MAC_ADDRESS_STR
1550 " reason:%d and Status:%d\n" ,
1551 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1552 roamResult, roamStatus);
1553
James Zmudafbf5ffc2013-03-25 12:45:35 -07001554 /* inform association failure event to nl80211 */
1555 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1556 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001557 if (pRoamInfo)
1558 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1559 NULL, 0, NULL, 0,
1560 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1561 GFP_KERNEL );
1562 else
1563 cfg80211_connect_result ( dev, pWextState->req_bssId,
1564 NULL, 0, NULL, 0,
1565 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1566 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001567 }
1568 else
1569 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001570 if (pRoamInfo)
1571 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1572 NULL, 0, NULL, 0,
1573 WLAN_STATUS_UNSPECIFIED_FAILURE,
1574 GFP_KERNEL );
1575 else
1576 cfg80211_connect_result ( dev, pWextState->req_bssId,
1577 NULL, 0, NULL, 0,
1578 WLAN_STATUS_UNSPECIFIED_FAILURE,
1579 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001580 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001582
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001583 /*Clear the roam profile*/
1584 hdd_clearRoamProfileIe( pAdapter );
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -07001585 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
1586 {
1587 hdd_wmm_init( pHddCtx, hddWmmDscpToUpMapInfra );
1588 }
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001589
c_hpothu24f40982014-04-18 18:00:36 +05301590 if (pRoamInfo)
1591 {
1592 WLANTL_AssocFailed(pRoamInfo->staId);
1593 }
Mihir Sheteb7337272014-04-11 15:53:08 +05301594
Jeff Johnson295189b2012-06-20 16:38:30 -07001595 netif_tx_disable(dev);
1596 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001597
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 }
1599
1600 return eHAL_STATUS_SUCCESS;
1601}
1602
1603/**============================================================================
1604 *
Jeff Johnson81c17882013-05-03 09:53:35 -07001605 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07001606 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07001607
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07001609static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
1610 tCsrRoamInfo *pRoamInfo,
1611 tANI_U32 roamId,
1612 eRoamCmdStatus roamStatus,
1613 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07001614{
Jeff Johnson81c17882013-05-03 09:53:35 -07001615 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
1616 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
1617
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 switch( roamResult )
1619 {
1620 // both IBSS Started and IBSS Join should come in here.
1621 case eCSR_ROAM_RESULT_IBSS_STARTED:
1622 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001623 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001625 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1626 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001627
Jeff Johnson81c17882013-05-03 09:53:35 -07001628 if (NULL == pRoamInfo)
1629 {
1630 VOS_ASSERT(0);
1631 return;
1632 }
1633
1634 /* When IBSS Started comes from CSR, we need to move
1635 * connection state to IBSS Disconnected (meaning no peers
1636 * are in the IBSS).
1637 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05301638 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1639 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
1640 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07001641 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
1642 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05301643 /*notify wmm */
1644 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001645 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1646 hdd_roamRegisterSTA (pAdapter, pRoamInfo,
1647 IBSS_BROADCAST_STAID,
1648 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001649
Jeff Johnson81c17882013-05-03 09:53:35 -07001650 if (pRoamInfo->pBssDesc)
1651 {
1652 struct cfg80211_bss *bss;
1653
1654 /* we created the IBSS, notify supplicant */
1655 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
1656 MAC_ADDRESS_STR,
1657 __func__, pAdapter->dev->name,
1658 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
1659
1660 /* we must first give cfg80211 the BSS information */
1661 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1662 if (NULL == bss)
1663 {
1664 hddLog(VOS_TRACE_LEVEL_ERROR,
1665 "%s: %s: unable to create IBSS entry",
1666 __func__, pAdapter->dev->name);
1667 return;
1668 }
1669
1670 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001671 cfg80211_put_bss(
1672#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1673 pHddCtx->wiphy,
1674#endif
1675 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07001676 }
1677
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 break;
1679 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001680
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1682 {
Jeff Johnson81c17882013-05-03 09:53:35 -07001683 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
1684 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 break;
1686 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001687
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07001689 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
1690 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001692 }
1693
Jeff Johnson81c17882013-05-03 09:53:35 -07001694 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001695}
1696
1697/**============================================================================
1698 *
1699 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1700 This information is passed to iwconfig later. The peer that joined
1701 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001702 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001703 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001704
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 ===========================================================================*/
1706static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1707{
1708 int fSuccess = FALSE;
1709 int idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001710
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1712 {
1713 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1714 {
1715 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001716
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001718
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 fSuccess = TRUE;
1720 break;
1721 }
1722 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001723
1724 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07001725}
1726/**============================================================================
1727 *
1728 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001729 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001730 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001731
Jeff Johnson295189b2012-06-20 16:38:30 -07001732 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07001733static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07001734{
1735 int fSuccess = FALSE;
1736 int idx = 0;
1737 v_U8_t valid_idx = 0;
1738 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07001739 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001740 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001741
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1743 {
1744 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1745 {
1746 pHddStaCtx->conn_info.staId[ idx ] = 0;
1747
1748 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1749
1750 fSuccess = TRUE;
Ravi Joshi8a934352013-09-25 16:46:58 -07001751
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 // Note the deleted Index, if its 0 we need special handling
1753 del_idx = idx;
Ravi Joshi8a934352013-09-25 16:46:58 -07001754
1755 empty_slots++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 }
1757 else
1758 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001759 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 {
1761 valid_idx = idx;
1762 }
Ravi Joshi8a934352013-09-25 16:46:58 -07001763 else
1764 {
1765 // Found an empty slot
1766 empty_slots++;
1767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 }
1769 }
1770
Ravi Joshi8a934352013-09-25 16:46:58 -07001771 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
1772 {
1773 // Last peer departed, set the IBSS state appropriately
1774 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001775 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07001776 "Last IBSS Peer Departed!!!" );
1777 }
1778
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 // Find next active staId, to have a valid sta trigger for TL.
1780 if (fSuccess == TRUE)
1781 {
1782 if (del_idx == 0)
1783 {
1784 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1785 {
1786 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1787 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1788 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1789
1790 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1791 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1792 }
1793 }
1794 }
1795 return( fSuccess );
1796}
1797
1798/**============================================================================
1799 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001800 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07001801 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001802
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 ===========================================================================*/
1804static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1805{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001806 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05301807 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1808 "%s: IBSS Connect Indication from SME!!! "
1809 "Set HDD connState to eConnectionState_IbssConnected",
1810 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1812 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1813
1814 // Save the connection info from CSR...
1815 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1816
1817 // Send the bssid address to the wext.
1818 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001820 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1821 if (NULL == bss)
1822 {
1823 hddLog(VOS_TRACE_LEVEL_ERROR,
1824 "%s: %s: unable to create IBSS entry",
1825 __func__, pAdapter->dev->name);
1826 return eHAL_STATUS_FAILURE;
1827 }
Yue Maf49ba872013-08-19 12:04:25 -07001828 cfg80211_put_bss(
1829#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1830 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
1831#endif
1832 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001833
1834 return( eHAL_STATUS_SUCCESS );
1835}
1836/**============================================================================
1837 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05301838 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
1839 suspend related data which was cleared during roaming in FWR.
1840
1841 ===========================================================================*/
1842static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
1843{
1844 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
1845 hdd_adapter_t *pAdapter;
1846 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
1847 ENTER();
1848
1849 spin_lock(&pHddCtx->filter_lock);
1850 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
1851 {
1852 pHddCtx->sus_res_mcastbcast_filter =
1853 pHddCtx->configuredMcastBcastFilter;
1854 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
1855 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
1856 hddLog(VOS_TRACE_LEVEL_INFO,
1857 FL("saving configuredMcastBcastFilter = %d"),
1858 pHddCtx->configuredMcastBcastFilter);
1859 hddLog(VOS_TRACE_LEVEL_INFO,
1860 FL("offload: calling hdd_conf_mcastbcast_filter"));
1861 }
1862 spin_unlock(&pHddCtx->filter_lock);
1863
1864 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
1865 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
1866 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
1867
1868 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
1869 //No need to configure GTK Offload from here because it might possible
1870 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
1871 //be handled as part of cfg80211_set_rekey_data processing.
1872 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
1873 {
1874 pAdapter = pAdapterNode->pAdapter;
1875 if( pAdapter &&
1876 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1877 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
1878 {
1879 if (pHddCtx->cfg_ini->fhostArpOffload)
1880 {
1881 //Configure ARPOFFLOAD
1882 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
1883 if (!VOS_IS_STATUS_SUCCESS(vstatus))
1884 {
1885 hddLog(VOS_TRACE_LEVEL_ERROR,
1886 FL("Failed to disable ARPOffload Feature %d"), vstatus);
1887 }
1888 }
1889#ifdef WLAN_NS_OFFLOAD
1890 //Configure NSOFFLOAD
1891 if (pHddCtx->cfg_ini->fhostNSOffload)
1892 {
1893 hdd_conf_ns_offload(pAdapter, TRUE);
1894 }
1895#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05301896#ifdef WLAN_FEATURE_PACKET_FILTERING
1897 /* During suspend, configure MC Addr list filter to the firmware
1898 * function takes care of checking necessary conditions before
1899 * configuring.
1900 */
1901 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
1902#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05301903 }
1904 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
1905 pAdapterNode = pNext;
1906 }
1907 EXIT();
1908}
1909
1910/**============================================================================
1911 *
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001913
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001915static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1916 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001917 eCsrRoamResult roamResult )
1918{
1919 eCsrEncryptionType connectedCipherAlgo;
1920 v_BOOL_t fConnected = FALSE;
1921 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1922 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1923 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1924 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07001925
1926 if (NULL == pRoamInfo)
1927 {
1928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
1929 return eHAL_STATUS_FAILURE;
1930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001931 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001932 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 // not require upper layer authentication) we can put TL directly into 'authenticated'
1934 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1936 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
1937 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001938
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1940 if( fConnected )
1941 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001942 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
1943 {
1944 v_U8_t staId;
1945
1946 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
1947
1948 if ( 0 == memcmp( pRoamInfo->peerMac,
1949 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
1950 {
1951 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1952 IBSS_BROADCAST_STAID);
1953 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1954 }
1955 else
1956 {
1957 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
1958 (v_MACADDR_t*)pRoamInfo->peerMac,
1959 &staId);
1960 if ( VOS_STATUS_SUCCESS == vosStatus )
1961 {
1962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1963 "WLAN TL STA Ptk Installed for STAID=%d", staId);
1964 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1965 staId);
1966 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1967 }
1968 }
1969 }
1970 else
1971 {
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301972 // TODO: Considering getting a state machine in HDD later.
1973 // This routine is invoked twice. 1)set PTK 2)set GTK.
1974 // The folloing if statement will be TRUE when setting GTK.
1975 // At this time we don't handle the state in detail.
1976 // Related CR: 174048 - TL not in authenticated state
1977 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
1978 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
1979 {
1980 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
1981 "for StaId= %d. Changing TL state to AUTHENTICATED",
1982 pHddStaCtx->conn_info.staId[ 0 ] );
1983
1984 // Connections that do not need Upper layer authentication,
1985 // transition TL to 'Authenticated' state after the keys are set.
1986 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1987 pHddStaCtx->conn_info.staId[ 0 ],
1988 WLANTL_STA_AUTHENTICATED );
1989
1990 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Mukul Sharmad2589a52014-04-23 21:06:25 +05301991 //Need to call offload because when roaming happen at that time fwr
1992 //clean offload info as part of the DelBss
1993 // No need to configure offload if host was not suspended
1994 spin_lock(&pHddCtx->filter_lock);
1995 if(pHddCtx->hdd_wlan_suspended)
1996 {
1997 spin_unlock(&pHddCtx->filter_lock);
1998 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
1999 }
2000 else
2001 {
2002 spin_unlock(&pHddCtx->filter_lock);
2003 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302004 }
2005 else
2006 {
2007 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2008 pHddStaCtx->conn_info.staId[ 0 ]);
2009 }
2010
2011 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002012 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302014 else
2015 {
2016 // possible disassoc after issuing set key and waiting set key complete
2017 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2018 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002019
Jeff Johnson295189b2012-06-20 16:38:30 -07002020 EXIT();
2021 return( eHAL_STATUS_SUCCESS );
2022}
2023/**============================================================================
2024 *
2025 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2026 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002027static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002029{
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2031
2032 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2033 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2034 {
2035 struct iw_michaelmicfailure msg;
2036 union iwreq_data wreq;
2037 memset(&msg, '\0', sizeof(msg));
2038 msg.src_addr.sa_family = ARPHRD_ETHER;
2039 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002040 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2041 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002042
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2044 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002045 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 msg.flags = IW_MICFAILURE_PAIRWISE;
2047 memset(&wreq, 0, sizeof(wreq));
2048 wreq.data.length = sizeof(msg);
2049 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002050 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002051 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2053 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2054 NL80211_KEYTYPE_GROUP :
2055 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002056 pRoamInfo->u.pMICFailureInfo->keyId,
2057 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002059
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002061
Jeff Johnson295189b2012-06-20 16:38:30 -07002062 return( eHAL_STATUS_SUCCESS );
2063}
2064
2065/**============================================================================
2066 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002067 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002068 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002069
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002071static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2072 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 eCsrRoamResult roamResult )
2074{
2075 VOS_STATUS vosStatus;
2076
2077 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2078 switch( roamResult )
2079 {
2080 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2081 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002082 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002083 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002084
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002085 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002086 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2087 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2088 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002090
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
2092 {
2093 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2094 "New IBSS peer but we already have the max we can handle. Can't register this one" );
2095 break;
2096 }
2097
2098 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2099
Shailender Karmuchia734f332013-04-19 14:02:48 -07002100 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2101 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2102 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2103
2104 // Register the Station with TL for the new peer.
Jeff Johnson295189b2012-06-20 16:38:30 -07002105 vosStatus = hdd_roamRegisterSTA( pAdapter,
2106 pRoamInfo,
2107 pRoamInfo->staId,
2108 (v_MACADDR_t *)pRoamInfo->peerMac,
2109 pRoamInfo->pBssDesc );
2110 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2111 {
2112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002113 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002114 vosStatus, vosStatus );
2115 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002116 pHddStaCtx->ibss_sta_generation++;
2117 memset(&staInfo, 0, sizeof(staInfo));
2118 staInfo.filled = 0;
2119 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2120
2121 cfg80211_new_sta(pAdapter->dev,
2122 (const u8 *)pRoamInfo->peerMac,
2123 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002124
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002125 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2126 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2127 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2128 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2129 {
2130 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2131 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2132 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2133
2134 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002135 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002136 pHddStaCtx->ibss_enc_key.encType);
2137
2138 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2139 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2140
2141 if ( VOS_STATUS_SUCCESS != vosStatus )
2142 {
2143 hddLog(VOS_TRACE_LEVEL_ERROR,
2144 "%s: sme_RoamSetKey failed, returned %d",
2145 __func__, vosStatus);
2146 return VOS_STATUS_E_FAILURE;
2147 }
2148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 netif_carrier_on(pAdapter->dev);
2150 netif_tx_start_all_queues(pAdapter->dev);
2151 break;
2152 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002153
Jeff Johnson295189b2012-06-20 16:38:30 -07002154 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2155 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002156
Jeff Johnson295189b2012-06-20 16:38:30 -07002157 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002158
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2162 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002163 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002164
Ravi Joshicc57ed42013-10-12 16:31:25 -07002165 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 {
2167 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2168 "IBSS peer departed by cannot find peer in our registration table with TL" );
2169 }
2170
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002171 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002172 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2173 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2174 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2175 pRoamInfo->staId );
2176
Jeff Johnson295189b2012-06-20 16:38:30 -07002177 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
2178
2179 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002180 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002181
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002182 cfg80211_del_sta(pAdapter->dev,
2183 (const u8 *)&pRoamInfo->peerMac,
2184 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 break;
2186 }
2187 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2188 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002189 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2190 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 // Stop only when we are inactive
2192 netif_tx_disable(pAdapter->dev);
2193 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302194 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2195 "%s: Set HDD connState to eConnectionState_NotConnected",
2196 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002198
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 // Send the bssid address to the wext.
2200 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2201 // clean up data path
2202 hdd_disconnect_tx_rx(pAdapter);
2203 break;
2204 }
2205 default:
2206 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002207
Jeff Johnson295189b2012-06-20 16:38:30 -07002208 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002209
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 return( eHAL_STATUS_SUCCESS );
2211}
2212
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002213#ifdef FEATURE_WLAN_TDLS
2214/**============================================================================
2215 *
2216 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2217 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2218 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002219
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002220 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002221VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2222 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002223{
2224 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002225 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002226 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2227 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002228 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2229 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002230 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2231 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002232
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002233 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2234 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002235 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002236 "%s not connected. ignored", __func__);
2237 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002238 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002239
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002240 /*
2241 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2242 * be peer MAC, here we are wokrking on direct Link
2243 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002244 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002245
2246 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002247
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002248 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002249 sizeof(tSirMacAddr) );
2250
2251 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2252 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2253
2254 /* set the QoS field appropriately ..*/
2255 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2256 : (staDesc.ucQosEnabled = 0) ;
2257
2258 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002259 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002260
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002261 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002262
2263 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002264 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002265
Shailender Karmuchia734f332013-04-19 14:02:48 -07002266 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002267 * UMA is ready we inform TL to do frame translation.
2268 */
2269 staDesc.ucSwFrameTXXlation = 1;
2270 staDesc.ucSwFrameRXXlation = 1;
2271 staDesc.ucAddRmvLLC = 1;
2272
2273 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002274 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002275
2276 /* tdls Direct Link do not need bcastSig */
2277 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002278
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002279#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2280 if(staDesc.ucProtectedFrame)
2281 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2282 else
2283 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2284#endif
2285
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302286 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002287
Shailender Karmuchia734f332013-04-19 14:02:48 -07002288 /* Register the Station with TL... */
2289 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2290 hdd_rx_packet_cbk,
2291 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002292 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002293
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002294 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2295 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002296 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002297 "%s: WLANTL_RegisterSTAClient() failed to register. "
2298 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002299 return vosStatus;
2300 }
2301
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002302 if ( cfg_param->dynSplitscan &&
2303 ( VOS_TIMER_STATE_RUNNING !=
2304 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2305 {
2306 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2307 cfg_param->trafficMntrTmrForSplitScan);
2308 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002309 return( vosStatus );
2310}
2311
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002312static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
2313{
2314 VOS_STATUS vosStatus;
2315 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2316 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2317 {
2318 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2319 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002320 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002321 __func__, staId, vosStatus, vosStatus );
2322 }
2323 return( vosStatus );
2324}
2325
2326
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002327/*
2328 * HDD interface between SME and TL to ensure TDLS client registration with
2329 * TL in case of new TDLS client is added and deregistration at the time
2330 * TDLS client is deleted.
2331 */
2332
Shailender Karmuchia734f332013-04-19 14:02:48 -07002333eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2334 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002335 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002336 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002337 eCsrRoamResult roamResult)
2338{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002339 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002340 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002341 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002342
2343#ifdef WLAN_FEATURE_TDLS_DEBUG
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002345 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2346 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2347 "ADD_TDLS_PEER" :
2348 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2349 "DEL_TDLS_PEER" :
2350 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2351 "DEL_TDLS_PEER_IND" :
2352 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2353 "DEL_ALL_TDLS_PEER_IND" :
2354 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2355 "UPDATE_TDLS_PEER" :
2356 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2357 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2358 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002359#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002360 switch( roamResult )
2361 {
2362 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2363 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002364 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2365 {
2366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002367 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002368 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002369 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002370 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002371
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002372 /* check if there is available index for this new TDLS STA */
2373 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2374 {
2375 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2376 {
2377 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2378 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2379
2380 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002381 ("TDLS: STA IDX at %d is %d "
2382 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002383 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002384 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002385
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002386 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002387 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2388 status = eHAL_STATUS_SUCCESS ;
2389 break ;
2390 }
2391 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002392 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002393 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002394 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002395 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2396 "wlan_hdd_tdls_set_sta_id() failed");
2397 return VOS_FALSE;
2398 }
2399
2400 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302401 /* store the ucast signature , if required for further reference. */
2402
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002403 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302404 /* start TDLS client registration with TL */
2405 status = hdd_roamRegisterTDLSSTA( pAdapter,
2406 pRoamInfo->peerMac,
2407 pRoamInfo->staId,
2408 pRoamInfo->ucastSig);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002409 }
2410 else
2411 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002412 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002414 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002415 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002416 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002417 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002418 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002419 break ;
2420 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002421 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2422 {
2423 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2424 {
2425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2426 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2427 }
2428 /* store the ucast signature which will be used later when
2429 * registering to TL
2430 */
2431 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2432 complete(&pAdapter->tdls_add_station_comp);
2433 break;
2434 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302435 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
2436 {
2437 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2438 {
2439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2440 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
2441 }
2442 complete(&pAdapter->tdls_link_establish_req_comp);
2443 break;
2444 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002445 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002446 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002447 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002448 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002449 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002450 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2451 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002452 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002454 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2455
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302456 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002457 if (NULL != curr_peer && TDLS_IS_CONNECTED(curr_peer))
2458 {
2459 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2460 wlan_hdd_tdls_decrement_peer_count(pAdapter);
2461 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002462 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002463
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002464 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2465 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2466 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002467 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002468 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002469 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002470 break ;
2471 }
2472 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002473 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002474 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002475 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002476 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2477 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002478 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002479 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2480 "%s: Sending teardown to supplicant with reason code %u",
2481 __func__, pRoamInfo->reasonCode);
2482
2483#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302484 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002485 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002486#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002487 status = eHAL_STATUS_SUCCESS ;
2488 break ;
2489 }
2490 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2491 {
2492 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002493 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002494 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002495 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2496 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002497 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002499 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002500 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002501 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002502 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2503 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2504 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002505
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002506 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002507 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002508 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2509 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002510
2511 status = eHAL_STATUS_SUCCESS ;
2512 }
2513 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05302514 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002515 break ;
2516 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002517 default:
2518 {
2519 break ;
2520 }
2521 }
2522
2523 return status ;
2524}
2525#endif
2526
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002527static void iw_full_power_cbfn (void *pContext, eHalStatus status)
2528{
2529 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
2530 hdd_context_t *pHddCtx = NULL;
2531 int ret;
2532
2533 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
2534 {
2535 hddLog(VOS_TRACE_LEVEL_ERROR,
2536 "%s: Bad param, pAdapter [%p]",
2537 __func__, pAdapter);
2538 return;
2539 }
2540
2541 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2542 ret = wlan_hdd_validate_context(pHddCtx);
2543 if (0 != ret)
2544 {
2545 hddLog(VOS_TRACE_LEVEL_ERROR,
2546 "%s: HDD context is not valid (%d)", __func__, ret);
2547 return;
2548 }
2549
2550 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2551 {
2552 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
2553 }
2554}
2555
Shailender Karmuchia734f332013-04-19 14:02:48 -07002556eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2558{
2559 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2560 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302561 hdd_wext_state_t *pWextState = NULL;
2562 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002563 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07002564 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002565
2566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002567 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002568 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002569
2570 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302571 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002572 {
2573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302574 "invalid adapter or adapter has invalid magic");
2575 return eHAL_STATUS_FAILURE;
2576 }
2577
2578 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2579 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2580
2581 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2582 {
2583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2584 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002585 return eHAL_STATUS_FAILURE;
2586 }
2587
Jeff Johnson295189b2012-06-20 16:38:30 -07002588 switch( roamStatus )
2589 {
2590 case eCSR_ROAM_SESSION_OPENED:
2591 if(pAdapter != NULL)
2592 {
2593 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2594 complete(&pAdapter->session_open_comp_var);
2595 }
2596 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002597
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002598#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
2599 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07002601 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 * interface down */
2603 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05302604 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
2605 roamStatus, roamResult, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2607 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2608 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2610 }
2611 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302612 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002613 break;
2614
2615 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002616 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07002618 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 // eCSR_ROAM_SHOULD_ROAM will be received.
2620 // Where in we will not mark the link down
2621 // Also we want to stop tx at this point when we will be
2622 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002623 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 {
2625 struct net_device *dev = pAdapter->dev;
2626 netif_tx_disable(dev);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002627 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002628 * Deregister for this STA with TL with the objective to flush
2629 * all the packets for this STA from wmm_tx_queue. If not done here,
2630 * we would run into a race condition (CR390567) wherein TX
2631 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2632 * been deleted. And, these packets get assigned with a STA idx of
2633 * self-sta (since the peer STA has been deleted) and get transmitted
2634 * on the new channel before the reassoc request. Since there will be
2635 * no ACK on the new channel, each packet gets retransmitted which
2636 * takes several seconds before the transmission of reassoc request.
2637 * This leads to reassoc-timeout and roam failure.
2638 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002639 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2640 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2641 {
2642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2643 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2644 pHddStaCtx->conn_info.staId[0], status, status );
2645 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002646 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 }
2648 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002649 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 break;
2651#endif
2652
2653 case eCSR_ROAM_SHOULD_ROAM:
2654 // Dont need to do anything
2655 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 struct net_device *dev = pAdapter->dev;
2657 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2658 // notify apps that we can't pass traffic anymore
2659 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002660#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 if (pHddStaCtx->ft_carrier_on == FALSE)
2662 {
2663#endif
2664 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002665#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 }
2667#endif
2668
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002669#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 //We should clear all sta register with TL, for now, only one.
2671 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2672 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2673 {
2674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2675 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2676 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002677 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002679#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 }
2681 break;
2682 case eCSR_ROAM_LOSTLINK:
2683 case eCSR_ROAM_DISASSOCIATED:
2684 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002685 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2686 "****eCSR_ROAM_DISASSOCIATED****");
2687 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2688 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07002689 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2690 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302691 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07002692 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08002693
2694 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
2695 pHddCtx->configuredMcastBcastFilter =
2696 pHddCtx->sus_res_mcastbcast_filter;
2697 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
2698 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302699
Amar Singhald53568e2013-09-26 11:03:45 -07002700 hddLog(VOS_TRACE_LEVEL_INFO,
2701 "offload: disassociation happening, restoring configuredMcastBcastFilter");
2702 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
2703 pHddCtx->configuredMcastBcastFilter);
2704 hddLog(VOS_TRACE_LEVEL_INFO,
2705 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07002706 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2707 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002708#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302709 /* Call to clear any MC Addr List filter applied after
2710 * successful connection.
2711 */
2712 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002713#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002714 }
2715 break;
2716 case eCSR_ROAM_IBSS_LEAVE:
2717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2718 "****eCSR_ROAM_IBSS_LEAVE****");
2719 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2720 break;
2721 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2723 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302724 // To Do - address probable memory leak with WEP encryption upon successful association
2725 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302727 //Clear saved connection information in HDD
2728 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002729 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302730 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002731
2732 break;
2733 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002734 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 pRoamInfo, roamId, roamStatus, roamResult );
2736 break;
2737 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07002738 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
2739 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 break;
2741
2742 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2743 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002744 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002745
2746 case eCSR_ROAM_MIC_ERROR_IND:
2747 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2748 break;
2749
2750 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002751 {
2752 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2753
2754 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002755 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
2756 (TRUE == pHddCtx->hdd_wlan_suspended) &&
2757 (eCSR_ROAM_RESULT_NONE == roamResult))
2758 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002759 /* Send DTIM period to the FW; only if the wlan is already
2760 in suspend. This is the case with roaming (reassoc),
2761 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
2762 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
2763 before the ENTER_BMPS_REQ ensures Listen Interval is
2764 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002765 hdd_set_pwrparams(pHddCtx);
2766 pHddStaCtx->hdd_ReassocScenario = VOS_FALSE;
2767
2768 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002769 if due to unexpected scenario, if we are in BMPS,
2770 then trigger Exit and Enter BMPS to take DTIM period
2771 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002772 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
2773 {
2774 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
2775
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002776 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2777 iw_full_power_cbfn, pAdapter,
2778 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002779 }
2780 }
2781 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302782 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 break;
2785#ifdef WLAN_FEATURE_VOWIFI_11R
2786 case eCSR_ROAM_FT_RESPONSE:
2787 hdd_SendFTEvent(pAdapter);
2788 break;
2789#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002790#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002791 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002792 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07002793 {
2794 /* Notify the supplicant of a new candidate */
2795 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2796 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002797 break;
2798#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002799
Yue Maef608272013-04-08 23:09:17 -07002800#ifdef FEATURE_WLAN_LFR_METRICS
2801 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
2802 /* This event is to notify pre-auth initiation */
2803 if (VOS_STATUS_SUCCESS !=
2804 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
2805 {
2806 halStatus = eHAL_STATUS_FAILURE;
2807 }
2808 break;
2809 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
2810 /* This event will notify pre-auth completion in case of success */
2811 if (VOS_STATUS_SUCCESS !=
2812 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2813 pRoamInfo, 1))
2814 {
2815 halStatus = eHAL_STATUS_FAILURE;
2816 }
2817 break;
2818 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
2819 /* This event will notify pre-auth completion in case of failure. */
2820 if (VOS_STATUS_SUCCESS !=
2821 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2822 pRoamInfo, 0))
2823 {
2824 halStatus = eHAL_STATUS_FAILURE;
2825 }
2826 break;
2827 case eCSR_ROAM_HANDOVER_SUCCESS:
2828 /* This event is to notify handover success.
2829 It will be only invoked on success */
2830 if (VOS_STATUS_SUCCESS !=
2831 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
2832 {
2833 halStatus = eHAL_STATUS_FAILURE;
2834 }
2835 break;
2836#endif
2837
Jeff Johnson295189b2012-06-20 16:38:30 -07002838 case eCSR_ROAM_INDICATE_MGMT_FRAME:
2839 hdd_indicateMgmtFrame( pAdapter,
2840 pRoamInfo->nFrameLength,
2841 pRoamInfo->pbFrames,
2842 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05302843 pRoamInfo->rxChan,
2844 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 break;
2846 case eCSR_ROAM_REMAIN_CHAN_READY:
2847 hdd_remainChanReadyHandler( pAdapter );
2848 break;
2849 case eCSR_ROAM_SEND_ACTION_CNF:
2850 hdd_sendActionCnf( pAdapter,
2851 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
2852 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002853#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08002854 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002855 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08002856 roamId, roamStatus, roamResult );
2857 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002858 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
2859 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
2860 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002861#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002862#ifdef WLAN_FEATURE_11W
2863 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
2864 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
2865 pRoamInfo->pbFrames,
2866 pRoamInfo->frameType);
2867 break;
2868#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002869#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002870 case eCSR_ROAM_TSM_IE_IND:
2871 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
2872 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
2873 break;
2874
2875 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
2876 {
2877 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
2878 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
2879 {
2880 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
2881 }
2882 break;
2883 }
2884
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002885 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002886 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002887 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002888 break;
2889 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002890
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002891 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002892 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002893 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002894 break;
2895 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002896#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 default:
2898 break;
2899 }
2900 return( halStatus );
2901}
Shailender Karmuchia734f332013-04-19 14:02:48 -07002902eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002903{
2904 eCsrAuthType auth_type;
2905 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002906 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 {
2908 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002909 } else
2910 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 {
2912 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002913 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002914#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07002915 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002916 {
2917 // Check for 11r FT Authentication with PSK
2918 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002919 } else
2920 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 {
2922 // Check for 11R FT Authentication with 802.1X
2923 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002924 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002925#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002926#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07002927 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002928 {
2929 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
2930 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002931#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07002932#ifdef WLAN_FEATURE_11W
2933 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
2934 {
2935 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
2936 } else
2937#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002938 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2940 }
2941 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002942}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002943
Shailender Karmuchia734f332013-04-19 14:02:48 -07002944eCsrAuthType
2945hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002946{
2947 eCsrAuthType auth_type;
2948 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002949 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 {
2951 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002952 } else
2953 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002954 {
2955 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002956 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002957#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07002958 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002959 {
2960 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002961 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002962#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002963 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002964 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2965 }
2966 hddLog(LOG1, FL("auth_type: %d"), auth_type);
2967 return auth_type;
2968}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002969
Shailender Karmuchia734f332013-04-19 14:02:48 -07002970eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07002971hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002972{
2973 eCsrEncryptionType cipher_type;
2974 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002975 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002976 {
2977 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002978 }
2979 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 {
2981 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002982 }
2983 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 {
2985 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002986 }
2987 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002988 {
2989 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002990 }
2991 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
2992 {
2993 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2994 }
2995 else
2996 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2998 }
2999 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3000 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003001}
Jeff Johnson295189b2012-06-20 16:38:30 -07003002/* To find if the MAC address is NULL */
3003static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3004{
3005 int i;
3006 for (i = 0; i < length; i++)
3007 {
3008 if (0x00 != (macAddr[i]))
3009 {
3010 return FALSE;
3011 }
3012 }
3013 return TRUE;
3014} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003015
Shailender Karmuchia734f332013-04-19 14:02:48 -07003016eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003017hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003018{
3019 eCsrEncryptionType cipher_type;
3020 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003021 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003022 {
3023 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003024 } else
3025 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003026 {
3027 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003028 } else
3029 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 {
3031 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003032 } else
3033 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 {
3035 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003036 } else
3037 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003039 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3040 } else
3041 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3043 }
3044 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3045 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003046}
Jeff Johnson295189b2012-06-20 16:38:30 -07003047
Shailender Karmuchia734f332013-04-19 14:02:48 -07003048static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3049 struct ether_addr *pBssid,
3050 eCsrEncryptionType *pEncryptType,
3051 eCsrEncryptionType *mcEncryptType,
3052 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003053#ifdef WLAN_FEATURE_11W
3054 u_int8_t *pMfpRequired,
3055 u_int8_t *pMfpCapable,
3056#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003057 u_int16_t gen_ie_len,
3058 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003059{
3060 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003061 eHalStatus result;
3062 tDot11fIERSN dot11RSNIE;
3063 tDot11fIEWPA dot11WPAIE;
3064 tANI_U32 i;
3065 tANI_U8 *pRsnIe;
3066 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003067 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003068 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003069
3070 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3071 flag to 0 */
3072 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3073 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3074
3075 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003076 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
3077 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303078 {
3079 hddLog(LOGE, "%s: Invalid DOT11F IE Length passed :%d",
3080 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 return -EINVAL;
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303082 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003084 if ( gen_ie[0] == DOT11F_EID_RSN)
3085 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003087 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3089 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303090 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3091 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 return -EINVAL;
3093 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003094 // Skip past the EID byte and length byte
3095 pRsnIe = gen_ie + 2;
3096 RSNIeLen = gen_ie_len - 2;
3097 // Unpack the RSN IE
3098 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3099 pRsnIe,
3100 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003102 // Copy out the encryption and authentication types
3103 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003104 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003105 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003106 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003107 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 but probably I suspect we can do something different*/
3109 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003110 // Just translate the FIRST one
3111 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3112 //dot11RSNIE.pwise_cipher_suite_count
3113 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3114 //dot11RSNIE.gp_cipher_suite_count
3115 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003116#ifdef WLAN_FEATURE_11W
3117 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3118 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3119#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003121 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003122 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003123 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303125 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 break;
3127 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003128 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303130 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 break;
3132 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003133 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 // For right now, I assume setASSOCIATE() has passed in the bssid.
3135 vos_mem_copy(PMKIDCache[i].BSSID,
3136 pBssid, ETHER_ADDR_LEN);
3137 vos_mem_copy(PMKIDCache[i].PMKID,
3138 dot11RSNIE.pmkid[i],
3139 CSR_RSN_PMKID_SIZE);
3140 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003141
3142 if (updatePMKCache)
3143 {
3144 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003145 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003146 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003147 // Finally set the PMKSA ID Cache in CSR
3148 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3149 PMKIDCache,
3150 dot11RSNIE.pmkid_count );
3151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 }
3153 else if (gen_ie[0] == DOT11F_EID_WPA)
3154 {
3155 // Validity checks
3156 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3157 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3158 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303159 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3160 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 return -EINVAL;
3162 }
3163 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003164 pRsnIe = gen_ie + 2 + 4;
3165 RSNIeLen = gen_ie_len - (2 + 4);
3166 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3168 pRsnIe,
3169 RSNIeLen,
3170 &dot11WPAIE);
3171 // Copy out the encryption and authentication types
3172 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003173 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003174 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003175 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 //dot11WPAIE.auth_suite_count
3177 // Just translate the FIRST one
3178 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3179 //dot11WPAIE.unicast_cipher_count
3180 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3181 //dot11WPAIE.unicast_cipher_count
3182 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3183 }
3184 else
3185 {
3186 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003187 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 }
3189 return 0;
3190}
3191int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3192{
3193 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3194 v_U32_t status = 0;
3195 eCsrEncryptionType RSNEncryptType;
3196 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003197#ifdef WLAN_FEATURE_11W
3198 u_int8_t RSNMfpRequired;
3199 u_int8_t RSNMfpCapable;
3200#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 struct ether_addr bSsid; // MAC address of assoc peer
3202 // MAC address of assoc peer
3203 // But, this routine is only called when we are NOT associated.
3204 vos_mem_copy(bSsid.ether_addr_octet,
3205 pWextState->roamProfile.BSSIDs.bssid,
3206 sizeof(bSsid.ether_addr_octet));
3207 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3208 {
3209 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 else
3212 {
3213 return 0;
3214 }
3215 // The actual processing may eventually be more extensive than this.
3216 // Right now, just consume any PMKIDs that are sent in by the app.
3217 status = hdd_ProcessGENIE(pAdapter,
3218 &bSsid, // MAC address of assoc peer
3219 &RSNEncryptType,
3220 &mcRSNEncryptType,
3221 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003222#ifdef WLAN_FEATURE_11W
3223 &RSNMfpRequired,
3224 &RSNMfpCapable,
3225#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 pWextState->WPARSNIE[1]+2,
3227 pWextState->WPARSNIE);
3228 if (status == 0)
3229 {
3230 // Now copy over all the security attributes you have parsed out
3231 pWextState->roamProfile.EncryptionType.numEntries = 1;
3232 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003233
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3235 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003236
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003237 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3238 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3239 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3240 {
3241 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3242 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3243 either AES/TKIP based on group cipher configuration
3244 mentioned in the wpa_supplicant.conf.*/
3245
3246 /*Set the unicast cipher same as multicast cipher*/
3247 pWextState->roamProfile.EncryptionType.encryptionType[0]
3248 = mcRSNEncryptType;
3249 }
3250
Chet Lanctot186b5732013-03-18 10:26:30 -07003251#ifdef WLAN_FEATURE_11W
3252 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3253 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3254#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003255 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 }
3257 return 0;
3258}
3259int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3260{
3261 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3262 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3263 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3264 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003265
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003267 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003268
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 switch( pHddStaCtx->conn_info.authType)
3270 {
3271 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003272#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 case eCSR_AUTH_TYPE_CCKM_WPA:
3274 case eCSR_AUTH_TYPE_CCKM_RSN:
3275#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003276 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3277
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003279 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003281
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003282#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003283 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3284 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3285 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003286 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003287 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3288 } else
3289 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003290 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003291 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 } else
3293#endif
3294 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3295 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003296 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3297 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3299 == IW_AUTH_KEY_MGMT_PSK) {
3300 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003301 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 }
3305 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003306#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003307 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3308 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3309 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003310 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003311 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003312 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003313 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003314 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003315 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 } else
3317#endif
3318
3319#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003320 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3321 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003322 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003323 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003324 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003325 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3327 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003328 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 } else
3330#endif
3331
Chet Lanctot186b5732013-03-18 10:26:30 -07003332#ifdef WLAN_FEATURE_11W
3333 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3334 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3335 } else
3336#endif
3337
Shailender Karmuchia734f332013-04-19 14:02:48 -07003338 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003340 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3341 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003342 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3343 == IW_AUTH_KEY_MGMT_PSK) {
3344 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003345 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003349 break;
3350
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003352
3353 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003354 break;
3355 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003356
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003357#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08003358 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003359#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3361 break;
3362 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003363
Jeff Johnson295189b2012-06-20 16:38:30 -07003364 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003365 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003366
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 EXIT();
3368 return 0;
3369}
3370
3371/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003372
3373 \brief iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003375 to the CSR roam profile.
3376
Jeff Johnson295189b2012-06-20 16:38:30 -07003377 \param - dev - Pointer to the net device.
3378 - info - Pointer to the iw_request_info.
3379 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003380 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003382
Jeff Johnson295189b2012-06-20 16:38:30 -07003383 --------------------------------------------------------------------------*/
3384
Shailender Karmuchia734f332013-04-19 14:02:48 -07003385int iw_set_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 struct iw_request_info *info,
3387 union iwreq_data *wrqu, char *extra)
3388{
3389 v_U32_t status = 0;
3390 hdd_wext_state_t *pWextState;
3391 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3392 v_U32_t roamId;
3393 tCsrRoamProfile *pRoamProfile;
3394 eMib_dot11DesiredBssType connectedBssType;
3395 eCsrAuthType RSNAuthType;
3396 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3397 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003398
3399 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3400
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 ENTER();
3402
3403 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3404 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 "%s:LOGP in Progress. Ignore!!!",__func__);
3407 return 0;
3408 }
3409
3410 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
3411 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
3412 return -EBUSY;
3413 }
3414 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
3415 return -EINVAL;
3416 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003417 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 {
3419 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
3420 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
3421 {
3422 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003423 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3425 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
3426
3427 if(VOS_STATUS_SUCCESS == vosStatus)
3428 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3429 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3430 }
3431 }
3432 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003433 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003434 {
3435 return -EINVAL;
3436 }
3437 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003438 /** when cfg80211 defined, wpa_supplicant wext driver uses
3439 zero-length, null-string ssid for force disconnection.
3440 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 driver MUST return success */
3442 if ( 0 == wrqu->essid.length ) {
3443 return 0;
3444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003445
3446 status = hdd_wmm_get_uapsd_mask(pAdapter,
3447 &pWextState->roamProfile.uapsd_mask);
3448 if (VOS_STATUS_SUCCESS != status)
3449 {
3450 pWextState->roamProfile.uapsd_mask = 0;
3451 }
3452 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003453
Jeff Johnson295189b2012-06-20 16:38:30 -07003454 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003455
3456 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
3458 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
3459 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003460
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 //set gen ie
3462 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
3463
3464 //set auth
3465 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
3466 }
3467#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003468 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003469 if (pAdapter->wapi_info.nWapiMode)
3470 {
3471 switch (pAdapter->wapi_info.wapiAuthMode)
3472 {
3473 case WAPI_AUTH_MODE_PSK:
3474 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003475 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003476 pRoamProfile->AuthType.numEntries = 1;
3477 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3478 break;
3479 }
3480 case WAPI_AUTH_MODE_CERT:
3481 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003482 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 pRoamProfile->AuthType.numEntries = 1;
3484 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3485 break;
3486 }
3487 } // End of switch
3488 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
3489 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
3490 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003491 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003492 pRoamProfile->EncryptionType.numEntries = 1;
3493 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3494 pRoamProfile->mcEncryptionType.numEntries = 1;
3495 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3496 }
3497 }
3498#endif /* FEATURE_WLAN_WAPI */
3499 /* if previous genIE is not NULL, update AssocIE */
3500 if (0 != pWextState->genIE.length)
3501 {
3502 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
3503 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
3504 pWextState->genIE.length);
3505 pWextState->assocAddIE.length = pWextState->genIE.length;
3506 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
3507 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
3508
3509 /* clear previous genIE after use it */
3510 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
3511 }
3512
3513 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
3514 pWextState->roamProfile.bWPSAssociation = FALSE;
3515
3516 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
3517 pWextState->roamProfile.nAddIEAssocLength))
3518 pWextState->roamProfile.bWPSAssociation = TRUE;
3519
3520
3521 // Disable auto BMPS entry by PMC until DHCP is done
3522 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
3523
Shailender Karmuchia734f332013-04-19 14:02:48 -07003524 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003525 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003526
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003527 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
3528 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003529 hdd_select_cbmode(pAdapter,
3530 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
3531 }
3532 status = sme_RoamConnect( hHal,pAdapter->sessionId,
3533 &(pWextState->roamProfile), &roamId);
3534 pRoamProfile->ChannelInfo.ChannelList = NULL;
3535 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003536
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003537 EXIT();
3538 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003539}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003540
Jeff Johnson295189b2012-06-20 16:38:30 -07003541/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003542
3543 \brief iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003545
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 \param - dev - Pointer to the net device.
3547 - info - Pointer to the iw_request_info.
3548 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003549 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003551
Jeff Johnson295189b2012-06-20 16:38:30 -07003552 --------------------------------------------------------------------------*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003553int iw_get_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 struct iw_request_info *info,
3555 struct iw_point *dwrq, char *extra)
3556{
3557 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003558 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003559 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3560 ENTER();
3561
3562 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
3563 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
3564 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
3565 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
3566 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
3567 {
3568 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
3569 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
3570 dwrq->flags = 1;
3571 } else {
3572 memset(extra, 0, dwrq->length);
3573 dwrq->length = 0;
3574 dwrq->flags = 0;
3575 }
3576 EXIT();
3577 return 0;
3578}
3579/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003580
3581 \brief iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003583
Jeff Johnson295189b2012-06-20 16:38:30 -07003584 \param - dev - Pointer to the net device.
3585 - info - Pointer to the iw_request_info.
3586 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003587 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003588 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003589
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 --------------------------------------------------------------------------*/
3591int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
3592 union iwreq_data *wrqu,char *extra)
3593{
3594 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003595 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3597 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003598 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 eCsrEncryptionType ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003600
Jeff Johnson295189b2012-06-20 16:38:30 -07003601 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003602
3603 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3604 {
3605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3606 "%s:LOGP in Progress. Ignore!!!", __func__);
3607 return -EBUSY;
3608 }
3609
Jeff Johnson295189b2012-06-20 16:38:30 -07003610 switch(wrqu->param.flags & IW_AUTH_INDEX)
3611 {
3612 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003613
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003615
Jeff Johnson295189b2012-06-20 16:38:30 -07003616 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003617
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 case IW_AUTH_CIPHER_PAIRWISE:
3619 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003620 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3624 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3627 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003628 }
3629
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003631
3632 if( (IW_AUTH_KEY_MGMT_802_1X
3633 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
3635 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003636 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07003637 else
3638 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003639 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003642
3643 if( ( IW_AUTH_KEY_MGMT_802_1X
3644 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3646 /*Dynamic WEP key*/
3647 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3648 else
3649 /*Static WEP key*/
3650 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003651
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 }
3653 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003654
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003656 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003657 return -EINVAL;
3658 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003659
Jeff Johnson295189b2012-06-20 16:38:30 -07003660 pRoamProfile->EncryptionType.numEntries = 1;
3661 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003662 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 break;
3664 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003665 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
3667 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3668 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003669
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3671 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
3672 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003673
3674 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
3676 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003677
Jeff Johnson295189b2012-06-20 16:38:30 -07003678 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003679
3680 if( ( IW_AUTH_KEY_MGMT_802_1X
3681 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
3682 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3683
Jeff Johnson295189b2012-06-20 16:38:30 -07003684 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003685
3686 else
3687 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003689
3690 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3691 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003693 if( ( IW_AUTH_KEY_MGMT_802_1X
3694 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3696 {
3697 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3698 }
3699 else
3700 {
3701 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3702 }
3703 }
3704 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003705
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003707 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 return -EINVAL;
3709 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003710
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 pRoamProfile->mcEncryptionType.numEntries = 1;
3712 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3713 }
3714 break;
3715
3716 case IW_AUTH_80211_AUTH_ALG:
3717 {
3718 /*Save the auth algo here and set auth type to SME Roam profile
3719 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003720 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07003721 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003722
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3724 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3725
3726 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3727 /*Not supported*/
3728 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3729 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3730 }
3731 break;
3732
3733 case IW_AUTH_KEY_MGMT:
3734 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003735#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003736#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3737 /*Check for CCKM AKM type */
3738 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003739 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
3740 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003741 /* Set the CCKM bit in authKeyMgmt */
3742 /* Right now, this breaks all ref to authKeyMgmt because our
3743 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 */
3745 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3746 /*Set the key management to 802.1X*/
3747 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003748 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3750 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3751 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3752 /*Save the key management*/
3753 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3754 //pWextState->authKeyMgmt = wrqu->param.value;
3755 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3756 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3757 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3758 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3759 /*Save the key management anyway*/
3760 pWextState->authKeyMgmt = wrqu->param.value;
3761 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3762 /*Save the key management*/
3763 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3764 //pWextState->authKeyMgmt = wrqu->param.value;
3765 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3766 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3767 }
3768#else
3769 /*Save the key management*/
3770 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003771#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 }
3773 break;
3774
3775 case IW_AUTH_TKIP_COUNTERMEASURES:
3776 {
3777 if(wrqu->param.value) {
3778 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3779 "Counter Measure started %d", wrqu->param.value);
3780 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3781 }
3782 else {
3783 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3784 "Counter Measure stopped=%d", wrqu->param.value);
3785 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3786 }
3787 }
3788 break;
3789 case IW_AUTH_DROP_UNENCRYPTED:
3790 case IW_AUTH_WPA_ENABLED:
3791 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3792 case IW_AUTH_ROAMING_CONTROL:
3793 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003794
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003796
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003797 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 wrqu->param.flags & IW_AUTH_INDEX);
3799 break;
3800 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003801
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 EXIT();
3803 return 0;
3804}
3805/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003806
3807 \brief iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003808 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003809
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 \param - dev - Pointer to the net device.
3811 - info - Pointer to the iw_request_info.
3812 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003813 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003815
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 --------------------------------------------------------------------------*/
3817int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3818 union iwreq_data *wrqu,char *extra)
3819{
3820 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003821 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003822 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3823 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003824
3825 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3826 {
3827 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3828 "%s:LOGP in Progress. Ignore!!!", __func__);
3829 return -EBUSY;
3830 }
3831
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 switch(pRoamProfile->negotiatedAuthType)
3833 {
3834 case eCSR_AUTH_TYPE_WPA_NONE:
3835 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3836 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
3837 break;
3838 case eCSR_AUTH_TYPE_WPA:
3839 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3840 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
3841 break;
3842#ifdef WLAN_FEATURE_VOWIFI_11R
3843 case eCSR_AUTH_TYPE_FT_RSN:
3844#endif
3845 case eCSR_AUTH_TYPE_RSN:
3846 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3847 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
3848 break;
3849 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3850 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3851 break;
3852 case eCSR_AUTH_TYPE_SHARED_KEY:
3853 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
3854 break;
3855 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003856 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3858 break;
3859 case eCSR_AUTH_TYPE_AUTOSWITCH:
3860 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3861 break;
3862 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303863 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3865 return -EIO;
3866#ifdef WLAN_FEATURE_VOWIFI_11R
3867 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3868#endif
3869 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07003870#ifdef WLAN_FEATURE_11W
3871 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3872#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05303873 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3875 return -EIO;
3876 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303877 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003878 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3879 return -EIO;
3880 }
3881 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
3882 {
3883 switch(pRoamProfile->negotiatedUCEncryptionType)
3884 {
3885 case eCSR_ENCRYPT_TYPE_NONE:
3886 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3887 break;
3888 case eCSR_ENCRYPT_TYPE_WEP40:
3889 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3890 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3891 break;
3892 case eCSR_ENCRYPT_TYPE_TKIP:
3893 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3894 break;
3895 case eCSR_ENCRYPT_TYPE_WEP104:
3896 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3897 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3898 break;
3899 case eCSR_ENCRYPT_TYPE_AES:
3900 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3901 break;
3902 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303903 hddLog(LOG1, "%s called with unknown auth type %d ",
3904 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 return -EIO;
3906 }
3907 }
3908
Shailender Karmuchia734f332013-04-19 14:02:48 -07003909 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07003910 {
3911 switch(pRoamProfile->negotiatedMCEncryptionType)
3912 {
3913 case eCSR_ENCRYPT_TYPE_NONE:
3914 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3915 break;
3916 case eCSR_ENCRYPT_TYPE_WEP40:
3917 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3918 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3919 break;
3920 case eCSR_ENCRYPT_TYPE_TKIP:
3921 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3922 break;
3923 case eCSR_ENCRYPT_TYPE_WEP104:
3924 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3925 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3926 break;
3927 case eCSR_ENCRYPT_TYPE_AES:
3928 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3929 break;
3930 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303931 hddLog(LOG1, "%s called with unknown auth type %d ",
3932 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 return -EIO;
3934 }
3935 }
3936
3937 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003938 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 EXIT();
3940 return 0;
3941}
3942/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003943
3944 \brief iw_set_ap_address() -
3945 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07003946 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003947
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 \param - dev - Pointer to the net device.
3949 - info - Pointer to the iw_request_info.
3950 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003951 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003953
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 --------------------------------------------------------------------------*/
3955int iw_set_ap_address(struct net_device *dev,
3956 struct iw_request_info *info,
3957 union iwreq_data *wrqu, char *extra)
3958{
3959 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3960 v_U8_t *pMacAddress=NULL;
3961 ENTER();
3962 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08003963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
3964 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
3966 EXIT();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003967
Jeff Johnson295189b2012-06-20 16:38:30 -07003968 return 0;
3969}
3970/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003971
3972 \brief iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 This function returns the BSSID to the wpa_supplicant
3974 \param - dev - Pointer to the net device.
3975 - info - Pointer to the iw_request_info.
3976 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003977 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003979
Jeff Johnson295189b2012-06-20 16:38:30 -07003980 --------------------------------------------------------------------------*/
3981int iw_get_ap_address(struct net_device *dev,
3982 struct iw_request_info *info,
3983 union iwreq_data *wrqu, char *extra)
3984{
3985 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3986 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3987
3988 ENTER();
3989
3990 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
3991 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
3992 {
Jeff Johnson4416a782013-03-25 14:17:50 -07003993 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003994 }
3995 else
3996 {
3997 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
3998 }
3999 EXIT();
4000 return 0;
4001}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004002
Chet Lanctot186b5732013-03-18 10:26:30 -07004003#ifdef WLAN_FEATURE_11W
4004/**---------------------------------------------------------------------------
4005
4006 \brief hdd_indicateUnprotMgmtFrame -
4007 This function forwards the unprotected management frame to the supplicant
4008 \param - pAdapter - Pointer to HDD adapter
4009 - nFrameLength - Length of the unprotected frame being passed
4010 - pbFrames - Pointer to the frame buffer
4011 - frameType - 802.11 frame type
4012 \return - nothing
4013
4014 --------------------------------------------------------------------------*/
4015void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4016 tANI_U32 nFrameLength,
4017 tANI_U8* pbFrames,
4018 tANI_U8 frameType )
4019{
4020 tANI_U8 type = 0;
4021 tANI_U8 subType = 0;
4022
4023 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4024 __func__, frameType, nFrameLength);
4025
4026 /* Sanity Checks */
4027 if (NULL == pAdapter)
4028 {
4029 hddLog( LOGE, FL("pAdapter is NULL"));
4030 return;
4031 }
4032
4033 if (NULL == pAdapter->dev)
4034 {
4035 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4036 return;
4037 }
4038
4039 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4040 {
4041 hddLog( LOGE, FL("pAdapter has invalid magic"));
4042 return;
4043 }
4044
4045 if( !nFrameLength )
4046 {
4047 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4048 return;
4049 }
4050
4051 if (NULL == pbFrames) {
4052 hddLog( LOGE, FL("pbFrames is NULL"));
4053 return;
4054 }
4055
4056 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4057 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4058
4059 /* Get pAdapter from Destination mac address of the frame */
4060 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
4061 {
4062 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
4063 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4064 }
4065 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
4066 {
4067 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
4068 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4069 }
4070 else
4071 {
4072 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
4073 return;
4074 }
4075}
4076#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004077
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004078#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004079void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
4080 tANI_U8 state,
4081 tANI_U16 measInterval )
4082{
4083 union iwreq_data wrqu;
4084 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004085 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004086
4087 if (NULL == pAdapter)
4088 return;
4089
4090 // create the event
4091 memset(&wrqu, '\0', sizeof(wrqu));
4092 memset(buf, '\0', sizeof(buf));
4093
4094 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
4095 tid, state, measInterval);
4096
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004097 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004098
4099 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004100 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004101 // send the event
4102 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4103}
4104
4105void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4106{
4107 union iwreq_data wrqu;
4108 char buf[IW_CUSTOM_MAX + 1];
4109 char *pos = buf;
4110 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4111
4112 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4113 return;
4114
4115 // create the event
4116 memset(&wrqu, '\0', sizeof(wrqu));
4117 memset(buf, '\0', sizeof(buf));
4118
4119 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304120 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
4121 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
4122 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
4123 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004124
4125 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4126 pos += nBytes;
4127 freeBytes -= nBytes;
4128
4129 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
4130 pos += WNI_CFG_BSSID_LEN;
4131 freeBytes -= WNI_CFG_BSSID_LEN;
4132
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004133 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4134 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004135
4136 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004137 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004138
4139 // send the event
4140 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4141}
4142
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004143void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004144{
4145 union iwreq_data wrqu;
4146 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004147 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004148
4149 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4150 return;
4151
4152 // create the event
4153 memset(&wrqu, '\0', sizeof(wrqu));
4154 memset(buf, '\0', sizeof(buf));
4155
4156 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
4157
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004158 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004159
4160 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004161 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004162
4163 // send the event
4164 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4165}
4166
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004167void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
4168 const tANI_U16 measurementToken,
4169 const tANI_BOOLEAN flag,
4170 const tANI_U8 numBss)
4171{
4172 union iwreq_data wrqu;
4173 char buf[IW_CUSTOM_MAX];
4174 char *pos = buf;
4175 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4176
4177 memset(&wrqu, '\0', sizeof(wrqu));
4178 memset(buf, '\0', sizeof(buf));
4179
4180 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
4181 numBss);
4182
4183 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4184 flag, numBss);
4185
4186 wrqu.data.pointer = buf;
4187 wrqu.data.length = nBytes;
4188 // send the event
4189 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4190}
4191
4192
4193static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004194 const tCsrRoamInfo *pRoamInfo)
4195{
4196 union iwreq_data wrqu;
4197 char buf[IW_CUSTOM_MAX + 1];
4198 char *pos = buf;
4199 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4200 tANI_U8 i = 0, len = 0;
4201 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
4202 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004203 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
4204 tANI_U8 ieLenByte = 1;
4205 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
4206#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004207
4208 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4209 return;
4210
4211 /* Custom event can pass maximum of 256 bytes of data,
4212 based on the IE len we need to identify how many BSS info can
4213 be filled in to custom event data */
4214 /*
4215 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4216 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4217 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4218 */
4219
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004220 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004221 {
4222 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
4223 /* If the measurement is none and no scan results found,
4224 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004225 hdd_indicateEseBcnReportNoResults(pAdapter,
4226 pRoamInfo->pEseBcnReportRsp->measurementToken,
4227 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004228 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004229 }
4230 else
4231 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004232 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004233 {
4234 memset(&wrqu, '\0', sizeof(wrqu));
4235 memset(buf, '\0', sizeof(buf));
4236 tot_bcn_ieLen = 0;
4237 sendBss = 0;
4238 pos = buf;
4239 freeBytes = IW_CUSTOM_MAX;
4240
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004241 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004242 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004243 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
4244 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004245 {
4246 break;
4247 }
4248 tot_bcn_ieLen += len;
4249 sendBss++;
4250 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
4251 "IeLength(%d) Length of Ie(%d) totLen(%d)",
4252 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004253 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004254 tot_bcn_ieLen);
4255 }
4256
4257 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
4258 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004259 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4260 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004261
4262 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004263 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4264 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004265 pos += nBytes;
4266 freeBytes -= nBytes;
4267
4268 /* Copy total Beacon report data length */
4269 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
4270 pos += sizeof(tot_bcn_ieLen);
4271 freeBytes -= sizeof(tot_bcn_ieLen);
4272
4273 for (i = 0; i < sendBss; i++)
4274 {
4275 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304276 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4277 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004278 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004279 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
4280 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
4281 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
4282 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
4283 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
4284 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
4285 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
4286 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
4287 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
4288 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
4289 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
4290 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
4291 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
4292 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
4293 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
4294 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004295
4296 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004297 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
4298 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004299 pos += len;
4300 freeBytes -= len;
4301
4302 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004303 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004304 vos_mem_copy(pos, (char*)&len, sizeof(len));
4305 pos += sizeof(len);
4306 freeBytes -= sizeof(len);
4307
4308 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004309 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004310 pos += len;
4311 freeBytes -= len;
4312 }
4313
4314 wrqu.data.pointer = buf;
4315 wrqu.data.length = strlen(buf);
4316
4317 // send the event
4318 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4319 lastSent += sendBss;
4320 }
4321 }
4322}
4323
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004324#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004325