blob: 5761208ced8c93b37bf61886d847cf8706ce1e84 [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
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301260 /* Check for STAID */
1261 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1262 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1263 else
1264 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001265
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001266#ifdef FEATURE_WLAN_TDLS
1267 wlan_hdd_tdls_connection_callback(pAdapter);
1268#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001269 //For reassoc, the station is already registered, all we need is to change the state
1270 //of the STA in TL.
1271 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
1272 if( !pRoamInfo->fReassocReq )
1273 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001274 struct cfg80211_bss *bss;
1275#ifdef WLAN_FEATURE_VOWIFI_11R
1276 u8 *pFTAssocRsp = NULL;
1277 unsigned int assocRsplen = 0;
1278 u8 *pFTAssocReq = NULL;
1279 unsigned int assocReqlen = 0;
1280 struct ieee80211_channel *chan;
1281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001283 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001284
1285 /* add bss_id to cfg80211 data base */
1286 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1287 if (NULL == bss)
1288 {
1289 pr_err("wlan: Not able to create BSS entry\n");
1290 return eHAL_STATUS_FAILURE;
1291 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001292#ifdef WLAN_FEATURE_VOWIFI_11R
1293 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001294 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001296
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001297 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001298 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001299 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001300 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001301 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001302 // pFTAssocRsp needs to point to the IEs
1303 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1304 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1305 (unsigned int)pFTAssocRsp[0],
1306 (unsigned int)pFTAssocRsp[1]);
1307 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001308 }
1309 else
1310 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001311 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1312 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001313 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001314
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001315 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001316 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001317 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001318 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001319 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001320 if(!ft_carrier_on)
1321 {
1322 // pFTAssocReq needs to point to the IEs
1323 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1324 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1325 (unsigned int)pFTAssocReq[0],
1326 (unsigned int)pFTAssocReq[1]);
1327 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1328 }
1329 else
1330 {
1331 /* This should contain only the FTIEs */
1332 assocReqlen = pRoamInfo->nAssocReqLength;
1333 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001334 }
1335 else
1336 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001337 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1338 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001339 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001340
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001341 if(ft_carrier_on)
1342 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001343 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001344 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001345 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1346 (int)pRoamInfo->pBssDesc->channelId);
Arif Hussain6d2a3322013-11-17 19:50:10 -08001347 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001348 assocRsplen);
1349 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
1350 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1351 GFP_KERNEL);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301352 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1353 {
1354 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1355 pRoamInfo->fAuthRequired = FALSE;
1356
1357 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1358 pRoamInfo->bssid,
1359 HDD_MAC_ADDR_LEN);
1360 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1361 pRoamInfo->peerMac,
1362 HDD_MAC_ADDR_LEN);
1363 pHddStaCtx->roam_info.roamId = roamId;
1364 pHddStaCtx->roam_info.roamStatus = roamStatus;
1365 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1366 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001367 }
1368 else
1369 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001370 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001371 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001372 cfg80211_connect_result(dev, pRoamInfo->bssid,
1373 pFTAssocReq, assocReqlen,
1374 pFTAssocRsp, assocRsplen,
1375 WLAN_STATUS_SUCCESS,
1376 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001377 }
1378 }
1379 else
1380#endif
1381 {
1382 /* wpa supplicant expecting WPA/RSN IE in connect result */
1383 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1384 pAdapter->sessionId,
1385 &reqRsnLength,
1386 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001387
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001388 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1389 pAdapter->sessionId,
1390 &rspRsnLength,
1391 rspRsnIe);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001392#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001393 if(ft_carrier_on)
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001394 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001395 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001396#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001397
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001398 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301399 hddLog(VOS_TRACE_LEVEL_INFO,
1400 "%s: sending connect indication to nl80211:"
1401 " for bssid " MAC_ADDRESS_STR
1402 " reason:%d and Status:%d\n",
1403 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1404 roamResult, roamStatus);
1405
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001406 /* inform connect result to nl80211 */
1407 cfg80211_connect_result(dev, pRoamInfo->bssid,
1408 reqRsnIe, reqRsnLength,
1409 rspRsnIe, rspRsnLength,
1410 WLAN_STATUS_SUCCESS,
1411 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 }
Yue Maf49ba872013-08-19 12:04:25 -07001414 cfg80211_put_bss(
1415#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1416 pHddCtx->wiphy,
1417#endif
1418 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001419 // Register the Station with TL after associated...
1420 vosStatus = hdd_roamRegisterSTA( pAdapter,
1421 pRoamInfo,
1422 pHddStaCtx->conn_info.staId[ 0 ],
1423 NULL,
1424 pRoamInfo->pBssDesc );
1425 }
1426 else
1427 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001428 /* wpa supplicant expecting WPA/RSN IE in connect result */
1429 /* in case of reassociation also need to indicate it to supplicant */
1430 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1431 pAdapter->sessionId,
1432 &reqRsnLength,
1433 reqRsnIe);
1434
1435 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301437 if( pRoamInfo->fAuthRequired )
1438 {
1439 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1440 pHddStaCtx->conn_info.staId[ 0 ],
1441 WLANTL_STA_CONNECTED );
1442 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1443 }
1444 else
1445 {
1446 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1447 "%s: staId: %d Changing TL state to AUTHENTICATED",
1448 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1449 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1450 pHddStaCtx->conn_info.staId[ 0 ],
1451 WLANTL_STA_AUTHENTICATED );
1452 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001454 }
1455
1456 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1457 {
1458 // perform any WMM-related association processing
1459 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1460 }
1461 else
1462 {
1463 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001464 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001465 vosStatus, vosStatus );
1466 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001467#ifdef WLAN_FEATURE_11W
1468 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1469 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1470#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 // Start the Queue
1472 netif_tx_wake_all_queues(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001473 }
1474 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1477
1478 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001479 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001480 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1481 " reason:%d and Status:%d\n",
1482 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1483 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001484 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001485 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1486 " reason:%d and Status:%d\n",
1487 MAC_ADDR_ARRAY(pWextState->req_bssId),
1488 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001489
Abhishek Singhf4669da2014-05-26 15:07:49 +05301490 /* Set connection state to eConnectionState_NotConnected only when CSR
1491 * has completed operation - with a ASSOCIATION_FAILURE status
1492 */
1493 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus )
1494 {
1495 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1496 "%s: Set HDD connState to eConnectionState_NotConnected",
1497 __func__);
1498 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001500 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
1501 {
1502 pHddCtx->isAmpAllowed = VOS_TRUE;
1503 }
1504
1505 //If the Device Mode is Station
1506 // and the P2P Client is Connected
1507 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001508
1509 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001510 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001511 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1512 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 (vos_concurrent_sessions_running()))
1514 {
1515 //Enable BMPS only of other Session is P2P Client
1516 hdd_context_t *pHddCtx = NULL;
1517 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1518
1519 if (NULL != pVosContext)
1520 {
1521 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1522
1523 if(NULL != pHddCtx)
1524 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301525 //Only P2P Client is there Enable Bmps back
1526 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
1527 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
1528 {
1529 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001530 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301531 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001532 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301533 hdd_enable_bmps_imps(pHddCtx);
1534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 }
1536 }
1537 }
1538
James Zmudafbf5ffc2013-03-25 12:45:35 -07001539 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001540 * completed operation - with a ASSOCIATION_FAILURE status.*/
1541 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus )
Jeff Johnsone7245742012-09-05 17:12:55 -07001542 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301543 if (pRoamInfo)
1544 hddLog(VOS_TRACE_LEVEL_ERROR,
1545 "%s: send connect failure to nl80211:"
1546 " for bssid " MAC_ADDRESS_STR
1547 " reason:%d and Status:%d\n" ,
1548 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1549 roamResult, roamStatus);
1550 else
1551 hddLog(VOS_TRACE_LEVEL_ERROR,
1552 "%s: connect failed:"
1553 " for bssid " MAC_ADDRESS_STR
1554 " reason:%d and Status:%d\n" ,
1555 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1556 roamResult, roamStatus);
1557
James Zmudafbf5ffc2013-03-25 12:45:35 -07001558 /* inform association failure event to nl80211 */
1559 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1560 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001561 if (pRoamInfo)
1562 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1563 NULL, 0, NULL, 0,
1564 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1565 GFP_KERNEL );
1566 else
1567 cfg80211_connect_result ( dev, pWextState->req_bssId,
1568 NULL, 0, NULL, 0,
1569 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1570 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001571 }
1572 else
1573 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001574 if (pRoamInfo)
1575 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1576 NULL, 0, NULL, 0,
1577 WLAN_STATUS_UNSPECIFIED_FAILURE,
1578 GFP_KERNEL );
1579 else
1580 cfg80211_connect_result ( dev, pWextState->req_bssId,
1581 NULL, 0, NULL, 0,
1582 WLAN_STATUS_UNSPECIFIED_FAILURE,
1583 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001584 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001585 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001586
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001587 /*Clear the roam profile*/
1588 hdd_clearRoamProfileIe( pAdapter );
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -07001589 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
1590 {
1591 hdd_wmm_init( pHddCtx, hddWmmDscpToUpMapInfra );
1592 }
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001593
c_hpothu24f40982014-04-18 18:00:36 +05301594 if (pRoamInfo)
1595 {
1596 WLANTL_AssocFailed(pRoamInfo->staId);
1597 }
Mihir Sheteb7337272014-04-11 15:53:08 +05301598
Jeff Johnson295189b2012-06-20 16:38:30 -07001599 netif_tx_disable(dev);
1600 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001601
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 }
1603
1604 return eHAL_STATUS_SUCCESS;
1605}
1606
1607/**============================================================================
1608 *
Jeff Johnson81c17882013-05-03 09:53:35 -07001609 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07001611
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07001613static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
1614 tCsrRoamInfo *pRoamInfo,
1615 tANI_U32 roamId,
1616 eRoamCmdStatus roamStatus,
1617 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07001618{
Jeff Johnson81c17882013-05-03 09:53:35 -07001619 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
1620 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
1621
Jeff Johnson295189b2012-06-20 16:38:30 -07001622 switch( roamResult )
1623 {
1624 // both IBSS Started and IBSS Join should come in here.
1625 case eCSR_ROAM_RESULT_IBSS_STARTED:
1626 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001627 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07001628 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001629 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1630 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001631
Jeff Johnson81c17882013-05-03 09:53:35 -07001632 if (NULL == pRoamInfo)
1633 {
1634 VOS_ASSERT(0);
1635 return;
1636 }
1637
1638 /* When IBSS Started comes from CSR, we need to move
1639 * connection state to IBSS Disconnected (meaning no peers
1640 * are in the IBSS).
1641 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05301642 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1643 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
1644 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07001645 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
1646 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05301647 /*notify wmm */
1648 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001649 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1650 hdd_roamRegisterSTA (pAdapter, pRoamInfo,
1651 IBSS_BROADCAST_STAID,
1652 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001653
Jeff Johnson81c17882013-05-03 09:53:35 -07001654 if (pRoamInfo->pBssDesc)
1655 {
1656 struct cfg80211_bss *bss;
1657
1658 /* we created the IBSS, notify supplicant */
1659 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
1660 MAC_ADDRESS_STR,
1661 __func__, pAdapter->dev->name,
1662 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
1663
1664 /* we must first give cfg80211 the BSS information */
1665 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1666 if (NULL == bss)
1667 {
1668 hddLog(VOS_TRACE_LEVEL_ERROR,
1669 "%s: %s: unable to create IBSS entry",
1670 __func__, pAdapter->dev->name);
1671 return;
1672 }
1673
1674 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001675 cfg80211_put_bss(
1676#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1677 pHddCtx->wiphy,
1678#endif
1679 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07001680 }
1681
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 break;
1683 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001684
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1686 {
Jeff Johnson81c17882013-05-03 09:53:35 -07001687 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
1688 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07001689 break;
1690 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001691
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07001693 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
1694 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001696 }
1697
Jeff Johnson81c17882013-05-03 09:53:35 -07001698 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001699}
1700
1701/**============================================================================
1702 *
1703 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1704 This information is passed to iwconfig later. The peer that joined
1705 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001706 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001707 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001708
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 ===========================================================================*/
1710static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1711{
1712 int fSuccess = FALSE;
1713 int idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001714
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1716 {
1717 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1718 {
1719 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001720
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001722
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 fSuccess = TRUE;
1724 break;
1725 }
1726 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001727
1728 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07001729}
1730/**============================================================================
1731 *
1732 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001733 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001735
Jeff Johnson295189b2012-06-20 16:38:30 -07001736 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07001737static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07001738{
1739 int fSuccess = FALSE;
1740 int idx = 0;
1741 v_U8_t valid_idx = 0;
1742 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07001743 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001744 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001745
Jeff Johnson295189b2012-06-20 16:38:30 -07001746 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1747 {
1748 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1749 {
1750 pHddStaCtx->conn_info.staId[ idx ] = 0;
1751
1752 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1753
1754 fSuccess = TRUE;
Ravi Joshi8a934352013-09-25 16:46:58 -07001755
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 // Note the deleted Index, if its 0 we need special handling
1757 del_idx = idx;
Ravi Joshi8a934352013-09-25 16:46:58 -07001758
1759 empty_slots++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 }
1761 else
1762 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001763 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 {
1765 valid_idx = idx;
1766 }
Ravi Joshi8a934352013-09-25 16:46:58 -07001767 else
1768 {
1769 // Found an empty slot
1770 empty_slots++;
1771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 }
1773 }
1774
Ravi Joshi8a934352013-09-25 16:46:58 -07001775 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
1776 {
1777 // Last peer departed, set the IBSS state appropriately
1778 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001779 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07001780 "Last IBSS Peer Departed!!!" );
1781 }
1782
Jeff Johnson295189b2012-06-20 16:38:30 -07001783 // Find next active staId, to have a valid sta trigger for TL.
1784 if (fSuccess == TRUE)
1785 {
1786 if (del_idx == 0)
1787 {
1788 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1789 {
1790 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1791 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1792 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1793
1794 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1795 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1796 }
1797 }
1798 }
1799 return( fSuccess );
1800}
1801
1802/**============================================================================
1803 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001804 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001806
Jeff Johnson295189b2012-06-20 16:38:30 -07001807 ===========================================================================*/
1808static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1809{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001810 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05301811 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1812 "%s: IBSS Connect Indication from SME!!! "
1813 "Set HDD connState to eConnectionState_IbssConnected",
1814 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001815 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1816 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1817
1818 // Save the connection info from CSR...
1819 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1820
1821 // Send the bssid address to the wext.
1822 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001823 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001824 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1825 if (NULL == bss)
1826 {
1827 hddLog(VOS_TRACE_LEVEL_ERROR,
1828 "%s: %s: unable to create IBSS entry",
1829 __func__, pAdapter->dev->name);
1830 return eHAL_STATUS_FAILURE;
1831 }
Yue Maf49ba872013-08-19 12:04:25 -07001832 cfg80211_put_bss(
1833#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1834 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
1835#endif
1836 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001837
1838 return( eHAL_STATUS_SUCCESS );
1839}
1840/**============================================================================
1841 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05301842 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
1843 suspend related data which was cleared during roaming in FWR.
1844
1845 ===========================================================================*/
1846static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
1847{
1848 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
1849 hdd_adapter_t *pAdapter;
1850 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
1851 ENTER();
1852
1853 spin_lock(&pHddCtx->filter_lock);
1854 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
1855 {
1856 pHddCtx->sus_res_mcastbcast_filter =
1857 pHddCtx->configuredMcastBcastFilter;
1858 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
1859 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
1860 hddLog(VOS_TRACE_LEVEL_INFO,
1861 FL("saving configuredMcastBcastFilter = %d"),
1862 pHddCtx->configuredMcastBcastFilter);
1863 hddLog(VOS_TRACE_LEVEL_INFO,
1864 FL("offload: calling hdd_conf_mcastbcast_filter"));
1865 }
1866 spin_unlock(&pHddCtx->filter_lock);
1867
1868 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
1869 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
1870 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
1871
1872 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
1873 //No need to configure GTK Offload from here because it might possible
1874 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
1875 //be handled as part of cfg80211_set_rekey_data processing.
1876 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
1877 {
1878 pAdapter = pAdapterNode->pAdapter;
1879 if( pAdapter &&
1880 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1881 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
1882 {
1883 if (pHddCtx->cfg_ini->fhostArpOffload)
1884 {
1885 //Configure ARPOFFLOAD
1886 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
1887 if (!VOS_IS_STATUS_SUCCESS(vstatus))
1888 {
1889 hddLog(VOS_TRACE_LEVEL_ERROR,
1890 FL("Failed to disable ARPOffload Feature %d"), vstatus);
1891 }
1892 }
1893#ifdef WLAN_NS_OFFLOAD
1894 //Configure NSOFFLOAD
1895 if (pHddCtx->cfg_ini->fhostNSOffload)
1896 {
1897 hdd_conf_ns_offload(pAdapter, TRUE);
1898 }
1899#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05301900#ifdef WLAN_FEATURE_PACKET_FILTERING
1901 /* During suspend, configure MC Addr list filter to the firmware
1902 * function takes care of checking necessary conditions before
1903 * configuring.
1904 */
1905 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
1906#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05301907 }
1908 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
1909 pAdapterNode = pNext;
1910 }
1911 EXIT();
1912}
1913
1914/**============================================================================
1915 *
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001917
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001919static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1920 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 eCsrRoamResult roamResult )
1922{
1923 eCsrEncryptionType connectedCipherAlgo;
1924 v_BOOL_t fConnected = FALSE;
1925 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1926 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1927 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1928 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07001929
1930 if (NULL == pRoamInfo)
1931 {
1932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
1933 return eHAL_STATUS_FAILURE;
1934 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001935 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001936 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 // not require upper layer authentication) we can put TL directly into 'authenticated'
1938 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1940 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
1941 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001942
Jeff Johnson295189b2012-06-20 16:38:30 -07001943 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1944 if( fConnected )
1945 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001946 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
1947 {
1948 v_U8_t staId;
1949
1950 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
1951
1952 if ( 0 == memcmp( pRoamInfo->peerMac,
1953 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
1954 {
1955 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1956 IBSS_BROADCAST_STAID);
1957 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1958 }
1959 else
1960 {
1961 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
1962 (v_MACADDR_t*)pRoamInfo->peerMac,
1963 &staId);
1964 if ( VOS_STATUS_SUCCESS == vosStatus )
1965 {
1966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1967 "WLAN TL STA Ptk Installed for STAID=%d", staId);
1968 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1969 staId);
1970 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1971 }
1972 }
1973 }
1974 else
1975 {
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301976 // TODO: Considering getting a state machine in HDD later.
1977 // This routine is invoked twice. 1)set PTK 2)set GTK.
1978 // The folloing if statement will be TRUE when setting GTK.
1979 // At this time we don't handle the state in detail.
1980 // Related CR: 174048 - TL not in authenticated state
1981 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
1982 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
1983 {
1984 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
1985 "for StaId= %d. Changing TL state to AUTHENTICATED",
1986 pHddStaCtx->conn_info.staId[ 0 ] );
1987
1988 // Connections that do not need Upper layer authentication,
1989 // transition TL to 'Authenticated' state after the keys are set.
1990 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1991 pHddStaCtx->conn_info.staId[ 0 ],
1992 WLANTL_STA_AUTHENTICATED );
1993
1994 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Mukul Sharmad2589a52014-04-23 21:06:25 +05301995 //Need to call offload because when roaming happen at that time fwr
1996 //clean offload info as part of the DelBss
1997 // No need to configure offload if host was not suspended
1998 spin_lock(&pHddCtx->filter_lock);
1999 if(pHddCtx->hdd_wlan_suspended)
2000 {
2001 spin_unlock(&pHddCtx->filter_lock);
2002 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2003 }
2004 else
2005 {
2006 spin_unlock(&pHddCtx->filter_lock);
2007 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302008 }
2009 else
2010 {
2011 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2012 pHddStaCtx->conn_info.staId[ 0 ]);
2013 }
2014
2015 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002016 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302018 else
2019 {
2020 // possible disassoc after issuing set key and waiting set key complete
2021 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2022 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002023
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 EXIT();
2025 return( eHAL_STATUS_SUCCESS );
2026}
2027/**============================================================================
2028 *
2029 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2030 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002031static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002032 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002033{
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2035
2036 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2037 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2038 {
2039 struct iw_michaelmicfailure msg;
2040 union iwreq_data wreq;
2041 memset(&msg, '\0', sizeof(msg));
2042 msg.src_addr.sa_family = ARPHRD_ETHER;
2043 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002044 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2045 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002046
Jeff Johnson295189b2012-06-20 16:38:30 -07002047 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2048 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002049 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002050 msg.flags = IW_MICFAILURE_PAIRWISE;
2051 memset(&wreq, 0, sizeof(wreq));
2052 wreq.data.length = sizeof(msg);
2053 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002055 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2057 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2058 NL80211_KEYTYPE_GROUP :
2059 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002060 pRoamInfo->u.pMICFailureInfo->keyId,
2061 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002062 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002063
Jeff Johnson295189b2012-06-20 16:38:30 -07002064 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002065
Jeff Johnson295189b2012-06-20 16:38:30 -07002066 return( eHAL_STATUS_SUCCESS );
2067}
2068
2069/**============================================================================
2070 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002071 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002073
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002075static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2076 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 eCsrRoamResult roamResult )
2078{
2079 VOS_STATUS vosStatus;
2080
2081 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2082 switch( roamResult )
2083 {
2084 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2085 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002086 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002087 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002088
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002089 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002090 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2091 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2092 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002094
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
2096 {
2097 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2098 "New IBSS peer but we already have the max we can handle. Can't register this one" );
2099 break;
2100 }
2101
2102 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2103
Shailender Karmuchia734f332013-04-19 14:02:48 -07002104 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2105 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2106 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2107
2108 // Register the Station with TL for the new peer.
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 vosStatus = hdd_roamRegisterSTA( pAdapter,
2110 pRoamInfo,
2111 pRoamInfo->staId,
2112 (v_MACADDR_t *)pRoamInfo->peerMac,
2113 pRoamInfo->pBssDesc );
2114 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2115 {
2116 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002117 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 vosStatus, vosStatus );
2119 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002120 pHddStaCtx->ibss_sta_generation++;
2121 memset(&staInfo, 0, sizeof(staInfo));
2122 staInfo.filled = 0;
2123 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2124
2125 cfg80211_new_sta(pAdapter->dev,
2126 (const u8 *)pRoamInfo->peerMac,
2127 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002128
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002129 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2130 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2131 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2132 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2133 {
2134 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2135 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2136 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2137
2138 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002139 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002140 pHddStaCtx->ibss_enc_key.encType);
2141
2142 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2143 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2144
2145 if ( VOS_STATUS_SUCCESS != vosStatus )
2146 {
2147 hddLog(VOS_TRACE_LEVEL_ERROR,
2148 "%s: sme_RoamSetKey failed, returned %d",
2149 __func__, vosStatus);
2150 return VOS_STATUS_E_FAILURE;
2151 }
2152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002153 netif_carrier_on(pAdapter->dev);
2154 netif_tx_start_all_queues(pAdapter->dev);
2155 break;
2156 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002157
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2159 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002160
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002162
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002164 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2166 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002167 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002168
Ravi Joshicc57ed42013-10-12 16:31:25 -07002169 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 {
2171 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2172 "IBSS peer departed by cannot find peer in our registration table with TL" );
2173 }
2174
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002175 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002176 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2177 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2178 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2179 pRoamInfo->staId );
2180
Jeff Johnson295189b2012-06-20 16:38:30 -07002181 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
2182
2183 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002184 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002185
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002186 cfg80211_del_sta(pAdapter->dev,
2187 (const u8 *)&pRoamInfo->peerMac,
2188 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 break;
2190 }
2191 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2192 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002193 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2194 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 // Stop only when we are inactive
2196 netif_tx_disable(pAdapter->dev);
2197 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302198 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2199 "%s: Set HDD connState to eConnectionState_NotConnected",
2200 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002202
Jeff Johnson295189b2012-06-20 16:38:30 -07002203 // Send the bssid address to the wext.
2204 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2205 // clean up data path
2206 hdd_disconnect_tx_rx(pAdapter);
2207 break;
2208 }
2209 default:
2210 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002211
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002213
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 return( eHAL_STATUS_SUCCESS );
2215}
2216
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002217#ifdef FEATURE_WLAN_TDLS
2218/**============================================================================
2219 *
2220 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2221 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2222 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002223
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002224 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002225VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2226 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002227{
2228 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002229 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002230 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2231 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002232 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2233 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002234 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2235 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002236
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002237 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2238 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002239 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002240 "%s not connected. ignored", __func__);
2241 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002242 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002243
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002244 /*
2245 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2246 * be peer MAC, here we are wokrking on direct Link
2247 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002248 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002249
2250 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002251
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002252 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002253 sizeof(tSirMacAddr) );
2254
2255 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2256 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2257
2258 /* set the QoS field appropriately ..*/
2259 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2260 : (staDesc.ucQosEnabled = 0) ;
2261
2262 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002263 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002264
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002265 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002266
2267 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002268 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002269
Shailender Karmuchia734f332013-04-19 14:02:48 -07002270 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002271 * UMA is ready we inform TL to do frame translation.
2272 */
2273 staDesc.ucSwFrameTXXlation = 1;
2274 staDesc.ucSwFrameRXXlation = 1;
2275 staDesc.ucAddRmvLLC = 1;
2276
2277 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002278 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002279
2280 /* tdls Direct Link do not need bcastSig */
2281 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002282
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002283#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2284 if(staDesc.ucProtectedFrame)
2285 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2286 else
2287 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2288#endif
2289
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302290 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002291
Shailender Karmuchia734f332013-04-19 14:02:48 -07002292 /* Register the Station with TL... */
2293 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2294 hdd_rx_packet_cbk,
2295 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002296 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002297
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002298 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2299 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002300 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002301 "%s: WLANTL_RegisterSTAClient() failed to register. "
2302 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002303 return vosStatus;
2304 }
2305
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002306 if ( cfg_param->dynSplitscan &&
2307 ( VOS_TIMER_STATE_RUNNING !=
2308 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2309 {
2310 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2311 cfg_param->trafficMntrTmrForSplitScan);
2312 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002313 return( vosStatus );
2314}
2315
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002316static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
2317{
2318 VOS_STATUS vosStatus;
2319 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2320 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2321 {
2322 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2323 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002324 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002325 __func__, staId, vosStatus, vosStatus );
2326 }
2327 return( vosStatus );
2328}
2329
2330
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002331/*
2332 * HDD interface between SME and TL to ensure TDLS client registration with
2333 * TL in case of new TDLS client is added and deregistration at the time
2334 * TDLS client is deleted.
2335 */
2336
Shailender Karmuchia734f332013-04-19 14:02:48 -07002337eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2338 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002339 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002340 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002341 eCsrRoamResult roamResult)
2342{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002343 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002344 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002345 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002346
2347#ifdef WLAN_FEATURE_TDLS_DEBUG
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002349 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2350 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2351 "ADD_TDLS_PEER" :
2352 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2353 "DEL_TDLS_PEER" :
2354 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2355 "DEL_TDLS_PEER_IND" :
2356 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2357 "DEL_ALL_TDLS_PEER_IND" :
2358 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2359 "UPDATE_TDLS_PEER" :
2360 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2361 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2362 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002363#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002364 switch( roamResult )
2365 {
2366 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2367 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002368 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2369 {
2370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002371 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002372 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002373 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002374 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002375
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002376 /* check if there is available index for this new TDLS STA */
2377 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2378 {
2379 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2380 {
2381 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2382 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2383
2384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002385 ("TDLS: STA IDX at %d is %d "
2386 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002387 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002388 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002389
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002390 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002391 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2392 status = eHAL_STATUS_SUCCESS ;
2393 break ;
2394 }
2395 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002396 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002397 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002398 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002399 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2400 "wlan_hdd_tdls_set_sta_id() failed");
2401 return VOS_FALSE;
2402 }
2403
2404 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302405 /* store the ucast signature , if required for further reference. */
2406
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002407 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302408 /* start TDLS client registration with TL */
2409 status = hdd_roamRegisterTDLSSTA( pAdapter,
2410 pRoamInfo->peerMac,
2411 pRoamInfo->staId,
2412 pRoamInfo->ucastSig);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002413 }
2414 else
2415 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002416 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002418 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002419 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002420 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002421 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002422 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002423 break ;
2424 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002425 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2426 {
2427 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2428 {
2429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2430 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2431 }
2432 /* store the ucast signature which will be used later when
2433 * registering to TL
2434 */
2435 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2436 complete(&pAdapter->tdls_add_station_comp);
2437 break;
2438 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302439 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
2440 {
2441 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2442 {
2443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2444 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
2445 }
2446 complete(&pAdapter->tdls_link_establish_req_comp);
2447 break;
2448 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002449 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002450 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002451 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002452 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002453 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002454 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2455 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002456 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002458 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2459
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302460 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002461 if (NULL != curr_peer && TDLS_IS_CONNECTED(curr_peer))
2462 {
2463 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2464 wlan_hdd_tdls_decrement_peer_count(pAdapter);
2465 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002466 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002467
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002468 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2469 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2470 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002471 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002472 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002473 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002474 break ;
2475 }
2476 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002477 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002478 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002479 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002480 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2481 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002482 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002483 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2484 "%s: Sending teardown to supplicant with reason code %u",
2485 __func__, pRoamInfo->reasonCode);
2486
2487#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302488 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002489 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002490#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002491 status = eHAL_STATUS_SUCCESS ;
2492 break ;
2493 }
2494 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2495 {
2496 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002497 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002498 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002499 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2500 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002501 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002503 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002504 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002505 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002506 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2507 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2508 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002509
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002510 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002511 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002512 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2513 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002514
2515 status = eHAL_STATUS_SUCCESS ;
2516 }
2517 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05302518 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002519 break ;
2520 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002521 default:
2522 {
2523 break ;
2524 }
2525 }
2526
2527 return status ;
2528}
2529#endif
2530
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002531static void iw_full_power_cbfn (void *pContext, eHalStatus status)
2532{
2533 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
2534 hdd_context_t *pHddCtx = NULL;
2535 int ret;
2536
2537 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
2538 {
2539 hddLog(VOS_TRACE_LEVEL_ERROR,
2540 "%s: Bad param, pAdapter [%p]",
2541 __func__, pAdapter);
2542 return;
2543 }
2544
2545 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2546 ret = wlan_hdd_validate_context(pHddCtx);
2547 if (0 != ret)
2548 {
2549 hddLog(VOS_TRACE_LEVEL_ERROR,
2550 "%s: HDD context is not valid (%d)", __func__, ret);
2551 return;
2552 }
2553
2554 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2555 {
2556 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
2557 }
2558}
2559
Shailender Karmuchia734f332013-04-19 14:02:48 -07002560eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2562{
2563 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2564 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302565 hdd_wext_state_t *pWextState = NULL;
2566 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002567 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07002568 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002569
2570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002571 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002572 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002573
2574 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302575 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002576 {
2577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302578 "invalid adapter or adapter has invalid magic");
2579 return eHAL_STATUS_FAILURE;
2580 }
2581
2582 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2583 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2584
2585 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2586 {
2587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2588 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002589 return eHAL_STATUS_FAILURE;
2590 }
2591
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 switch( roamStatus )
2593 {
2594 case eCSR_ROAM_SESSION_OPENED:
2595 if(pAdapter != NULL)
2596 {
2597 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2598 complete(&pAdapter->session_open_comp_var);
2599 }
2600 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002601
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002602#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
2603 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07002605 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 * interface down */
2607 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05302608 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
2609 roamStatus, roamResult, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2611 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2612 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002613 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2614 }
2615 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302616 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 break;
2618
2619 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002620 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07002622 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 // eCSR_ROAM_SHOULD_ROAM will be received.
2624 // Where in we will not mark the link down
2625 // Also we want to stop tx at this point when we will be
2626 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002627 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002628 {
2629 struct net_device *dev = pAdapter->dev;
2630 netif_tx_disable(dev);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002631 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002632 * Deregister for this STA with TL with the objective to flush
2633 * all the packets for this STA from wmm_tx_queue. If not done here,
2634 * we would run into a race condition (CR390567) wherein TX
2635 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2636 * been deleted. And, these packets get assigned with a STA idx of
2637 * self-sta (since the peer STA has been deleted) and get transmitted
2638 * on the new channel before the reassoc request. Since there will be
2639 * no ACK on the new channel, each packet gets retransmitted which
2640 * takes several seconds before the transmission of reassoc request.
2641 * This leads to reassoc-timeout and roam failure.
2642 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002643 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2644 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2645 {
2646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2647 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2648 pHddStaCtx->conn_info.staId[0], status, status );
2649 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002650 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 }
2652 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002653 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002654 break;
2655#endif
2656
2657 case eCSR_ROAM_SHOULD_ROAM:
2658 // Dont need to do anything
2659 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 struct net_device *dev = pAdapter->dev;
2661 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2662 // notify apps that we can't pass traffic anymore
2663 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002664#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 if (pHddStaCtx->ft_carrier_on == FALSE)
2666 {
2667#endif
2668 netif_carrier_off(dev);
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 }
2671#endif
2672
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002673#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 //We should clear all sta register with TL, for now, only one.
2675 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2676 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2677 {
2678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2679 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2680 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002681 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002682 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002683#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 }
2685 break;
2686 case eCSR_ROAM_LOSTLINK:
2687 case eCSR_ROAM_DISASSOCIATED:
2688 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2690 "****eCSR_ROAM_DISASSOCIATED****");
2691 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2692 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07002693 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2694 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302695 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07002696 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08002697
2698 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
2699 pHddCtx->configuredMcastBcastFilter =
2700 pHddCtx->sus_res_mcastbcast_filter;
2701 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
2702 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302703
Amar Singhald53568e2013-09-26 11:03:45 -07002704 hddLog(VOS_TRACE_LEVEL_INFO,
2705 "offload: disassociation happening, restoring configuredMcastBcastFilter");
2706 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
2707 pHddCtx->configuredMcastBcastFilter);
2708 hddLog(VOS_TRACE_LEVEL_INFO,
2709 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07002710 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2711 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002712#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302713 /* Call to clear any MC Addr List filter applied after
2714 * successful connection.
2715 */
2716 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002717#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 }
2719 break;
2720 case eCSR_ROAM_IBSS_LEAVE:
2721 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2722 "****eCSR_ROAM_IBSS_LEAVE****");
2723 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2724 break;
2725 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2727 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302728 // To Do - address probable memory leak with WEP encryption upon successful association
2729 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302731 //Clear saved connection information in HDD
2732 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302734 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002735
2736 break;
2737 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002738 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 pRoamInfo, roamId, roamStatus, roamResult );
2740 break;
2741 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07002742 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
2743 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 break;
2745
2746 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2747 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002748 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002749
2750 case eCSR_ROAM_MIC_ERROR_IND:
2751 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2752 break;
2753
2754 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002755 {
2756 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2757
2758 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002759 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
2760 (TRUE == pHddCtx->hdd_wlan_suspended) &&
2761 (eCSR_ROAM_RESULT_NONE == roamResult))
2762 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002763 /* Send DTIM period to the FW; only if the wlan is already
2764 in suspend. This is the case with roaming (reassoc),
2765 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
2766 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
2767 before the ENTER_BMPS_REQ ensures Listen Interval is
2768 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002769 hdd_set_pwrparams(pHddCtx);
2770 pHddStaCtx->hdd_ReassocScenario = VOS_FALSE;
2771
2772 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002773 if due to unexpected scenario, if we are in BMPS,
2774 then trigger Exit and Enter BMPS to take DTIM period
2775 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002776 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
2777 {
2778 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
2779
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002780 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2781 iw_full_power_cbfn, pAdapter,
2782 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002783 }
2784 }
2785 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302786 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002787 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 break;
2789#ifdef WLAN_FEATURE_VOWIFI_11R
2790 case eCSR_ROAM_FT_RESPONSE:
2791 hdd_SendFTEvent(pAdapter);
2792 break;
2793#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002794#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002795 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002796 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07002797 {
2798 /* Notify the supplicant of a new candidate */
2799 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2800 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002801 break;
2802#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002803
Yue Maef608272013-04-08 23:09:17 -07002804#ifdef FEATURE_WLAN_LFR_METRICS
2805 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
2806 /* This event is to notify pre-auth initiation */
2807 if (VOS_STATUS_SUCCESS !=
2808 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
2809 {
2810 halStatus = eHAL_STATUS_FAILURE;
2811 }
2812 break;
2813 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
2814 /* This event will notify pre-auth completion in case of success */
2815 if (VOS_STATUS_SUCCESS !=
2816 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2817 pRoamInfo, 1))
2818 {
2819 halStatus = eHAL_STATUS_FAILURE;
2820 }
2821 break;
2822 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
2823 /* This event will notify pre-auth completion in case of failure. */
2824 if (VOS_STATUS_SUCCESS !=
2825 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2826 pRoamInfo, 0))
2827 {
2828 halStatus = eHAL_STATUS_FAILURE;
2829 }
2830 break;
2831 case eCSR_ROAM_HANDOVER_SUCCESS:
2832 /* This event is to notify handover success.
2833 It will be only invoked on success */
2834 if (VOS_STATUS_SUCCESS !=
2835 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
2836 {
2837 halStatus = eHAL_STATUS_FAILURE;
2838 }
2839 break;
2840#endif
2841
Jeff Johnson295189b2012-06-20 16:38:30 -07002842 case eCSR_ROAM_INDICATE_MGMT_FRAME:
2843 hdd_indicateMgmtFrame( pAdapter,
2844 pRoamInfo->nFrameLength,
2845 pRoamInfo->pbFrames,
2846 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05302847 pRoamInfo->rxChan,
2848 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07002849 break;
2850 case eCSR_ROAM_REMAIN_CHAN_READY:
2851 hdd_remainChanReadyHandler( pAdapter );
2852 break;
2853 case eCSR_ROAM_SEND_ACTION_CNF:
2854 hdd_sendActionCnf( pAdapter,
2855 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
2856 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002857#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08002858 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002859 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08002860 roamId, roamStatus, roamResult );
2861 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002862 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
2863 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
2864 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002865#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002866#ifdef WLAN_FEATURE_11W
2867 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
2868 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
2869 pRoamInfo->pbFrames,
2870 pRoamInfo->frameType);
2871 break;
2872#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002873#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002874 case eCSR_ROAM_TSM_IE_IND:
2875 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
2876 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
2877 break;
2878
2879 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
2880 {
2881 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
2882 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
2883 {
2884 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
2885 }
2886 break;
2887 }
2888
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002889 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002890 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002891 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002892 break;
2893 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002894
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002895 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002896 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002897 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002898 break;
2899 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002900#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 default:
2902 break;
2903 }
2904 return( halStatus );
2905}
Shailender Karmuchia734f332013-04-19 14:02:48 -07002906eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002907{
2908 eCsrAuthType auth_type;
2909 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002910 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 {
2912 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002913 } else
2914 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 {
2916 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002917 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002918#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07002919 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002920 {
2921 // Check for 11r FT Authentication with PSK
2922 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002923 } else
2924 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 {
2926 // Check for 11R FT Authentication with 802.1X
2927 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002928 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002929#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002930#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07002931 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002932 {
2933 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
2934 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002935#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07002936#ifdef WLAN_FEATURE_11W
2937 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
2938 {
2939 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
2940 } else
2941#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002942 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002943 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2944 }
2945 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002946}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002947
Shailender Karmuchia734f332013-04-19 14:02:48 -07002948eCsrAuthType
2949hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002950{
2951 eCsrAuthType auth_type;
2952 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002953 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002954 {
2955 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002956 } else
2957 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 {
2959 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002960 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002961#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07002962 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002963 {
2964 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002965 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002966#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002967 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2969 }
2970 hddLog(LOG1, FL("auth_type: %d"), auth_type);
2971 return auth_type;
2972}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002973
Shailender Karmuchia734f332013-04-19 14:02:48 -07002974eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07002975hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002976{
2977 eCsrEncryptionType cipher_type;
2978 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002979 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 {
2981 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002982 }
2983 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 {
2985 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002986 }
2987 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002988 {
2989 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002990 }
2991 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002992 {
2993 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002994 }
2995 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
2996 {
2997 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2998 }
2999 else
3000 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3002 }
3003 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3004 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003005}
Jeff Johnson295189b2012-06-20 16:38:30 -07003006/* To find if the MAC address is NULL */
3007static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3008{
3009 int i;
3010 for (i = 0; i < length; i++)
3011 {
3012 if (0x00 != (macAddr[i]))
3013 {
3014 return FALSE;
3015 }
3016 }
3017 return TRUE;
3018} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003019
Shailender Karmuchia734f332013-04-19 14:02:48 -07003020eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003021hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003022{
3023 eCsrEncryptionType cipher_type;
3024 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003025 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003026 {
3027 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003028 } else
3029 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 {
3031 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003032 } else
3033 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 {
3035 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003036 } else
3037 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 {
3039 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003040 } else
3041 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003043 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3044 } else
3045 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003046 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3047 }
3048 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3049 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003050}
Jeff Johnson295189b2012-06-20 16:38:30 -07003051
Shailender Karmuchia734f332013-04-19 14:02:48 -07003052static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3053 struct ether_addr *pBssid,
3054 eCsrEncryptionType *pEncryptType,
3055 eCsrEncryptionType *mcEncryptType,
3056 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003057#ifdef WLAN_FEATURE_11W
3058 u_int8_t *pMfpRequired,
3059 u_int8_t *pMfpCapable,
3060#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003061 u_int16_t gen_ie_len,
3062 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003063{
3064 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003065 eHalStatus result;
3066 tDot11fIERSN dot11RSNIE;
3067 tDot11fIEWPA dot11WPAIE;
3068 tANI_U32 i;
3069 tANI_U8 *pRsnIe;
3070 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003072 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003073
3074 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3075 flag to 0 */
3076 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3077 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3078
3079 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003080 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
3081 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303082 {
3083 hddLog(LOGE, "%s: Invalid DOT11F IE Length passed :%d",
3084 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 return -EINVAL;
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003088 if ( gen_ie[0] == DOT11F_EID_RSN)
3089 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003091 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3093 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303094 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3095 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 return -EINVAL;
3097 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003098 // Skip past the EID byte and length byte
3099 pRsnIe = gen_ie + 2;
3100 RSNIeLen = gen_ie_len - 2;
3101 // Unpack the RSN IE
3102 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3103 pRsnIe,
3104 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003106 // Copy out the encryption and authentication types
3107 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003108 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003109 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003110 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003111 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 but probably I suspect we can do something different*/
3113 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003114 // Just translate the FIRST one
3115 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3116 //dot11RSNIE.pwise_cipher_suite_count
3117 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3118 //dot11RSNIE.gp_cipher_suite_count
3119 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003120#ifdef WLAN_FEATURE_11W
3121 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3122 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3123#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003125 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003127 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003128 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303129 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 break;
3131 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003132 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303134 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 break;
3136 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003137 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 // For right now, I assume setASSOCIATE() has passed in the bssid.
3139 vos_mem_copy(PMKIDCache[i].BSSID,
3140 pBssid, ETHER_ADDR_LEN);
3141 vos_mem_copy(PMKIDCache[i].PMKID,
3142 dot11RSNIE.pmkid[i],
3143 CSR_RSN_PMKID_SIZE);
3144 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003145
3146 if (updatePMKCache)
3147 {
3148 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003149 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003150 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003151 // Finally set the PMKSA ID Cache in CSR
3152 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3153 PMKIDCache,
3154 dot11RSNIE.pmkid_count );
3155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 }
3157 else if (gen_ie[0] == DOT11F_EID_WPA)
3158 {
3159 // Validity checks
3160 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3161 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3162 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303163 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3164 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 return -EINVAL;
3166 }
3167 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003168 pRsnIe = gen_ie + 2 + 4;
3169 RSNIeLen = gen_ie_len - (2 + 4);
3170 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3172 pRsnIe,
3173 RSNIeLen,
3174 &dot11WPAIE);
3175 // Copy out the encryption and authentication types
3176 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003177 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003179 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 //dot11WPAIE.auth_suite_count
3181 // Just translate the FIRST one
3182 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3183 //dot11WPAIE.unicast_cipher_count
3184 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3185 //dot11WPAIE.unicast_cipher_count
3186 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3187 }
3188 else
3189 {
3190 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003191 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 }
3193 return 0;
3194}
3195int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3196{
3197 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3198 v_U32_t status = 0;
3199 eCsrEncryptionType RSNEncryptType;
3200 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003201#ifdef WLAN_FEATURE_11W
3202 u_int8_t RSNMfpRequired;
3203 u_int8_t RSNMfpCapable;
3204#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 struct ether_addr bSsid; // MAC address of assoc peer
3206 // MAC address of assoc peer
3207 // But, this routine is only called when we are NOT associated.
3208 vos_mem_copy(bSsid.ether_addr_octet,
3209 pWextState->roamProfile.BSSIDs.bssid,
3210 sizeof(bSsid.ether_addr_octet));
3211 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3212 {
3213 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 else
3216 {
3217 return 0;
3218 }
3219 // The actual processing may eventually be more extensive than this.
3220 // Right now, just consume any PMKIDs that are sent in by the app.
3221 status = hdd_ProcessGENIE(pAdapter,
3222 &bSsid, // MAC address of assoc peer
3223 &RSNEncryptType,
3224 &mcRSNEncryptType,
3225 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003226#ifdef WLAN_FEATURE_11W
3227 &RSNMfpRequired,
3228 &RSNMfpCapable,
3229#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 pWextState->WPARSNIE[1]+2,
3231 pWextState->WPARSNIE);
3232 if (status == 0)
3233 {
3234 // Now copy over all the security attributes you have parsed out
3235 pWextState->roamProfile.EncryptionType.numEntries = 1;
3236 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003237
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3239 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003240
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003241 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3242 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3243 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3244 {
3245 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3246 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3247 either AES/TKIP based on group cipher configuration
3248 mentioned in the wpa_supplicant.conf.*/
3249
3250 /*Set the unicast cipher same as multicast cipher*/
3251 pWextState->roamProfile.EncryptionType.encryptionType[0]
3252 = mcRSNEncryptType;
3253 }
3254
Chet Lanctot186b5732013-03-18 10:26:30 -07003255#ifdef WLAN_FEATURE_11W
3256 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3257 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3258#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003259 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003260 }
3261 return 0;
3262}
3263int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3264{
3265 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3266 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3267 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3268 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003269
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003271 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003272
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 switch( pHddStaCtx->conn_info.authType)
3274 {
3275 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003276#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 case eCSR_AUTH_TYPE_CCKM_WPA:
3278 case eCSR_AUTH_TYPE_CCKM_RSN:
3279#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003280 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3281
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003283 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003285
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003286#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003287 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3288 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3289 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003290 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003291 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3292 } else
3293 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003294 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003295 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003296 } else
3297#endif
3298 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3299 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003300 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3301 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3303 == IW_AUTH_KEY_MGMT_PSK) {
3304 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003305 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003307 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 }
3309 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003310#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003311 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3312 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3313 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003314 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __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
Shailender Karmuchia734f332013-04-19 14:02:48 -07003317 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003318 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003319 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003320 } else
3321#endif
3322
3323#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003324 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3325 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003327 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003328 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003329 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3331 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003332 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 } else
3334#endif
3335
Chet Lanctot186b5732013-03-18 10:26:30 -07003336#ifdef WLAN_FEATURE_11W
3337 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3338 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3339 } else
3340#endif
3341
Shailender Karmuchia734f332013-04-19 14:02:48 -07003342 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003344 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3345 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3347 == IW_AUTH_KEY_MGMT_PSK) {
3348 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003349 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003350 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003351 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003353 break;
3354
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003356
3357 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003358 break;
3359 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003360
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003361#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08003362 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003363#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003364 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3365 break;
3366 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003367
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003369 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003370
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 EXIT();
3372 return 0;
3373}
3374
3375/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003376
3377 \brief iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003379 to the CSR roam profile.
3380
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 \param - dev - Pointer to the net device.
3382 - info - Pointer to the iw_request_info.
3383 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003384 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003386
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 --------------------------------------------------------------------------*/
3388
Shailender Karmuchia734f332013-04-19 14:02:48 -07003389int iw_set_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 struct iw_request_info *info,
3391 union iwreq_data *wrqu, char *extra)
3392{
3393 v_U32_t status = 0;
3394 hdd_wext_state_t *pWextState;
3395 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3396 v_U32_t roamId;
3397 tCsrRoamProfile *pRoamProfile;
3398 eMib_dot11DesiredBssType connectedBssType;
3399 eCsrAuthType RSNAuthType;
3400 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3401 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003402
3403 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3404
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 ENTER();
3406
3407 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3408 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 "%s:LOGP in Progress. Ignore!!!",__func__);
3411 return 0;
3412 }
3413
3414 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
3415 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
3416 return -EBUSY;
3417 }
3418 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
3419 return -EINVAL;
3420 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003421 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 {
3423 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
3424 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
3425 {
3426 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003427 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3429 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
3430
3431 if(VOS_STATUS_SUCCESS == vosStatus)
3432 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3433 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3434 }
3435 }
3436 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003437 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 {
3439 return -EINVAL;
3440 }
3441 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003442 /** when cfg80211 defined, wpa_supplicant wext driver uses
3443 zero-length, null-string ssid for force disconnection.
3444 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 driver MUST return success */
3446 if ( 0 == wrqu->essid.length ) {
3447 return 0;
3448 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003449
3450 status = hdd_wmm_get_uapsd_mask(pAdapter,
3451 &pWextState->roamProfile.uapsd_mask);
3452 if (VOS_STATUS_SUCCESS != status)
3453 {
3454 pWextState->roamProfile.uapsd_mask = 0;
3455 }
3456 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003457
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003459
3460 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
3462 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
3463 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003464
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 //set gen ie
3466 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
3467
3468 //set auth
3469 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
3470 }
3471#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003472 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 if (pAdapter->wapi_info.nWapiMode)
3474 {
3475 switch (pAdapter->wapi_info.wapiAuthMode)
3476 {
3477 case WAPI_AUTH_MODE_PSK:
3478 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003479 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003480 pRoamProfile->AuthType.numEntries = 1;
3481 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3482 break;
3483 }
3484 case WAPI_AUTH_MODE_CERT:
3485 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003486 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003487 pRoamProfile->AuthType.numEntries = 1;
3488 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3489 break;
3490 }
3491 } // End of switch
3492 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
3493 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
3494 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003495 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003496 pRoamProfile->EncryptionType.numEntries = 1;
3497 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3498 pRoamProfile->mcEncryptionType.numEntries = 1;
3499 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3500 }
3501 }
3502#endif /* FEATURE_WLAN_WAPI */
3503 /* if previous genIE is not NULL, update AssocIE */
3504 if (0 != pWextState->genIE.length)
3505 {
3506 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
3507 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
3508 pWextState->genIE.length);
3509 pWextState->assocAddIE.length = pWextState->genIE.length;
3510 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
3511 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
3512
3513 /* clear previous genIE after use it */
3514 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
3515 }
3516
3517 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
3518 pWextState->roamProfile.bWPSAssociation = FALSE;
3519
3520 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
3521 pWextState->roamProfile.nAddIEAssocLength))
3522 pWextState->roamProfile.bWPSAssociation = TRUE;
3523
3524
3525 // Disable auto BMPS entry by PMC until DHCP is done
3526 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
3527
Shailender Karmuchia734f332013-04-19 14:02:48 -07003528 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003530
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003531 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
3532 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003533 hdd_select_cbmode(pAdapter,
3534 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
3535 }
3536 status = sme_RoamConnect( hHal,pAdapter->sessionId,
3537 &(pWextState->roamProfile), &roamId);
3538 pRoamProfile->ChannelInfo.ChannelList = NULL;
3539 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003540
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003541 EXIT();
3542 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003543}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003544
Jeff Johnson295189b2012-06-20 16:38:30 -07003545/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003546
3547 \brief iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003549
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 \param - dev - Pointer to the net device.
3551 - info - Pointer to the iw_request_info.
3552 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003553 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003555
Jeff Johnson295189b2012-06-20 16:38:30 -07003556 --------------------------------------------------------------------------*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003557int iw_get_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 struct iw_request_info *info,
3559 struct iw_point *dwrq, char *extra)
3560{
3561 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003562 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3564 ENTER();
3565
3566 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
3567 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
3568 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
3569 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
3570 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
3571 {
3572 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
3573 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
3574 dwrq->flags = 1;
3575 } else {
3576 memset(extra, 0, dwrq->length);
3577 dwrq->length = 0;
3578 dwrq->flags = 0;
3579 }
3580 EXIT();
3581 return 0;
3582}
3583/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003584
3585 \brief iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003587
Jeff Johnson295189b2012-06-20 16:38:30 -07003588 \param - dev - Pointer to the net device.
3589 - info - Pointer to the iw_request_info.
3590 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003591 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003592 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003593
Jeff Johnson295189b2012-06-20 16:38:30 -07003594 --------------------------------------------------------------------------*/
3595int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
3596 union iwreq_data *wrqu,char *extra)
3597{
3598 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003599 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003600 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3601 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003602 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 eCsrEncryptionType ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003604
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003606
3607 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3608 {
3609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3610 "%s:LOGP in Progress. Ignore!!!", __func__);
3611 return -EBUSY;
3612 }
3613
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 switch(wrqu->param.flags & IW_AUTH_INDEX)
3615 {
3616 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003617
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003619
Jeff Johnson295189b2012-06-20 16:38:30 -07003620 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003621
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 case IW_AUTH_CIPHER_PAIRWISE:
3623 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003624 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003627 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3628 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3631 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003632 }
3633
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003635
3636 if( (IW_AUTH_KEY_MGMT_802_1X
3637 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003638 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
3639 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003640 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 else
3642 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003643 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3644 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003646
3647 if( ( IW_AUTH_KEY_MGMT_802_1X
3648 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3650 /*Dynamic WEP key*/
3651 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3652 else
3653 /*Static WEP key*/
3654 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003655
Jeff Johnson295189b2012-06-20 16:38:30 -07003656 }
3657 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003658
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003660 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003661 return -EINVAL;
3662 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003663
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 pRoamProfile->EncryptionType.numEntries = 1;
3665 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003667 break;
3668 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003669 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
3671 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3672 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003673
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3675 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
3676 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003677
3678 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
3680 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003681
Jeff Johnson295189b2012-06-20 16:38:30 -07003682 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003683
3684 if( ( IW_AUTH_KEY_MGMT_802_1X
3685 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
3686 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3687
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003689
3690 else
3691 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003693
3694 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3695 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003697 if( ( IW_AUTH_KEY_MGMT_802_1X
3698 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003699 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3700 {
3701 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3702 }
3703 else
3704 {
3705 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3706 }
3707 }
3708 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003709
Jeff Johnson295189b2012-06-20 16:38:30 -07003710 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003711 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 return -EINVAL;
3713 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003714
Jeff Johnson295189b2012-06-20 16:38:30 -07003715 pRoamProfile->mcEncryptionType.numEntries = 1;
3716 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3717 }
3718 break;
3719
3720 case IW_AUTH_80211_AUTH_ALG:
3721 {
3722 /*Save the auth algo here and set auth type to SME Roam profile
3723 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003724 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07003725 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003726
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3728 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3729
3730 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3731 /*Not supported*/
3732 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3733 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3734 }
3735 break;
3736
3737 case IW_AUTH_KEY_MGMT:
3738 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003739#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003740#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3741 /*Check for CCKM AKM type */
3742 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003743 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
3744 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003745 /* Set the CCKM bit in authKeyMgmt */
3746 /* Right now, this breaks all ref to authKeyMgmt because our
3747 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 */
3749 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3750 /*Set the key management to 802.1X*/
3751 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003752 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3754 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3755 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3756 /*Save the key management*/
3757 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3758 //pWextState->authKeyMgmt = wrqu->param.value;
3759 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3760 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3761 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3762 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3763 /*Save the key management anyway*/
3764 pWextState->authKeyMgmt = wrqu->param.value;
3765 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3766 /*Save the key management*/
3767 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3768 //pWextState->authKeyMgmt = wrqu->param.value;
3769 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3770 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3771 }
3772#else
3773 /*Save the key management*/
3774 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003775#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 }
3777 break;
3778
3779 case IW_AUTH_TKIP_COUNTERMEASURES:
3780 {
3781 if(wrqu->param.value) {
3782 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3783 "Counter Measure started %d", wrqu->param.value);
3784 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3785 }
3786 else {
3787 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3788 "Counter Measure stopped=%d", wrqu->param.value);
3789 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3790 }
3791 }
3792 break;
3793 case IW_AUTH_DROP_UNENCRYPTED:
3794 case IW_AUTH_WPA_ENABLED:
3795 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3796 case IW_AUTH_ROAMING_CONTROL:
3797 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003798
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003800
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003801 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 wrqu->param.flags & IW_AUTH_INDEX);
3803 break;
3804 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003805
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 EXIT();
3807 return 0;
3808}
3809/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003810
3811 \brief iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003813
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 \param - dev - Pointer to the net device.
3815 - info - Pointer to the iw_request_info.
3816 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003817 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003819
Jeff Johnson295189b2012-06-20 16:38:30 -07003820 --------------------------------------------------------------------------*/
3821int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3822 union iwreq_data *wrqu,char *extra)
3823{
3824 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003825 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003826 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3827 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003828
3829 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3830 {
3831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3832 "%s:LOGP in Progress. Ignore!!!", __func__);
3833 return -EBUSY;
3834 }
3835
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 switch(pRoamProfile->negotiatedAuthType)
3837 {
3838 case eCSR_AUTH_TYPE_WPA_NONE:
3839 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3840 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
3841 break;
3842 case eCSR_AUTH_TYPE_WPA:
3843 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3844 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
3845 break;
3846#ifdef WLAN_FEATURE_VOWIFI_11R
3847 case eCSR_AUTH_TYPE_FT_RSN:
3848#endif
3849 case eCSR_AUTH_TYPE_RSN:
3850 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3851 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
3852 break;
3853 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3854 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3855 break;
3856 case eCSR_AUTH_TYPE_SHARED_KEY:
3857 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
3858 break;
3859 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003860 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3862 break;
3863 case eCSR_AUTH_TYPE_AUTOSWITCH:
3864 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3865 break;
3866 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303867 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003868 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3869 return -EIO;
3870#ifdef WLAN_FEATURE_VOWIFI_11R
3871 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3872#endif
3873 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07003874#ifdef WLAN_FEATURE_11W
3875 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3876#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05303877 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003878 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3879 return -EIO;
3880 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303881 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3883 return -EIO;
3884 }
3885 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
3886 {
3887 switch(pRoamProfile->negotiatedUCEncryptionType)
3888 {
3889 case eCSR_ENCRYPT_TYPE_NONE:
3890 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3891 break;
3892 case eCSR_ENCRYPT_TYPE_WEP40:
3893 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3894 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3895 break;
3896 case eCSR_ENCRYPT_TYPE_TKIP:
3897 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3898 break;
3899 case eCSR_ENCRYPT_TYPE_WEP104:
3900 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3901 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3902 break;
3903 case eCSR_ENCRYPT_TYPE_AES:
3904 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3905 break;
3906 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303907 hddLog(LOG1, "%s called with unknown auth type %d ",
3908 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 return -EIO;
3910 }
3911 }
3912
Shailender Karmuchia734f332013-04-19 14:02:48 -07003913 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 {
3915 switch(pRoamProfile->negotiatedMCEncryptionType)
3916 {
3917 case eCSR_ENCRYPT_TYPE_NONE:
3918 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3919 break;
3920 case eCSR_ENCRYPT_TYPE_WEP40:
3921 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3922 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3923 break;
3924 case eCSR_ENCRYPT_TYPE_TKIP:
3925 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3926 break;
3927 case eCSR_ENCRYPT_TYPE_WEP104:
3928 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3929 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3930 break;
3931 case eCSR_ENCRYPT_TYPE_AES:
3932 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3933 break;
3934 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303935 hddLog(LOG1, "%s called with unknown auth type %d ",
3936 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 return -EIO;
3938 }
3939 }
3940
3941 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003942 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003943 EXIT();
3944 return 0;
3945}
3946/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003947
3948 \brief iw_set_ap_address() -
3949 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003951
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 \param - dev - Pointer to the net device.
3953 - info - Pointer to the iw_request_info.
3954 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003955 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003957
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 --------------------------------------------------------------------------*/
3959int iw_set_ap_address(struct net_device *dev,
3960 struct iw_request_info *info,
3961 union iwreq_data *wrqu, char *extra)
3962{
3963 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3964 v_U8_t *pMacAddress=NULL;
3965 ENTER();
3966 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08003967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
3968 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
3970 EXIT();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003971
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 return 0;
3973}
3974/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003975
3976 \brief iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003977 This function returns the BSSID to the wpa_supplicant
3978 \param - dev - Pointer to the net device.
3979 - info - Pointer to the iw_request_info.
3980 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003981 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003983
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 --------------------------------------------------------------------------*/
3985int iw_get_ap_address(struct net_device *dev,
3986 struct iw_request_info *info,
3987 union iwreq_data *wrqu, char *extra)
3988{
3989 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3990 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3991
3992 ENTER();
3993
3994 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
3995 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
3996 {
Jeff Johnson4416a782013-03-25 14:17:50 -07003997 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003998 }
3999 else
4000 {
4001 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4002 }
4003 EXIT();
4004 return 0;
4005}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004006
Chet Lanctot186b5732013-03-18 10:26:30 -07004007#ifdef WLAN_FEATURE_11W
4008/**---------------------------------------------------------------------------
4009
4010 \brief hdd_indicateUnprotMgmtFrame -
4011 This function forwards the unprotected management frame to the supplicant
4012 \param - pAdapter - Pointer to HDD adapter
4013 - nFrameLength - Length of the unprotected frame being passed
4014 - pbFrames - Pointer to the frame buffer
4015 - frameType - 802.11 frame type
4016 \return - nothing
4017
4018 --------------------------------------------------------------------------*/
4019void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4020 tANI_U32 nFrameLength,
4021 tANI_U8* pbFrames,
4022 tANI_U8 frameType )
4023{
4024 tANI_U8 type = 0;
4025 tANI_U8 subType = 0;
4026
4027 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4028 __func__, frameType, nFrameLength);
4029
4030 /* Sanity Checks */
4031 if (NULL == pAdapter)
4032 {
4033 hddLog( LOGE, FL("pAdapter is NULL"));
4034 return;
4035 }
4036
4037 if (NULL == pAdapter->dev)
4038 {
4039 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4040 return;
4041 }
4042
4043 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4044 {
4045 hddLog( LOGE, FL("pAdapter has invalid magic"));
4046 return;
4047 }
4048
4049 if( !nFrameLength )
4050 {
4051 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4052 return;
4053 }
4054
4055 if (NULL == pbFrames) {
4056 hddLog( LOGE, FL("pbFrames is NULL"));
4057 return;
4058 }
4059
4060 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4061 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4062
4063 /* Get pAdapter from Destination mac address of the frame */
4064 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
4065 {
4066 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
4067 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4068 }
4069 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
4070 {
4071 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
4072 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4073 }
4074 else
4075 {
4076 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
4077 return;
4078 }
4079}
4080#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004081
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004082#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004083void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
4084 tANI_U8 state,
4085 tANI_U16 measInterval )
4086{
4087 union iwreq_data wrqu;
4088 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004089 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004090
4091 if (NULL == pAdapter)
4092 return;
4093
4094 // create the event
4095 memset(&wrqu, '\0', sizeof(wrqu));
4096 memset(buf, '\0', sizeof(buf));
4097
4098 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
4099 tid, state, measInterval);
4100
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004101 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004102
4103 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004104 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004105 // send the event
4106 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4107}
4108
4109void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4110{
4111 union iwreq_data wrqu;
4112 char buf[IW_CUSTOM_MAX + 1];
4113 char *pos = buf;
4114 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4115
4116 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4117 return;
4118
4119 // create the event
4120 memset(&wrqu, '\0', sizeof(wrqu));
4121 memset(buf, '\0', sizeof(buf));
4122
4123 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304124 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
4125 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
4126 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
4127 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004128
4129 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4130 pos += nBytes;
4131 freeBytes -= nBytes;
4132
4133 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
4134 pos += WNI_CFG_BSSID_LEN;
4135 freeBytes -= WNI_CFG_BSSID_LEN;
4136
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004137 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4138 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004139
4140 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004141 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004142
4143 // send the event
4144 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4145}
4146
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004147void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004148{
4149 union iwreq_data wrqu;
4150 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004151 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004152
4153 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4154 return;
4155
4156 // create the event
4157 memset(&wrqu, '\0', sizeof(wrqu));
4158 memset(buf, '\0', sizeof(buf));
4159
4160 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
4161
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004162 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004163
4164 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004165 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004166
4167 // send the event
4168 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4169}
4170
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004171void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
4172 const tANI_U16 measurementToken,
4173 const tANI_BOOLEAN flag,
4174 const tANI_U8 numBss)
4175{
4176 union iwreq_data wrqu;
4177 char buf[IW_CUSTOM_MAX];
4178 char *pos = buf;
4179 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4180
4181 memset(&wrqu, '\0', sizeof(wrqu));
4182 memset(buf, '\0', sizeof(buf));
4183
4184 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
4185 numBss);
4186
4187 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4188 flag, numBss);
4189
4190 wrqu.data.pointer = buf;
4191 wrqu.data.length = nBytes;
4192 // send the event
4193 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4194}
4195
4196
4197static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004198 const tCsrRoamInfo *pRoamInfo)
4199{
4200 union iwreq_data wrqu;
4201 char buf[IW_CUSTOM_MAX + 1];
4202 char *pos = buf;
4203 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4204 tANI_U8 i = 0, len = 0;
4205 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
4206 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004207 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
4208 tANI_U8 ieLenByte = 1;
4209 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
4210#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004211
4212 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4213 return;
4214
4215 /* Custom event can pass maximum of 256 bytes of data,
4216 based on the IE len we need to identify how many BSS info can
4217 be filled in to custom event data */
4218 /*
4219 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4220 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4221 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4222 */
4223
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004224 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004225 {
4226 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
4227 /* If the measurement is none and no scan results found,
4228 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004229 hdd_indicateEseBcnReportNoResults(pAdapter,
4230 pRoamInfo->pEseBcnReportRsp->measurementToken,
4231 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004232 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004233 }
4234 else
4235 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004236 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004237 {
4238 memset(&wrqu, '\0', sizeof(wrqu));
4239 memset(buf, '\0', sizeof(buf));
4240 tot_bcn_ieLen = 0;
4241 sendBss = 0;
4242 pos = buf;
4243 freeBytes = IW_CUSTOM_MAX;
4244
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004245 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004246 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004247 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
4248 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004249 {
4250 break;
4251 }
4252 tot_bcn_ieLen += len;
4253 sendBss++;
4254 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
4255 "IeLength(%d) Length of Ie(%d) totLen(%d)",
4256 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004257 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004258 tot_bcn_ieLen);
4259 }
4260
4261 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
4262 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004263 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4264 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004265
4266 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004267 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4268 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004269 pos += nBytes;
4270 freeBytes -= nBytes;
4271
4272 /* Copy total Beacon report data length */
4273 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
4274 pos += sizeof(tot_bcn_ieLen);
4275 freeBytes -= sizeof(tot_bcn_ieLen);
4276
4277 for (i = 0; i < sendBss; i++)
4278 {
4279 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304280 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4281 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004282 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004283 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
4284 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
4285 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
4286 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
4287 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
4288 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
4289 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
4290 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
4291 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
4292 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
4293 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
4294 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
4295 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
4296 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
4297 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
4298 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004299
4300 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004301 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
4302 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004303 pos += len;
4304 freeBytes -= len;
4305
4306 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004307 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004308 vos_mem_copy(pos, (char*)&len, sizeof(len));
4309 pos += sizeof(len);
4310 freeBytes -= sizeof(len);
4311
4312 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004313 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004314 pos += len;
4315 freeBytes -= len;
4316 }
4317
4318 wrqu.data.pointer = buf;
4319 wrqu.data.length = strlen(buf);
4320
4321 // send the event
4322 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4323 lastSent += sendBss;
4324 }
4325 }
4326}
4327
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004328#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004329