blob: 86a98fc25da6a6ccc3d781b0ab436c4e2a2f977d [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"
Sushant Kaushikba6764e2014-06-30 19:52:09 +053066#include "wlan_hdd_hostapd.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053067#ifdef DEBUG_ROAM_DELAY
68#include "vos_utils.h"
69#endif
70
Jeff Johnson295189b2012-06-20 16:38:30 -070071v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
72
Shailender Karmuchia734f332013-04-19 14:02:48 -070073struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -070074{
75 u_char ether_addr_octet[6];
76};
77// These are needed to recognize WPA and RSN suite types
78#define HDD_WPA_OUI_SIZE 4
79v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
80v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
81v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
82v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
83v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
84v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080085#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070086v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080087#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070088#define HDD_RSN_OUI_SIZE 4
89v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
90v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
91v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
92v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
93v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
94v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080095#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070096v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080097#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -070098#ifdef WLAN_FEATURE_11W
99v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
100#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700101
Shailender Karmuchia734f332013-04-19 14:02:48 -0700102#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700103// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700104#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
105#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700106#endif
107
108#define BEACON_FRAME_IES_OFFSET 12
109
Chet Lanctot186b5732013-03-18 10:26:30 -0700110#ifdef WLAN_FEATURE_11W
111void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
112 tANI_U32 nFrameLength,
113 tANI_U8* pbFrames,
114 tANI_U8 frameType );
115#endif
116
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800117#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700118static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
119 tANI_U8 state,
120 tANI_U16 measInterval );
121static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800122static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
123static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700124
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800125#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700126
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530127static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
128 tCsrRoamInfo *pRoamInfo,
129 tANI_U32 roamId,
130 eRoamCmdStatus roamStatus,
131 eCsrRoamResult roamResult );
132
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530133v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
134 eConnectionState connState )
135{
136 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530137 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
138 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700139 pHddStaCtx->conn_info.connState = connState;
140}
141
142// returns FALSE if not connected.
143// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
144// returns the connection state. Can specify NULL if you dont' want to get the actual state.
145
Shailender Karmuchia734f332013-04-19 14:02:48 -0700146static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
147 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700148{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700149 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700150 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700151
Jeff Johnson295189b2012-06-20 16:38:30 -0700152 // get the connection state.
153 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700154 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700156 eConnectionState_IbssConnected == connState ||
157 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700158 {
159 fConnected = VOS_TRUE;
160 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700161 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 {
163 fConnected = VOS_FALSE;
164 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700165
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 if ( pConnState )
167 {
168 *pConnState = connState;
169 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700170
Jeff Johnson295189b2012-06-20 16:38:30 -0700171 return( fConnected );
172}
173
174v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
175{
176 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700177}
Jeff Johnson295189b2012-06-20 16:38:30 -0700178
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530179eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
180{
181 v_U8_t staChannel = 0;
182
183 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
184 {
185 staChannel = pHddStaCtx->conn_info.operationChannel;
186 }
187
188 if ( staChannel > 0 && staChannel < 14 )
189 return eCSR_BAND_24;
190 else if (staChannel >= 36 && staChannel <= 165 )
191 return eCSR_BAND_5G;
192 else /* If station is not connected return as eCSR_BAND_ALL */
193 return eCSR_BAND_ALL;
194}
195
196
Jeff Johnson295189b2012-06-20 16:38:30 -0700197//TODO - Not used anyhwere. Can be removed.
198#if 0
199//
200v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
201{
202 v_BOOL_t fConnectedInfra = FALSE;
203 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700204
Jeff Johnson295189b2012-06-20 16:38:30 -0700205 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700206 {
207 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700208 {
209 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700210 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700211 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700212
Jeff Johnson295189b2012-06-20 16:38:30 -0700213 return( fConnectedInfra );
214}
215#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
218{
219 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700220
Jeff Johnson295189b2012-06-20 16:38:30 -0700221 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700222
223 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700224 {
225 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
226 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700227
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 return( fConnected );
229}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700230
Jeff Johnson295189b2012-06-20 16:38:30 -0700231inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
232{
233 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700234
Jeff Johnson295189b2012-06-20 16:38:30 -0700235 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700236
237 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700238 {
239 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
240 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700241
Jeff Johnson295189b2012-06-20 16:38:30 -0700242 return( fConnected );
243}
244
245static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
246{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700247 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700248 {
249 case eCSR_BSS_TYPE_INFRASTRUCTURE:
250 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
251 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700252
Jeff Johnson295189b2012-06-20 16:38:30 -0700253 case eCSR_BSS_TYPE_IBSS:
254 case eCSR_BSS_TYPE_START_IBSS:
255 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
256 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700257
258 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700259 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700260 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 default:
262 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700263 break;
264 }
265
Jeff Johnson295189b2012-06-20 16:38:30 -0700266}
267
268void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
269{
270 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
271 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700272
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700274
275 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700276 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700277 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
279 {
280 VOS_ASSERT( pRoamInfo->pBssDesc );
281 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
282
283 // Save the Station ID for this station from the 'Roam Info'.
284 //For IBSS mode, staId is assigned in NEW_PEER_IND
285 //For reassoc, the staID doesn't change and it may be invalid in this structure
286 //so no change here.
287 if( !pRoamInfo->fReassocReq )
288 {
289 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
290 }
291 }
292 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700293 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700294 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700295 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700296 else
297 {
298 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
299 // or we can't function.
300 VOS_ASSERT( 0 );
301 }
302
303 // notify WMM
304 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
305
306 if( !pRoamInfo->u.pConnectedProfile )
307 {
308 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
309 }
310 else
311 {
312 // Get Multicast Encryption Type
313 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
314 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
315 // Get Unicast Encrytion Type
316 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
317 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
318
319 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
320
321 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
322
323 // Save the ssid for the connection
324 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530325
326 // Save dot11mode in which STA associated to AP
327 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700328 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700329 }
330
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700332 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
333
Jeff Johnson295189b2012-06-20 16:38:30 -0700334}
335
336#if defined(WLAN_FEATURE_VOWIFI_11R)
337/*
338 * Send the 11R key information to the supplicant.
339 * Only then can the supplicant generate the PMK-R1.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800340 * (BTW, the ESE supplicant also needs the Assoc Resp IEs
Jeff Johnson295189b2012-06-20 16:38:30 -0700341 * for the same purpose.)
342 *
343 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
344 * this contains the R1KHID, R0KHID and the MDID.
345 * For FT, this consists of the Reassoc Rsp FTIEs.
346 * This is the Assoc Response.
347 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700348static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 tCsrRoamInfo *pCsrRoamInfo)
350{
351 union iwreq_data wrqu;
352 char *buff;
353 unsigned int len = 0;
354 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700355
356 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 {
358 hddLog(LOGE,
359 "%s: pCsrRoamInfo->nAssocRspLength=%d",
360 __func__, (int)pCsrRoamInfo->nAssocRspLength);
361 return;
362 }
363
Shailender Karmuchia734f332013-04-19 14:02:48 -0700364 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700366 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700367 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700368 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 return;
370 }
371
372 // pFTAssocRsp needs to point to the IEs
373 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
374 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
375 (unsigned int)pFTAssocRsp[0],
376 (unsigned int)pFTAssocRsp[1]);
377
378 // We need to send the IEs to the supplicant.
379 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700380 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700381 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700382 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700383 return;
384 }
385
386 // Send the Assoc Resp, the supplicant needs this for initial Auth.
387 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700388 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700390 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
392
393 kfree(buff);
394}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700395#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700396
397#ifdef WLAN_FEATURE_VOWIFI_11R
398
399/*---------------------------------------------------
400 *
401 * Send the FTIEs, RIC IEs during FT. This is eventually
402 * used to send the FT events to the supplicant
403 *
404 * At the reception of Auth2 we send the RIC followed
405 * by the auth response IEs to the supplicant.
406 * Once both are received in the supplicant, an FT
407 * event is generated to the supplicant.
408 *
409 *---------------------------------------------------
410 */
411void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
412{
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 tANI_U16 auth_resp_len = 0;
414 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
416
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530417#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700418 struct cfg80211_ft_event_params ftEvent;
419 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
420 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
421 struct net_device *dev = pAdapter->dev;
422#else
423 char *buff;
424 union iwreq_data wrqu;
425 tANI_U16 str_len;
426#endif
427
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530428#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530429 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
430 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700431
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530432 sme_GetRICIEs( pHddCtx->hHal, (u8 *)ricIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800433 DOT11F_IE_FTINFO_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530434 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700435 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530436 hddLog(LOGW,
437 "%s: RIC IEs is of length 0 not sending RIC Information for now",
438 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700439 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700440
441 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530442 ftEvent.ric_ies_len = ric_ies_length;
443 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700444
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530445 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800446 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700447
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530448 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700449 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530450 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700451 return;
452 }
453
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530454 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530455
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530456 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700457
458 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
459 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
460
Jeff Johnson59a121e2013-11-30 09:46:08 -0800461 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
462 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
463 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530464 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800465 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
466 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
467 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700468
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530469 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700470
471#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530472 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530474 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700475 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530476 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 return;
478 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530479 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700480
Shailender Karmuchia734f332013-04-19 14:02:48 -0700481 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530483 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800484 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530485 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530487 hddLog(LOGW,
488 "%s: RIC IEs is of length 0 not sending RIC Information for now",
489 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 }
491 else
492 {
493 wrqu.data.length = str_len + ric_ies_length;
494 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
495 }
496
497 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530498 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700499 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530500 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
501 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700502
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530503 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700504 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530505 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 return;
507 }
508
509 wrqu.data.length = str_len + auth_resp_len;
510 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
511
512 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700513#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700514}
515
516#endif /* WLAN_FEATURE_VOWIFI_11R */
517
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800518#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700519
520/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800521 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 * (This keeps the supplicant "up to date" on the current channel.)
523 *
524 * The current (new AP) channel information is passed in.
525 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700526static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 tCsrRoamInfo *pCsrRoamInfo)
528{
529 union iwreq_data wrqu;
530 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700531
Shailender Karmuchia734f332013-04-19 14:02:48 -0700532
533 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700534 {
535 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800536 "%s: pCsrRoamInfo->pBssDesc=%p",
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 __func__, descriptor);
538 return;
539 }
540
541 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -0800542 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 memset(&wrqu, '\0', sizeof(wrqu));
544 wrqu.freq.m = descriptor->channelId;
545 wrqu.freq.e = 0;
546 wrqu.freq.i = 0;
547 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
548}
549
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800550#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700551
552void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
553{
554 union iwreq_data wrqu;
555 u8 *pBeaconIes;
556 u8 currentLen = 0;
557 char *buff;
558 int totalIeLen = 0, currentOffset = 0, strLen;
559
560 memset(&wrqu, '\0', sizeof(wrqu));
561
562 if (0 == pCsrRoamInfo->nBeaconLength)
563 {
564 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
565 return;
566 }
567 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700568 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700569 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700570 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 return;
572 }
573
574 // pBeaconIes needs to point to the IEs
575 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
576 (unsigned int)pBeaconIes[0],
577 (unsigned int)pBeaconIes[1]);
578 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700579
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 // We need to send the IEs to the supplicant.
581 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700582 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700584 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 return;
586 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700587 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700588
589 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
590 currentLen = strLen + 1;
591
592 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
593 do
594 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700595 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 * max size and send it to supplicant. Changes are done in supplicant to handle this */
597 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
598 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
599 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
600 currentOffset += currentLen;
601 totalIeLen -= currentLen;
602 wrqu.data.length = strLen + 1 + currentLen;
603 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700604 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700605 else
606 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
607
608 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
609 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
610 } while (totalIeLen > 0);
611
612 kfree(buff);
613}
614
615static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
616{
617 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
618 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
619 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
620 union iwreq_data wrqu;
621 int we_event;
622 char *msg;
623 int type = -1;
624
Shailender Karmuchia734f332013-04-19 14:02:48 -0700625#if defined (WLAN_FEATURE_VOWIFI_11R)
626 // Added to find the auth type on the fly at run time
627 // rather than with cfg to see if FT is enabled
628 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
630#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700631
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700633 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700635
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
637 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530638 /* In case of roaming ; We are not doing disconnect.
639 * If disconnect is not being done for roam; We will not
640 * decrease count for Active sessions. We should not increase active
641 * active session in case of roaming.
642 */
643 if(pHddStaCtx->ft_carrier_on == FALSE)
644 {
645 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
646 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700647 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
648 type = WLAN_STA_ASSOC_DONE_IND;
649
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700650#ifdef WLAN_FEATURE_P2P_DEBUG
651 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
652 {
653 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
654 {
655 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
656 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
657 "Connecting state to Connected State for 8-way "
658 "Handshake");
659 }
660 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
661 {
662 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
663 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
664 "Connecting state to P2P Client Connection Completed");
665 }
666 }
667#endif
Arif Hussain77d044f2014-01-03 19:56:04 -0800668 pr_info("wlan: " MAC_ADDRESS_STR " connected to " MAC_ADDRESS_STR "\n",
669 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
Kiet Lam34947452014-01-21 23:23:40 -0800670 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700671 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
672
673 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
674 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
675 * and fFTEnable is TRUE */
676#ifdef WLAN_FEATURE_VOWIFI_11R
677 // Send FT Keys to the supplicant when FT is enabled
678 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700679 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800680#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700681 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
682 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
683#endif
684 )
685 {
686 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
687 }
688#endif
689 }
690 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
691 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530692 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -0700693 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 type = WLAN_STA_ASSOC_DONE_IND;
Arif Hussain24bafea2013-11-15 15:10:03 -0800695 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR"\n",
696 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 }
698 else /* Not Associated */
699 {
700 pr_info("wlan: disconnected\n");
701 type = WLAN_STA_DISASSOC_DONE_IND;
702 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
703 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700704 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700705
706 msg = NULL;
707 /*During the WLAN uninitialization,supplicant is stopped before the
708 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530709 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 {
711 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800712#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700714 {
715 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
716 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
718 }
719#endif
720 }
721 send_btc_nlink_msg(type, 0);
722}
723
724void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
725{
726 // Remove staId, bssId and peerMacAddress
727 pHddStaCtx->conn_info.staId [ 0 ] = 0;
728 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
729 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
730
731 // Clear all security settings
732 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
733 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
734 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
735
736 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700737 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700738
739 // Set not-connected state
740 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700741
742 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
743}
744/* TODO Revist this function. and data path */
745static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
746{
747 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700748 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
749
750 if (WLAN_HDD_IBSS != pAdapter->device_mode)
751 {
752 hdd_disconnect_tx_rx(pAdapter);
753 }
754 else
755 {
756 // Need to cleanup all queues only if the last peer leaves
757 if (eConnectionState_IbssDisconnected == pHddStaCtx->conn_info.connState)
758 {
759 netif_tx_disable(pAdapter->dev);
760 netif_carrier_off(pAdapter->dev);
761 hdd_disconnect_tx_rx(pAdapter);
762 }
763 else
764 {
765 // There is atleast one more peer, do not cleanup all queues
766 hdd_flush_ibss_tx_queues(pAdapter, staId);
767 }
768 }
769
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
771 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
772 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700775 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700776 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700777 }
778 return( vosStatus );
779}
780
781
782static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
783 tANI_U32 roamId, eRoamCmdStatus roamStatus,
784 eCsrRoamResult roamResult )
785{
786 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700787 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 struct net_device *dev = pAdapter->dev;
789 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
790 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700791 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530792 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700793
794 // Sanity check
795 if(dev == NULL)
796 {
Agarwal Ashish971c2882013-10-30 20:11:12 +0530797 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700798 "%s: net_dev is released return", __func__);
799 return eHAL_STATUS_FAILURE;
800 }
801
Jeff Johnson295189b2012-06-20 16:38:30 -0700802 // notify apps that we can't pass traffic anymore
803 netif_tx_disable(dev);
804 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700805
Jeff Johnsone7245742012-09-05 17:12:55 -0700806 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530807 /* HDD has initiated disconnect, do not send disconnect indication
808 * to kernel as it will be handled by __cfg80211_disconnect.
809 */
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530810 /* If only STA mode is on */
811 if((pHddCtx->concurrency_mode <= 1) &&
812 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
813 {
814 pHddCtx->isAmpAllowed = VOS_TRUE;
815 }
816
Agarwal Ashish47d18112014-08-04 19:55:07 +0530817 /* Need to apply spin lock before decreasing active sessions
818 * as there can be chance for double decrement if context switch
819 * Calls wlan_hdd_disconnect.
820 */
821
822 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530823 if ( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState )
824 {
825 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
826 FL(" HDD has initiated a disconnect, no need to send"
827 " disconnect indication to kernel"));
828 sendDisconInd = FALSE;
829 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530830 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700831 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530832 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +0530833 FL(" Set HDD connState to eConnectionState_Disconnecting from %d "),
834 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530835 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
836 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 }
Agarwal Ashish47d18112014-08-04 19:55:07 +0530838 spin_unlock_bh(&pAdapter->lock_for_active_session);
839
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -0700841
842 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -0700843
844 // indicate 'disconnect' status to wpa_supplicant...
845 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 /* indicate disconnected event to nl80211 */
847 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
848 {
849 /*During the WLAN uninitialization,supplicant is stopped before the
850 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530851 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700852 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700853 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
854 "%s: sent disconnected event to nl80211",
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700856#ifdef WLAN_FEATURE_P2P_DEBUG
857 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
858 {
859 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
860 {
861 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
862 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
863 "and moved to disconnected state");
864 }
865 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
866 {
867 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
868 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
869 "and moved to inactive state");
870 }
871 }
872#endif
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530873 /*Only send indication to kernel if not initiated by kernel*/
874 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530876 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
877 if ( eCSR_ROAM_LOSTLINK == roamStatus )
878 {
879 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
880 }
881 else
882 {
883 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
884 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 //If the Device Mode is Station
887 // and the P2P Client is Connected
888 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700889
890 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -0700891 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -0700892 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 {
894 //Enable BMPS only of other Session is P2P Client
895 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700896 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -0700897
898 if (NULL != pVosContext)
899 {
900 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
901
902 if(NULL != pHddCtx)
903 {
904 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +0530905 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
906 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530908 if (pHddCtx->hdd_wlan_suspended)
909 {
910 hdd_set_pwrparams(pHddCtx);
911 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530913 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 }
915 }
916 }
917 }
918 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700919
krunal soni3fc26642013-10-08 22:41:42 -0700920 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
921 {
922 sta_id = IBSS_BROADCAST_STAID;
923 }
924 else
925 {
926 sta_id = pHddStaCtx->conn_info.staId[0];
927 }
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +0530928 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +0530929#if defined(WLAN_FEATURE_VOWIFI_11R)
930 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
931#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 //We should clear all sta register with TL, for now, only one.
krunal soni3fc26642013-10-08 22:41:42 -0700933 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
Jeff Johnson43971f52012-07-17 12:26:56 -0700934 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700937 "hdd_roamDeregisterSTA() failed to for staID %d. "
938 "Status= %d [0x%x]",
krunal soni3fc26642013-10-08 22:41:42 -0700939 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700940
941 status = eHAL_STATUS_FAILURE;
942 }
943
krunal soni3fc26642013-10-08 22:41:42 -0700944 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 // Clear saved connection information in HDD
946 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +0530947 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
948 "%s: Set HDD connState to eConnectionState_NotConnected",
949 __func__);
950 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530951#ifdef WLAN_FEATURE_GTK_OFFLOAD
952 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
953 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
954 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +0530955 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
956 sizeof (tSirGtkOffloadParams));
957 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530958 }
959#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700960
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800961#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -0700962 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
963 {
964 wlan_hdd_tdls_disconnection_callback(pAdapter);
965 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800966#endif
967
Jeff Johnson295189b2012-06-20 16:38:30 -0700968 //Unblock anyone waiting for disconnect to complete
969 complete(&pAdapter->disconnect_comp_var);
970 return( status );
971}
972static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
973 tCsrRoamInfo *pRoamInfo,
974 v_U8_t staId,
975 v_MACADDR_t *pPeerMacAddress,
976 tSirBssDescription *pBssDesc )
977{
978 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
979 WLAN_STADescType staDesc = {0};
980 eCsrEncryptionType connectedCipherAlgo;
981 v_BOOL_t fConnected;
982 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
983 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -0700984 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700985
986 if ( NULL == pBssDesc)
987 {
988 return VOS_STATUS_E_FAILURE;
989 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 // Get the Station ID from the one saved during the assocation.
991 staDesc.ucSTAId = staId;
992
993 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
Jeff Johnson295189b2012-06-20 16:38:30 -0700994 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700995 staDesc.wSTAType = WLAN_STA_INFRA;
996
997 // grab the bssid from the connection info in the adapter structure and hand that
998 // over to TL when registering.
999 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
1000 }
1001 else
1002 {
1003 // for an IBSS 'connect', setup the Station Descriptor for TL.
Jeff Johnson295189b2012-06-20 16:38:30 -07001004 staDesc.wSTAType = WLAN_STA_IBSS;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001005
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
1007 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
1008 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
1009 // pass when making an Infrastructure connection.
1010 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
1011 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
1012 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001013
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1015
1016 // set the QoS field appropriately
1017 if (hdd_wmm_is_active(pAdapter))
1018 {
1019 staDesc.ucQosEnabled = 1;
1020 }
1021 else
1022 {
1023 staDesc.ucQosEnabled = 0;
1024 }
1025
1026 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1027 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1028 {
1029 staDesc.ucProtectedFrame = 1;
1030 }
1031 else
1032 {
1033 staDesc.ucProtectedFrame = 0;
1034
1035 }
1036
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001037#ifdef FEATURE_WLAN_ESE
1038 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1039#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001040
1041#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1042 /* check whether replay check is valid for the station or not */
1043 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1044 {
1045 /* Encryption mode is either TKIP or AES
1046 and replay check is valid for only these
1047 two encryption modes */
1048 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1049 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1050 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1051 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001052
Jeff Johnson295189b2012-06-20 16:38:30 -07001053 else
1054 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001055 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001057 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1059 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1060 }
1061#endif
1062
1063#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001064 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 if (pAdapter->wapi_info.fIsWapiSta)
1066 {
1067 staDesc.ucIsWapiSta = 1;
1068 }
1069 else
1070 {
1071 staDesc.ucIsWapiSta = 0;
1072 }
1073#endif /* FEATURE_WLAN_WAPI */
1074
1075 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1076 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1077
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 // UMA is Not ready yet, Xlation will be done by TL
1079 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 staDesc.ucSwFrameRXXlation = 1;
1081 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001082 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001083 staDesc.ucQosEnabled );
1084 // Initialize signatures and state
1085 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1086 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1087 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1088 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001089 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001090 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 -07001091 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1092 hdd_rx_packet_cbk,
1093 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001094 hdd_tx_fetch_packet_cbk, &staDesc,
1095 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001096
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1098 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001099 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001100 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001101 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001102 return vosStatus;
1103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001104
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001105 if ( cfg_param->dynSplitscan &&
1106 ( VOS_TIMER_STATE_RUNNING !=
1107 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1108 {
1109 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1110 cfg_param->trafficMntrTmrForSplitScan);
1111 }
1112
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301113 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1114 // then go to 'authenticated'. For all other authentication types
1115 // (those that donot require upper layer authentication) we can put
1116 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001117 if (staDesc.wSTAType != WLAN_STA_IBSS)
1118 VOS_ASSERT( fConnected );
1119
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301120 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001121 {
1122 // Connections that do not need Upper layer auth, transition TL directly
1123 // to 'Authenticated' state.
1124 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1125 WLANTL_STA_AUTHENTICATED );
1126
1127 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1128 }
1129 else
1130 {
1131 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301132 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1133 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001134 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301135 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001136 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 return( vosStatus );
1139}
1140
Jeff Johnson295189b2012-06-20 16:38:30 -07001141static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1142 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1143{
1144 unsigned int len = 0;
1145 u8 *pFTAssocRsp = NULL;
Agarwal Ashish51325b52014-06-16 16:50:49 +05301146 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001147 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 tANI_U32 rspRsnLength = 0;
1149 struct ieee80211_channel *chan;
1150
Agarwal Ashish51325b52014-06-16 16:50:49 +05301151 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001152 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001153 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001154 }
1155
Agarwal Ashish51325b52014-06-16 16:50:49 +05301156 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001157 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1158 goto done;
1159 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001160
Agarwal Ashish51325b52014-06-16 16:50:49 +05301161 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001162 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1163 goto done;
1164 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001165
1166 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1167 pCsrRoamInfo->nAssocReqLength);
1168 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001169 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001170
1171 //pFTAssocRsp needs to point to the IEs
1172 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001173 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001174 (unsigned int)pFTAssocRsp[0],
1175 (unsigned int)pFTAssocRsp[1]);
1176
Agarwal Ashish51325b52014-06-16 16:50:49 +05301177 /* Active session count is decremented upon disconnection, but during
1178 * roaming, there is no disconnect indication and hence active session
1179 * count is not decremented.
1180 * After roaming is completed, active session count is incremented
1181 * as a part of connect indication but effectively after roaming the
1182 * active session count should still be the same and hence upon
1183 * successful reassoc decrement the active session count here */
1184
1185 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
1186
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001188 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001191 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001192
1193 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1194 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1195 reqRsnIe, reqRsnLength,
1196 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001197
1198done:
1199 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001200}
Jeff Johnson295189b2012-06-20 16:38:30 -07001201
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301202void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1203{
1204 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1205 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1206 tCsrRoamInfo roamInfo;
1207 roamInfo.fAuthRequired = FALSE;
1208 vos_mem_copy(roamInfo.bssid,
1209 pHddStaCtx->roam_info.bssid,
1210 WNI_CFG_BSSID_LEN);
1211 vos_mem_copy(roamInfo.peerMac,
1212 pHddStaCtx->roam_info.peerMac,
1213 WNI_CFG_BSSID_LEN);
1214
1215 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1216 &roamInfo,
1217 pHddStaCtx->roam_info.roamId,
1218 pHddStaCtx->roam_info.roamStatus,
1219 eCSR_ROAM_RESULT_AUTHENTICATED);
1220 if (halStatus != eHAL_STATUS_SUCCESS)
1221 {
1222 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1223 }
1224 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1225}
1226
Shailender Karmuchia734f332013-04-19 14:02:48 -07001227static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1228 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 eCsrRoamResult roamResult )
1230{
1231 struct net_device *dev = pAdapter->dev;
1232 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1233 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301234 hdd_adapter_t *pHostapdAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001236 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1237 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001238#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 int ft_carrier_on = FALSE;
1240#endif
1241 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301242 v_BOOL_t hddDisconInProgress = FALSE;
1243
1244 /* HDD has initiated disconnect, do not send connect result indication
1245 * to kernel as it will be handled by __cfg80211_disconnect.
1246 */
1247 if(( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) &&
1248 (( eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1249 ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)) )
1250 {
1251 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1252 FL(" Disconnect from HDD in progress "));
1253 hddDisconInProgress = TRUE;
1254 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001255
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1257 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301258 if ( !hddDisconInProgress )
1259 {
1260 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301261 "%s: Set HDD connState to eConnectionState_Associated",
1262 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301263 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001265
c_hpothu44ff4e02014-05-08 00:13:57 +05301266 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 // Save the connection info from CSR...
1268 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1269#ifdef FEATURE_WLAN_WAPI
1270 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1271 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1272 {
1273 pAdapter->wapi_info.fIsWapiSta = 1;
1274 }
1275 else
1276 {
1277 pAdapter->wapi_info.fIsWapiSta = 0;
1278 }
1279#endif /* FEATURE_WLAN_WAPI */
1280
1281 // indicate 'connect' status to userspace
1282 hdd_SendAssociationEvent(dev,pRoamInfo);
1283
1284
Shailender Karmuchia734f332013-04-19 14:02:48 -07001285 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001286 INIT_COMPLETION(pAdapter->linkup_event_var);
1287
1288 /*
1289 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1290 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 -07001291 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 know that the device is getting activated properly.
1293 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001294#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 if (pHddStaCtx->ft_carrier_on == FALSE)
1296 {
1297#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001298 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 pAdapter->isLinkUpSvcNeeded = TRUE;
1300
Shailender Karmuchia734f332013-04-19 14:02:48 -07001301 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 pAdapter->isLinkUpSvcNeeded = TRUE;
1303
1304 // Switch on the Carrier to activate the device
1305 netif_carrier_on(dev);
1306
1307 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1308 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1309 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001310 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 {
1312 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1313 }
1314
1315 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1316 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001317#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001318 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001319 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 }
1323#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301324 /* Check for STAID */
1325 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1326 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1327 else
1328 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001329
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001330#ifdef FEATURE_WLAN_TDLS
1331 wlan_hdd_tdls_connection_callback(pAdapter);
1332#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 //For reassoc, the station is already registered, all we need is to change the state
1334 //of the STA in TL.
1335 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
1336 if( !pRoamInfo->fReassocReq )
1337 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001338 struct cfg80211_bss *bss;
1339#ifdef WLAN_FEATURE_VOWIFI_11R
1340 u8 *pFTAssocRsp = NULL;
1341 unsigned int assocRsplen = 0;
1342 u8 *pFTAssocReq = NULL;
1343 unsigned int assocReqlen = 0;
1344 struct ieee80211_channel *chan;
1345#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001348
1349 /* add bss_id to cfg80211 data base */
1350 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1351 if (NULL == bss)
1352 {
1353 pr_err("wlan: Not able to create BSS entry\n");
1354 return eHAL_STATUS_FAILURE;
1355 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001356#ifdef WLAN_FEATURE_VOWIFI_11R
1357 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001358 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001360
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001361 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001362 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001363 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001364 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001365 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001366 // pFTAssocRsp needs to point to the IEs
1367 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1368 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1369 (unsigned int)pFTAssocRsp[0],
1370 (unsigned int)pFTAssocRsp[1]);
1371 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001372 }
1373 else
1374 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001375 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1376 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001377 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001378
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001379 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001380 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001381 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001382 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001383 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001384 if(!ft_carrier_on)
1385 {
1386 // pFTAssocReq needs to point to the IEs
1387 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1388 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1389 (unsigned int)pFTAssocReq[0],
1390 (unsigned int)pFTAssocReq[1]);
1391 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1392 }
1393 else
1394 {
1395 /* This should contain only the FTIEs */
1396 assocReqlen = pRoamInfo->nAssocReqLength;
1397 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001398 }
1399 else
1400 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001401 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1402 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001403 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001404
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001405 if(ft_carrier_on)
1406 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301407 if ( !hddDisconInProgress )
1408 {
1409 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001410 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301411 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001412 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301413 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001414 assocRsplen);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301415 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001416 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1417 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301418 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301419 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1420 {
1421 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1422 pRoamInfo->fAuthRequired = FALSE;
1423
1424 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1425 pRoamInfo->bssid,
1426 HDD_MAC_ADDR_LEN);
1427 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1428 pRoamInfo->peerMac,
1429 HDD_MAC_ADDR_LEN);
1430 pHddStaCtx->roam_info.roamId = roamId;
1431 pHddStaCtx->roam_info.roamStatus = roamStatus;
1432 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1433 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001434 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301435 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001436 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001437 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001438 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001439 cfg80211_connect_result(dev, pRoamInfo->bssid,
1440 pFTAssocReq, assocReqlen,
1441 pFTAssocRsp, assocRsplen,
1442 WLAN_STATUS_SUCCESS,
1443 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001444 }
1445 }
1446 else
1447#endif
1448 {
1449 /* wpa supplicant expecting WPA/RSN IE in connect result */
1450 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1451 pAdapter->sessionId,
1452 &reqRsnLength,
1453 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001454
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001455 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1456 pAdapter->sessionId,
1457 &rspRsnLength,
1458 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301459 if ( !hddDisconInProgress )
1460 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001461#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301462 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301463 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301464 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Mukul Sharma84f27252014-07-14 18:11:42 +05301465#ifdef DEBUG_ROAM_DELAY
1466 //HACK we are using the buff len as Auth Type
1467 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1468#endif
1469 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301470 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001471#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001472
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301473 {
1474 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301475 "%s: sending connect indication to nl80211:"
1476 " for bssid " MAC_ADDRESS_STR
1477 " reason:%d and Status:%d\n",
1478 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1479 roamResult, roamStatus);
1480
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301481 /* inform connect result to nl80211 */
1482 cfg80211_connect_result(dev, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001483 reqRsnIe, reqRsnLength,
1484 rspRsnIe, rspRsnLength,
1485 WLAN_STATUS_SUCCESS,
1486 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301487 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301490 if ( !hddDisconInProgress )
1491 {
1492 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001493#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301494 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001495#endif
1496 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301497 // Register the Station with TL after associated...
1498 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 pRoamInfo,
1500 pHddStaCtx->conn_info.staId[ 0 ],
1501 NULL,
1502 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 }
1505 else
1506 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001507 /* wpa supplicant expecting WPA/RSN IE in connect result */
1508 /* in case of reassociation also need to indicate it to supplicant */
1509 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1510 pAdapter->sessionId,
1511 &reqRsnLength,
1512 reqRsnIe);
1513
1514 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001515 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301516 if( pRoamInfo->fAuthRequired )
1517 {
1518 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1519 pHddStaCtx->conn_info.staId[ 0 ],
1520 WLANTL_STA_CONNECTED );
1521 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1522 }
1523 else
1524 {
1525 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1526 "%s: staId: %d Changing TL state to AUTHENTICATED",
1527 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1528 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1529 pHddStaCtx->conn_info.staId[ 0 ],
1530 WLANTL_STA_AUTHENTICATED );
1531 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 }
1534
1535 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1536 {
1537 // perform any WMM-related association processing
1538 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1539 }
1540 else
1541 {
1542 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001543 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 vosStatus, vosStatus );
1545 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001546#ifdef WLAN_FEATURE_11W
1547 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1548 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1549#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 // Start the Queue
1551 netif_tx_wake_all_queues(dev);
Mukul Sharma84f27252014-07-14 18:11:42 +05301552#ifdef DEBUG_ROAM_DELAY
1553 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1554#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001555 }
1556 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001558 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1559
1560 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001561 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001562 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1563 " reason:%d and Status:%d\n",
1564 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1565 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001566 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001567 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1568 " reason:%d and Status:%d\n",
1569 MAC_ADDR_ARRAY(pWextState->req_bssId),
1570 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001571
Abhishek Singhf4669da2014-05-26 15:07:49 +05301572 /* Set connection state to eConnectionState_NotConnected only when CSR
1573 * has completed operation - with a ASSOCIATION_FAILURE status
1574 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301575 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301576 {
1577 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1578 "%s: Set HDD connState to eConnectionState_NotConnected",
1579 __func__);
1580 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1581 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05301582 if((pHddCtx->concurrency_mode <= 1) &&
1583 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07001584 {
1585 pHddCtx->isAmpAllowed = VOS_TRUE;
1586 }
1587
1588 //If the Device Mode is Station
1589 // and the P2P Client is Connected
1590 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001591
1592 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001593 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001594 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1595 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05301596 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 {
1598 //Enable BMPS only of other Session is P2P Client
1599 hdd_context_t *pHddCtx = NULL;
1600 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1601
1602 if (NULL != pVosContext)
1603 {
1604 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1605
1606 if(NULL != pHddCtx)
1607 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301608 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301609 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1610 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301611 {
1612 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001613 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301614 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001615 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301616 hdd_enable_bmps_imps(pHddCtx);
1617 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 }
1619 }
1620 }
1621
James Zmudafbf5ffc2013-03-25 12:45:35 -07001622 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001623 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301624 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07001625 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301626 if (pRoamInfo)
1627 hddLog(VOS_TRACE_LEVEL_ERROR,
1628 "%s: send connect failure to nl80211:"
1629 " for bssid " MAC_ADDRESS_STR
1630 " reason:%d and Status:%d\n" ,
1631 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1632 roamResult, roamStatus);
1633 else
1634 hddLog(VOS_TRACE_LEVEL_ERROR,
1635 "%s: connect failed:"
1636 " for bssid " MAC_ADDRESS_STR
1637 " reason:%d and Status:%d\n" ,
1638 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1639 roamResult, roamStatus);
1640
c_hpothudaa90e22014-06-24 17:23:43 +05301641 /*Clear the roam profile*/
1642 hdd_clearRoamProfileIe( pAdapter );
1643
James Zmudafbf5ffc2013-03-25 12:45:35 -07001644 /* inform association failure event to nl80211 */
1645 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1646 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001647 if (pRoamInfo)
1648 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1649 NULL, 0, NULL, 0,
1650 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1651 GFP_KERNEL );
1652 else
1653 cfg80211_connect_result ( dev, pWextState->req_bssId,
1654 NULL, 0, NULL, 0,
1655 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1656 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001657 }
1658 else
1659 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001660 if (pRoamInfo)
1661 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1662 NULL, 0, NULL, 0,
1663 WLAN_STATUS_UNSPECIFIED_FAILURE,
1664 GFP_KERNEL );
1665 else
1666 cfg80211_connect_result ( dev, pWextState->req_bssId,
1667 NULL, 0, NULL, 0,
1668 WLAN_STATUS_UNSPECIFIED_FAILURE,
1669 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001670 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001672
Kumar Anand82c009f2014-05-29 00:29:42 -07001673 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001674
c_hpothu24f40982014-04-18 18:00:36 +05301675 if (pRoamInfo)
1676 {
1677 WLANTL_AssocFailed(pRoamInfo->staId);
1678 }
Mihir Sheteb7337272014-04-11 15:53:08 +05301679
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 netif_tx_disable(dev);
1681 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001682
Jeff Johnson295189b2012-06-20 16:38:30 -07001683 }
1684
Sushant Kaushikbf584e92014-08-06 17:59:20 +05301685 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301686 {
1687 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
1688 if (pHostapdAdapter != NULL)
1689 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05301690 /* Restart SAP if its operating channel is different
1691 * from AP channel.
1692 */
1693 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
1694 (int)pRoamInfo->pBssDesc->channelId)
1695 {
1696 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
1697 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
1698 (int)pRoamInfo->pBssDesc->channelId);
1699 hdd_restart_softap(pHddCtx, pHostapdAdapter);
1700 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301701 }
1702 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001703 return eHAL_STATUS_SUCCESS;
1704}
1705
1706/**============================================================================
1707 *
Jeff Johnson81c17882013-05-03 09:53:35 -07001708 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07001710
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07001712static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
1713 tCsrRoamInfo *pRoamInfo,
1714 tANI_U32 roamId,
1715 eRoamCmdStatus roamStatus,
1716 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07001717{
Jeff Johnson81c17882013-05-03 09:53:35 -07001718 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
1719 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
1720
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 switch( roamResult )
1722 {
1723 // both IBSS Started and IBSS Join should come in here.
1724 case eCSR_ROAM_RESULT_IBSS_STARTED:
1725 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001726 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07001727 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001728 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1729 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001730
Jeff Johnson81c17882013-05-03 09:53:35 -07001731 if (NULL == pRoamInfo)
1732 {
1733 VOS_ASSERT(0);
1734 return;
1735 }
1736
1737 /* When IBSS Started comes from CSR, we need to move
1738 * connection state to IBSS Disconnected (meaning no peers
1739 * are in the IBSS).
1740 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05301741 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1742 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
1743 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07001744 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
1745 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05301746 /*notify wmm */
1747 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001748 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1749 hdd_roamRegisterSTA (pAdapter, pRoamInfo,
1750 IBSS_BROADCAST_STAID,
1751 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001752
Jeff Johnson81c17882013-05-03 09:53:35 -07001753 if (pRoamInfo->pBssDesc)
1754 {
1755 struct cfg80211_bss *bss;
1756
1757 /* we created the IBSS, notify supplicant */
1758 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
1759 MAC_ADDRESS_STR,
1760 __func__, pAdapter->dev->name,
1761 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
1762
1763 /* we must first give cfg80211 the BSS information */
1764 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1765 if (NULL == bss)
1766 {
1767 hddLog(VOS_TRACE_LEVEL_ERROR,
1768 "%s: %s: unable to create IBSS entry",
1769 __func__, pAdapter->dev->name);
1770 return;
1771 }
1772
1773 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001774 cfg80211_put_bss(
1775#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1776 pHddCtx->wiphy,
1777#endif
1778 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07001779 }
1780
Jeff Johnson295189b2012-06-20 16:38:30 -07001781 break;
1782 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001783
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1785 {
Jeff Johnson81c17882013-05-03 09:53:35 -07001786 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
1787 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 break;
1789 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001790
Jeff Johnson295189b2012-06-20 16:38:30 -07001791 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07001792 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
1793 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001795 }
1796
Jeff Johnson81c17882013-05-03 09:53:35 -07001797 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001798}
1799
1800/**============================================================================
1801 *
1802 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1803 This information is passed to iwconfig later. The peer that joined
1804 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001805 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001806 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001807
Jeff Johnson295189b2012-06-20 16:38:30 -07001808 ===========================================================================*/
1809static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1810{
1811 int fSuccess = FALSE;
1812 int idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001813
Jeff Johnson295189b2012-06-20 16:38:30 -07001814 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1815 {
1816 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1817 {
1818 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001819
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001821
Jeff Johnson295189b2012-06-20 16:38:30 -07001822 fSuccess = TRUE;
1823 break;
1824 }
1825 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001826
1827 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07001828}
1829/**============================================================================
1830 *
1831 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001832 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001834
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07001836static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07001837{
1838 int fSuccess = FALSE;
1839 int idx = 0;
1840 v_U8_t valid_idx = 0;
1841 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07001842 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001843 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001844
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1846 {
1847 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1848 {
1849 pHddStaCtx->conn_info.staId[ idx ] = 0;
1850
1851 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1852
1853 fSuccess = TRUE;
Ravi Joshi8a934352013-09-25 16:46:58 -07001854
Jeff Johnson295189b2012-06-20 16:38:30 -07001855 // Note the deleted Index, if its 0 we need special handling
1856 del_idx = idx;
Ravi Joshi8a934352013-09-25 16:46:58 -07001857
1858 empty_slots++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 }
1860 else
1861 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001862 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 {
1864 valid_idx = idx;
1865 }
Ravi Joshi8a934352013-09-25 16:46:58 -07001866 else
1867 {
1868 // Found an empty slot
1869 empty_slots++;
1870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 }
1872 }
1873
Ravi Joshi8a934352013-09-25 16:46:58 -07001874 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
1875 {
1876 // Last peer departed, set the IBSS state appropriately
1877 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001878 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07001879 "Last IBSS Peer Departed!!!" );
1880 }
1881
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 // Find next active staId, to have a valid sta trigger for TL.
1883 if (fSuccess == TRUE)
1884 {
1885 if (del_idx == 0)
1886 {
1887 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1888 {
1889 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1890 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1891 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1892
1893 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1894 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1895 }
1896 }
1897 }
1898 return( fSuccess );
1899}
1900
1901/**============================================================================
1902 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001903 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001905
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 ===========================================================================*/
1907static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1908{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001909 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05301910 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1911 "%s: IBSS Connect Indication from SME!!! "
1912 "Set HDD connState to eConnectionState_IbssConnected",
1913 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1915 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1916
1917 // Save the connection info from CSR...
1918 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1919
1920 // Send the bssid address to the wext.
1921 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001923 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1924 if (NULL == bss)
1925 {
1926 hddLog(VOS_TRACE_LEVEL_ERROR,
1927 "%s: %s: unable to create IBSS entry",
1928 __func__, pAdapter->dev->name);
1929 return eHAL_STATUS_FAILURE;
1930 }
Yue Maf49ba872013-08-19 12:04:25 -07001931 cfg80211_put_bss(
1932#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1933 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
1934#endif
1935 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001936
1937 return( eHAL_STATUS_SUCCESS );
1938}
1939/**============================================================================
1940 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05301941 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
1942 suspend related data which was cleared during roaming in FWR.
1943
1944 ===========================================================================*/
1945static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
1946{
1947 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
1948 hdd_adapter_t *pAdapter;
1949 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
1950 ENTER();
1951
1952 spin_lock(&pHddCtx->filter_lock);
1953 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
1954 {
1955 pHddCtx->sus_res_mcastbcast_filter =
1956 pHddCtx->configuredMcastBcastFilter;
1957 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
1958 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
1959 hddLog(VOS_TRACE_LEVEL_INFO,
1960 FL("saving configuredMcastBcastFilter = %d"),
1961 pHddCtx->configuredMcastBcastFilter);
1962 hddLog(VOS_TRACE_LEVEL_INFO,
1963 FL("offload: calling hdd_conf_mcastbcast_filter"));
1964 }
1965 spin_unlock(&pHddCtx->filter_lock);
1966
1967 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
1968 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
1969 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
1970
1971 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
1972 //No need to configure GTK Offload from here because it might possible
1973 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
1974 //be handled as part of cfg80211_set_rekey_data processing.
1975 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
1976 {
1977 pAdapter = pAdapterNode->pAdapter;
1978 if( pAdapter &&
1979 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1980 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
1981 {
1982 if (pHddCtx->cfg_ini->fhostArpOffload)
1983 {
1984 //Configure ARPOFFLOAD
1985 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
1986 if (!VOS_IS_STATUS_SUCCESS(vstatus))
1987 {
1988 hddLog(VOS_TRACE_LEVEL_ERROR,
1989 FL("Failed to disable ARPOffload Feature %d"), vstatus);
1990 }
1991 }
1992#ifdef WLAN_NS_OFFLOAD
1993 //Configure NSOFFLOAD
1994 if (pHddCtx->cfg_ini->fhostNSOffload)
1995 {
1996 hdd_conf_ns_offload(pAdapter, TRUE);
1997 }
1998#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05301999#ifdef WLAN_FEATURE_PACKET_FILTERING
2000 /* During suspend, configure MC Addr list filter to the firmware
2001 * function takes care of checking necessary conditions before
2002 * configuring.
2003 */
2004 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
2005#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05302006 }
2007 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2008 pAdapterNode = pNext;
2009 }
2010 EXIT();
2011}
2012
2013/**============================================================================
2014 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002016
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002018static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2019 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002020 eCsrRoamResult roamResult )
2021{
2022 eCsrEncryptionType connectedCipherAlgo;
2023 v_BOOL_t fConnected = FALSE;
2024 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2025 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2026 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2027 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002028
2029 if (NULL == pRoamInfo)
2030 {
2031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2032 return eHAL_STATUS_FAILURE;
2033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002035 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 // not require upper layer authentication) we can put TL directly into 'authenticated'
2037 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2039 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2040 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002041
Jeff Johnson295189b2012-06-20 16:38:30 -07002042 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2043 if( fConnected )
2044 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002045 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2046 {
2047 v_U8_t staId;
2048
2049 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2050
2051 if ( 0 == memcmp( pRoamInfo->peerMac,
2052 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2053 {
2054 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2055 IBSS_BROADCAST_STAID);
2056 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2057 }
2058 else
2059 {
2060 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2061 (v_MACADDR_t*)pRoamInfo->peerMac,
2062 &staId);
2063 if ( VOS_STATUS_SUCCESS == vosStatus )
2064 {
2065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2066 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2067 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2068 staId);
2069 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2070 }
2071 }
2072 }
2073 else
2074 {
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302075 // TODO: Considering getting a state machine in HDD later.
2076 // This routine is invoked twice. 1)set PTK 2)set GTK.
2077 // The folloing if statement will be TRUE when setting GTK.
2078 // At this time we don't handle the state in detail.
2079 // Related CR: 174048 - TL not in authenticated state
2080 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2081 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2082 {
2083 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2084 "for StaId= %d. Changing TL state to AUTHENTICATED",
2085 pHddStaCtx->conn_info.staId[ 0 ] );
2086
2087 // Connections that do not need Upper layer authentication,
2088 // transition TL to 'Authenticated' state after the keys are set.
2089 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2090 pHddStaCtx->conn_info.staId[ 0 ],
2091 WLANTL_STA_AUTHENTICATED );
2092
2093 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Mukul Sharmad2589a52014-04-23 21:06:25 +05302094 //Need to call offload because when roaming happen at that time fwr
2095 //clean offload info as part of the DelBss
2096 // No need to configure offload if host was not suspended
2097 spin_lock(&pHddCtx->filter_lock);
2098 if(pHddCtx->hdd_wlan_suspended)
2099 {
2100 spin_unlock(&pHddCtx->filter_lock);
2101 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2102 }
2103 else
2104 {
2105 spin_unlock(&pHddCtx->filter_lock);
2106 }
Mukul Sharma84f27252014-07-14 18:11:42 +05302107#ifdef DEBUG_ROAM_DELAY
2108 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2109#endif
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302110 }
2111 else
2112 {
2113 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2114 pHddStaCtx->conn_info.staId[ 0 ]);
Mukul Sharma84f27252014-07-14 18:11:42 +05302115#ifdef DEBUG_ROAM_DELAY
2116 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2117#endif
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302118 }
2119
2120 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302123 else
2124 {
2125 // possible disassoc after issuing set key and waiting set key complete
2126 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2127 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002128
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 EXIT();
2130 return( eHAL_STATUS_SUCCESS );
2131}
2132/**============================================================================
2133 *
2134 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2135 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002136static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002138{
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2140
2141 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2142 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2143 {
2144 struct iw_michaelmicfailure msg;
2145 union iwreq_data wreq;
2146 memset(&msg, '\0', sizeof(msg));
2147 msg.src_addr.sa_family = ARPHRD_ETHER;
2148 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002149 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2150 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002151
Jeff Johnson295189b2012-06-20 16:38:30 -07002152 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2153 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002154 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002155 msg.flags = IW_MICFAILURE_PAIRWISE;
2156 memset(&wreq, 0, sizeof(wreq));
2157 wreq.data.length = sizeof(msg);
2158 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002160 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2162 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2163 NL80211_KEYTYPE_GROUP :
2164 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002165 pRoamInfo->u.pMICFailureInfo->keyId,
2166 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002168
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002170
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 return( eHAL_STATUS_SUCCESS );
2172}
2173
2174/**============================================================================
2175 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002176 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002177 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002178
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002180static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2181 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002182 eCsrRoamResult roamResult )
2183{
2184 VOS_STATUS vosStatus;
2185
2186 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2187 switch( roamResult )
2188 {
2189 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2190 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002191 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002192 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002193
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002194 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002195 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2196 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2197 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002199
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
2201 {
2202 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2203 "New IBSS peer but we already have the max we can handle. Can't register this one" );
2204 break;
2205 }
2206
2207 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2208
Shailender Karmuchia734f332013-04-19 14:02:48 -07002209 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2210 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2211 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2212
2213 // Register the Station with TL for the new peer.
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 vosStatus = hdd_roamRegisterSTA( pAdapter,
2215 pRoamInfo,
2216 pRoamInfo->staId,
2217 (v_MACADDR_t *)pRoamInfo->peerMac,
2218 pRoamInfo->pBssDesc );
2219 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2220 {
2221 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002222 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 vosStatus, vosStatus );
2224 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002225 pHddStaCtx->ibss_sta_generation++;
2226 memset(&staInfo, 0, sizeof(staInfo));
2227 staInfo.filled = 0;
2228 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2229
2230 cfg80211_new_sta(pAdapter->dev,
2231 (const u8 *)pRoamInfo->peerMac,
2232 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002233
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002234 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2235 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2236 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2237 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2238 {
2239 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2240 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2241 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2242
2243 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002244 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002245 pHddStaCtx->ibss_enc_key.encType);
2246
2247 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2248 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2249
2250 if ( VOS_STATUS_SUCCESS != vosStatus )
2251 {
2252 hddLog(VOS_TRACE_LEVEL_ERROR,
2253 "%s: sme_RoamSetKey failed, returned %d",
2254 __func__, vosStatus);
2255 return VOS_STATUS_E_FAILURE;
2256 }
2257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002258 netif_carrier_on(pAdapter->dev);
2259 netif_tx_start_all_queues(pAdapter->dev);
2260 break;
2261 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002262
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2264 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002265
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002267
Jeff Johnson295189b2012-06-20 16:38:30 -07002268 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002270 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2271 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002272 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002273
Ravi Joshicc57ed42013-10-12 16:31:25 -07002274 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002275 {
2276 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2277 "IBSS peer departed by cannot find peer in our registration table with TL" );
2278 }
2279
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002280 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002281 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2282 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2283 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2284 pRoamInfo->staId );
2285
Jeff Johnson295189b2012-06-20 16:38:30 -07002286 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
2287
2288 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002289 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002290
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002291 cfg80211_del_sta(pAdapter->dev,
2292 (const u8 *)&pRoamInfo->peerMac,
2293 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 break;
2295 }
2296 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2297 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002298 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2299 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 // Stop only when we are inactive
2301 netif_tx_disable(pAdapter->dev);
2302 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302303 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2304 "%s: Set HDD connState to eConnectionState_NotConnected",
2305 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002307
Jeff Johnson295189b2012-06-20 16:38:30 -07002308 // Send the bssid address to the wext.
2309 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2310 // clean up data path
2311 hdd_disconnect_tx_rx(pAdapter);
2312 break;
2313 }
2314 default:
2315 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002316
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002318
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 return( eHAL_STATUS_SUCCESS );
2320}
2321
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002322#ifdef FEATURE_WLAN_TDLS
2323/**============================================================================
2324 *
2325 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2326 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2327 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002328
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002329 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002330VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2331 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002332{
2333 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002334 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002335 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2336 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002337 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2338 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002339 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2340 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002341
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002342 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2343 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002344 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002345 "%s not connected. ignored", __func__);
2346 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002347 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002348
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002349 /*
2350 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2351 * be peer MAC, here we are wokrking on direct Link
2352 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002353 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002354
2355 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002356
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002357 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002358 sizeof(tSirMacAddr) );
2359
2360 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2361 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2362
2363 /* set the QoS field appropriately ..*/
2364 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2365 : (staDesc.ucQosEnabled = 0) ;
2366
2367 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002368 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002369
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002370 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002371
2372 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002373 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002374
Shailender Karmuchia734f332013-04-19 14:02:48 -07002375 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002376 * UMA is ready we inform TL to do frame translation.
2377 */
2378 staDesc.ucSwFrameTXXlation = 1;
2379 staDesc.ucSwFrameRXXlation = 1;
2380 staDesc.ucAddRmvLLC = 1;
2381
2382 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002383 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002384
2385 /* tdls Direct Link do not need bcastSig */
2386 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002387
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002388#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2389 if(staDesc.ucProtectedFrame)
2390 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2391 else
2392 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2393#endif
2394
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302395 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002396
Shailender Karmuchia734f332013-04-19 14:02:48 -07002397 /* Register the Station with TL... */
2398 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2399 hdd_rx_packet_cbk,
2400 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002401 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002402
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002403 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2404 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002405 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002406 "%s: WLANTL_RegisterSTAClient() failed to register. "
2407 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002408 return vosStatus;
2409 }
2410
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002411 if ( cfg_param->dynSplitscan &&
2412 ( VOS_TIMER_STATE_RUNNING !=
2413 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2414 {
2415 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2416 cfg_param->trafficMntrTmrForSplitScan);
2417 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002418 return( vosStatus );
2419}
2420
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002421static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
2422{
2423 VOS_STATUS vosStatus;
2424 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2425 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2426 {
2427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2428 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002429 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002430 __func__, staId, vosStatus, vosStatus );
2431 }
2432 return( vosStatus );
2433}
2434
2435
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002436/*
2437 * HDD interface between SME and TL to ensure TDLS client registration with
2438 * TL in case of new TDLS client is added and deregistration at the time
2439 * TDLS client is deleted.
2440 */
2441
Shailender Karmuchia734f332013-04-19 14:02:48 -07002442eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2443 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002444 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002445 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002446 eCsrRoamResult roamResult)
2447{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002448 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002449 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002450 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002451
2452#ifdef WLAN_FEATURE_TDLS_DEBUG
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002454 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2455 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2456 "ADD_TDLS_PEER" :
2457 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2458 "DEL_TDLS_PEER" :
2459 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2460 "DEL_TDLS_PEER_IND" :
2461 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2462 "DEL_ALL_TDLS_PEER_IND" :
2463 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2464 "UPDATE_TDLS_PEER" :
2465 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2466 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2467 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002468#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002469 switch( roamResult )
2470 {
2471 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2472 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002473 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2474 {
2475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002476 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002477 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002478 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002479 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002480
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002481 /* check if there is available index for this new TDLS STA */
2482 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2483 {
2484 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2485 {
2486 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2487 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2488
2489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002490 ("TDLS: STA IDX at %d is %d "
2491 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002492 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002493 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002494
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002495 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002496 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2497 status = eHAL_STATUS_SUCCESS ;
2498 break ;
2499 }
2500 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002501 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002502 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002503 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002504 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2505 "wlan_hdd_tdls_set_sta_id() failed");
2506 return VOS_FALSE;
2507 }
2508
2509 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302510 /* store the ucast signature , if required for further reference. */
2511
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002512 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302513 /* start TDLS client registration with TL */
2514 status = hdd_roamRegisterTDLSSTA( pAdapter,
2515 pRoamInfo->peerMac,
2516 pRoamInfo->staId,
2517 pRoamInfo->ucastSig);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002518 }
2519 else
2520 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002521 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002523 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002524 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002525 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002526 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002527 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002528 break ;
2529 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002530 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2531 {
2532 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2533 {
2534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2535 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2536 }
2537 /* store the ucast signature which will be used later when
2538 * registering to TL
2539 */
2540 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2541 complete(&pAdapter->tdls_add_station_comp);
2542 break;
2543 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302544 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
2545 {
2546 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2547 {
2548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2549 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
2550 }
2551 complete(&pAdapter->tdls_link_establish_req_comp);
2552 break;
2553 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002554 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002555 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002556 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002557 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002558 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002559 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2560 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002561 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002563 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2564
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302565 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002566 if (NULL != curr_peer && TDLS_IS_CONNECTED(curr_peer))
2567 {
2568 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2569 wlan_hdd_tdls_decrement_peer_count(pAdapter);
2570 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002571 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002572
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002573 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2574 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2575 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002576 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002577 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002578 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002579 break ;
2580 }
2581 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002582 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002583 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002584 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002585 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2586 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002587 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002588 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2589 "%s: Sending teardown to supplicant with reason code %u",
2590 __func__, pRoamInfo->reasonCode);
2591
2592#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302593 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002594 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002595#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002596 status = eHAL_STATUS_SUCCESS ;
2597 break ;
2598 }
2599 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2600 {
2601 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002602 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002603 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002604 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2605 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002606 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002608 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002609 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002610 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002611 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2612 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2613 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002614
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002615 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002616 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002617 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2618 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002619
2620 status = eHAL_STATUS_SUCCESS ;
2621 }
2622 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05302623 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002624 break ;
2625 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002626 default:
2627 {
2628 break ;
2629 }
2630 }
2631
2632 return status ;
2633}
2634#endif
2635
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002636static void iw_full_power_cbfn (void *pContext, eHalStatus status)
2637{
2638 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
2639 hdd_context_t *pHddCtx = NULL;
2640 int ret;
2641
2642 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
2643 {
2644 hddLog(VOS_TRACE_LEVEL_ERROR,
2645 "%s: Bad param, pAdapter [%p]",
2646 __func__, pAdapter);
2647 return;
2648 }
2649
2650 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2651 ret = wlan_hdd_validate_context(pHddCtx);
2652 if (0 != ret)
2653 {
2654 hddLog(VOS_TRACE_LEVEL_ERROR,
2655 "%s: HDD context is not valid (%d)", __func__, ret);
2656 return;
2657 }
2658
2659 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2660 {
2661 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
2662 }
2663}
2664
Shailender Karmuchia734f332013-04-19 14:02:48 -07002665eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2667{
2668 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2669 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302670 hdd_wext_state_t *pWextState = NULL;
2671 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002672 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07002673 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002674
2675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002676 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002677 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002678
2679 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302680 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002681 {
2682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302683 "invalid adapter or adapter has invalid magic");
2684 return eHAL_STATUS_FAILURE;
2685 }
2686
2687 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2688 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2689
2690 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2691 {
2692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2693 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002694 return eHAL_STATUS_FAILURE;
2695 }
2696
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 switch( roamStatus )
2698 {
2699 case eCSR_ROAM_SESSION_OPENED:
2700 if(pAdapter != NULL)
2701 {
2702 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2703 complete(&pAdapter->session_open_comp_var);
2704 }
2705 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002706
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002707#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
2708 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002709 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07002710 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 * interface down */
2712 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05302713 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
2714 roamStatus, roamResult, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2716 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2717 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2719 }
2720 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302721 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002722 break;
2723
2724 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002725 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07002727 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07002728 // eCSR_ROAM_SHOULD_ROAM will be received.
2729 // Where in we will not mark the link down
2730 // Also we want to stop tx at this point when we will be
2731 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002732 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 {
2734 struct net_device *dev = pAdapter->dev;
2735 netif_tx_disable(dev);
Mukul Sharma84f27252014-07-14 18:11:42 +05302736#ifdef DEBUG_ROAM_DELAY
2737 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
2738#endif
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002739 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002740 * Deregister for this STA with TL with the objective to flush
2741 * all the packets for this STA from wmm_tx_queue. If not done here,
2742 * we would run into a race condition (CR390567) wherein TX
2743 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2744 * been deleted. And, these packets get assigned with a STA idx of
2745 * self-sta (since the peer STA has been deleted) and get transmitted
2746 * on the new channel before the reassoc request. Since there will be
2747 * no ACK on the new channel, each packet gets retransmitted which
2748 * takes several seconds before the transmission of reassoc request.
2749 * This leads to reassoc-timeout and roam failure.
2750 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002751 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2752 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2753 {
2754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2755 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2756 pHddStaCtx->conn_info.staId[0], status, status );
2757 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002758 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 }
2760 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002761 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 break;
2763#endif
2764
2765 case eCSR_ROAM_SHOULD_ROAM:
2766 // Dont need to do anything
2767 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002768 struct net_device *dev = pAdapter->dev;
2769 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2770 // notify apps that we can't pass traffic anymore
2771 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002772#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002773 if (pHddStaCtx->ft_carrier_on == FALSE)
2774 {
2775#endif
2776 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002777#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002778 }
2779#endif
2780
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002781#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002782 //We should clear all sta register with TL, for now, only one.
2783 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2784 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2785 {
2786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2787 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2788 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002789 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002791#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002792 }
2793 break;
2794 case eCSR_ROAM_LOSTLINK:
2795 case eCSR_ROAM_DISASSOCIATED:
2796 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2798 "****eCSR_ROAM_DISASSOCIATED****");
2799 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2800 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07002801 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2802 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302803 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07002804 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08002805
2806 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
2807 pHddCtx->configuredMcastBcastFilter =
2808 pHddCtx->sus_res_mcastbcast_filter;
2809 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
2810 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302811
Amar Singhald53568e2013-09-26 11:03:45 -07002812 hddLog(VOS_TRACE_LEVEL_INFO,
2813 "offload: disassociation happening, restoring configuredMcastBcastFilter");
2814 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
2815 pHddCtx->configuredMcastBcastFilter);
2816 hddLog(VOS_TRACE_LEVEL_INFO,
2817 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2819 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002820#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302821 /* Call to clear any MC Addr List filter applied after
2822 * successful connection.
2823 */
2824 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002825#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 }
2827 break;
2828 case eCSR_ROAM_IBSS_LEAVE:
2829 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2830 "****eCSR_ROAM_IBSS_LEAVE****");
2831 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2832 break;
2833 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2834 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2835 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302836 // To Do - address probable memory leak with WEP encryption upon successful association
2837 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07002838 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302839 //Clear saved connection information in HDD
2840 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002841 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302842 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002843
2844 break;
2845 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002846 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 pRoamInfo, roamId, roamStatus, roamResult );
2848 break;
2849 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07002850 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
2851 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 break;
2853
2854 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2855 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002856 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002857
2858 case eCSR_ROAM_MIC_ERROR_IND:
2859 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2860 break;
2861
2862 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002863 {
2864 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2865
2866 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002867 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
2868 (TRUE == pHddCtx->hdd_wlan_suspended) &&
2869 (eCSR_ROAM_RESULT_NONE == roamResult))
2870 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002871 /* Send DTIM period to the FW; only if the wlan is already
2872 in suspend. This is the case with roaming (reassoc),
2873 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
2874 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
2875 before the ENTER_BMPS_REQ ensures Listen Interval is
2876 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002877 hdd_set_pwrparams(pHddCtx);
2878 pHddStaCtx->hdd_ReassocScenario = VOS_FALSE;
2879
2880 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002881 if due to unexpected scenario, if we are in BMPS,
2882 then trigger Exit and Enter BMPS to take DTIM period
2883 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002884 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
2885 {
2886 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
2887
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002888 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2889 iw_full_power_cbfn, pAdapter,
2890 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002891 }
2892 }
2893 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302894 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002896 break;
2897#ifdef WLAN_FEATURE_VOWIFI_11R
2898 case eCSR_ROAM_FT_RESPONSE:
2899 hdd_SendFTEvent(pAdapter);
2900 break;
2901#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002902#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002903 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002904 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07002905 {
2906 /* Notify the supplicant of a new candidate */
2907 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2908 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002909 break;
2910#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002911
Yue Maef608272013-04-08 23:09:17 -07002912#ifdef FEATURE_WLAN_LFR_METRICS
2913 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
2914 /* This event is to notify pre-auth initiation */
2915 if (VOS_STATUS_SUCCESS !=
2916 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
2917 {
2918 halStatus = eHAL_STATUS_FAILURE;
2919 }
2920 break;
2921 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
2922 /* This event will notify pre-auth completion in case of success */
2923 if (VOS_STATUS_SUCCESS !=
2924 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2925 pRoamInfo, 1))
2926 {
2927 halStatus = eHAL_STATUS_FAILURE;
2928 }
2929 break;
2930 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
2931 /* This event will notify pre-auth completion in case of failure. */
2932 if (VOS_STATUS_SUCCESS !=
2933 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2934 pRoamInfo, 0))
2935 {
2936 halStatus = eHAL_STATUS_FAILURE;
2937 }
2938 break;
2939 case eCSR_ROAM_HANDOVER_SUCCESS:
2940 /* This event is to notify handover success.
2941 It will be only invoked on success */
2942 if (VOS_STATUS_SUCCESS !=
2943 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
2944 {
2945 halStatus = eHAL_STATUS_FAILURE;
2946 }
2947 break;
2948#endif
2949
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 case eCSR_ROAM_INDICATE_MGMT_FRAME:
2951 hdd_indicateMgmtFrame( pAdapter,
2952 pRoamInfo->nFrameLength,
2953 pRoamInfo->pbFrames,
2954 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05302955 pRoamInfo->rxChan,
2956 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07002957 break;
2958 case eCSR_ROAM_REMAIN_CHAN_READY:
2959 hdd_remainChanReadyHandler( pAdapter );
2960 break;
2961 case eCSR_ROAM_SEND_ACTION_CNF:
2962 hdd_sendActionCnf( pAdapter,
2963 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
2964 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002965#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08002966 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002967 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08002968 roamId, roamStatus, roamResult );
2969 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002970 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
2971 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
2972 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002973#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002974#ifdef WLAN_FEATURE_11W
2975 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
2976 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
2977 pRoamInfo->pbFrames,
2978 pRoamInfo->frameType);
2979 break;
2980#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002981#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002982 case eCSR_ROAM_TSM_IE_IND:
2983 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
2984 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
2985 break;
2986
2987 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
2988 {
2989 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
2990 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
2991 {
2992 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
2993 }
2994 break;
2995 }
2996
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002997 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002998 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002999 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003000 break;
3001 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003002
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003003 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003004 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003005 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003006 break;
3007 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003008#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 default:
3010 break;
3011 }
3012 return( halStatus );
3013}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003014eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003015{
3016 eCsrAuthType auth_type;
3017 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003018 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003019 {
3020 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003021 } else
3022 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 {
3024 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003025 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003026#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003027 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 {
3029 // Check for 11r FT Authentication with PSK
3030 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003031 } else
3032 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003033 {
3034 // Check for 11R FT Authentication with 802.1X
3035 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003036 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003037#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003038#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003039 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 {
3041 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3042 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003043#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003044#ifdef WLAN_FEATURE_11W
3045 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3046 {
3047 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3048 } else
3049#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003050 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003051 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3052 }
3053 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003054}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003055
Shailender Karmuchia734f332013-04-19 14:02:48 -07003056eCsrAuthType
3057hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003058{
3059 eCsrAuthType auth_type;
3060 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003061 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003062 {
3063 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003064 } else
3065 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 {
3067 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003068 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003069#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003070 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 {
3072 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003073 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003074#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003075 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3077 }
3078 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3079 return auth_type;
3080}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003081
Shailender Karmuchia734f332013-04-19 14:02:48 -07003082eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003083hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003084{
3085 eCsrEncryptionType cipher_type;
3086 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003087 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 {
3089 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003090 }
3091 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 {
3093 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003094 }
3095 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 {
3097 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003098 }
3099 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003100 {
3101 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003102 }
3103 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3104 {
3105 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3106 }
3107 else
3108 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003109 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3110 }
3111 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3112 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003113}
Jeff Johnson295189b2012-06-20 16:38:30 -07003114/* To find if the MAC address is NULL */
3115static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3116{
3117 int i;
3118 for (i = 0; i < length; i++)
3119 {
3120 if (0x00 != (macAddr[i]))
3121 {
3122 return FALSE;
3123 }
3124 }
3125 return TRUE;
3126} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003127
Shailender Karmuchia734f332013-04-19 14:02:48 -07003128eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003129hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003130{
3131 eCsrEncryptionType cipher_type;
3132 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003133 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 {
3135 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003136 } else
3137 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 {
3139 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003140 } else
3141 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 {
3143 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003144 } else
3145 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 {
3147 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003148 } else
3149 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003150 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003151 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3152 } else
3153 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003154 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3155 }
3156 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3157 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003158}
Jeff Johnson295189b2012-06-20 16:38:30 -07003159
Shailender Karmuchia734f332013-04-19 14:02:48 -07003160static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3161 struct ether_addr *pBssid,
3162 eCsrEncryptionType *pEncryptType,
3163 eCsrEncryptionType *mcEncryptType,
3164 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003165#ifdef WLAN_FEATURE_11W
3166 u_int8_t *pMfpRequired,
3167 u_int8_t *pMfpCapable,
3168#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003169 u_int16_t gen_ie_len,
3170 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003171{
3172 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003173 eHalStatus result;
3174 tDot11fIERSN dot11RSNIE;
3175 tDot11fIEWPA dot11WPAIE;
3176 tANI_U32 i;
3177 tANI_U8 *pRsnIe;
3178 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003179 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003180 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003181
3182 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3183 flag to 0 */
3184 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3185 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3186
3187 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003188 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
3189 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303190 {
3191 hddLog(LOGE, "%s: Invalid DOT11F IE Length passed :%d",
3192 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 return -EINVAL;
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303194 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003196 if ( gen_ie[0] == DOT11F_EID_RSN)
3197 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003199 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3201 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303202 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3203 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 return -EINVAL;
3205 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003206 // Skip past the EID byte and length byte
3207 pRsnIe = gen_ie + 2;
3208 RSNIeLen = gen_ie_len - 2;
3209 // Unpack the RSN IE
3210 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3211 pRsnIe,
3212 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003214 // Copy out the encryption and authentication types
3215 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003216 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003217 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003218 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003219 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 but probably I suspect we can do something different*/
3221 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003222 // Just translate the FIRST one
3223 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3224 //dot11RSNIE.pwise_cipher_suite_count
3225 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3226 //dot11RSNIE.gp_cipher_suite_count
3227 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003228#ifdef WLAN_FEATURE_11W
3229 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3230 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3231#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003232 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003233 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003235 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003236 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303237 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 break;
3239 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003240 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303242 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003243 break;
3244 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003245 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 // For right now, I assume setASSOCIATE() has passed in the bssid.
3247 vos_mem_copy(PMKIDCache[i].BSSID,
3248 pBssid, ETHER_ADDR_LEN);
3249 vos_mem_copy(PMKIDCache[i].PMKID,
3250 dot11RSNIE.pmkid[i],
3251 CSR_RSN_PMKID_SIZE);
3252 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003253
3254 if (updatePMKCache)
3255 {
3256 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003257 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003258 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003259 // Finally set the PMKSA ID Cache in CSR
3260 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3261 PMKIDCache,
3262 dot11RSNIE.pmkid_count );
3263 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 }
3265 else if (gen_ie[0] == DOT11F_EID_WPA)
3266 {
3267 // Validity checks
3268 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3269 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3270 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303271 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3272 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 return -EINVAL;
3274 }
3275 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003276 pRsnIe = gen_ie + 2 + 4;
3277 RSNIeLen = gen_ie_len - (2 + 4);
3278 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3280 pRsnIe,
3281 RSNIeLen,
3282 &dot11WPAIE);
3283 // Copy out the encryption and authentication types
3284 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003285 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003287 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 //dot11WPAIE.auth_suite_count
3289 // Just translate the FIRST one
3290 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3291 //dot11WPAIE.unicast_cipher_count
3292 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3293 //dot11WPAIE.unicast_cipher_count
3294 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3295 }
3296 else
3297 {
3298 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003299 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 }
3301 return 0;
3302}
3303int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3304{
3305 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3306 v_U32_t status = 0;
3307 eCsrEncryptionType RSNEncryptType;
3308 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003309#ifdef WLAN_FEATURE_11W
3310 u_int8_t RSNMfpRequired;
3311 u_int8_t RSNMfpCapable;
3312#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003313 struct ether_addr bSsid; // MAC address of assoc peer
3314 // MAC address of assoc peer
3315 // But, this routine is only called when we are NOT associated.
3316 vos_mem_copy(bSsid.ether_addr_octet,
3317 pWextState->roamProfile.BSSIDs.bssid,
3318 sizeof(bSsid.ether_addr_octet));
3319 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3320 {
3321 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003322 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 else
3324 {
3325 return 0;
3326 }
3327 // The actual processing may eventually be more extensive than this.
3328 // Right now, just consume any PMKIDs that are sent in by the app.
3329 status = hdd_ProcessGENIE(pAdapter,
3330 &bSsid, // MAC address of assoc peer
3331 &RSNEncryptType,
3332 &mcRSNEncryptType,
3333 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003334#ifdef WLAN_FEATURE_11W
3335 &RSNMfpRequired,
3336 &RSNMfpCapable,
3337#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 pWextState->WPARSNIE[1]+2,
3339 pWextState->WPARSNIE);
3340 if (status == 0)
3341 {
3342 // Now copy over all the security attributes you have parsed out
3343 pWextState->roamProfile.EncryptionType.numEntries = 1;
3344 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003345
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3347 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003348
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003349 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3350 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3351 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3352 {
3353 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3354 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3355 either AES/TKIP based on group cipher configuration
3356 mentioned in the wpa_supplicant.conf.*/
3357
3358 /*Set the unicast cipher same as multicast cipher*/
3359 pWextState->roamProfile.EncryptionType.encryptionType[0]
3360 = mcRSNEncryptType;
3361 }
3362
Chet Lanctot186b5732013-03-18 10:26:30 -07003363#ifdef WLAN_FEATURE_11W
3364 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3365 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3366#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003367 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 }
3369 return 0;
3370}
3371int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3372{
3373 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3374 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3375 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3376 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003377
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003379 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003380
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 switch( pHddStaCtx->conn_info.authType)
3382 {
3383 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003384#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 case eCSR_AUTH_TYPE_CCKM_WPA:
3386 case eCSR_AUTH_TYPE_CCKM_RSN:
3387#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003388 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3389
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003391 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003393
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003394#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003395 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3396 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3397 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003398 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003399 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3400 } else
3401 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003402 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003403 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 } else
3405#endif
3406 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3407 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003408 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3409 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3411 == IW_AUTH_KEY_MGMT_PSK) {
3412 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003413 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003416 }
3417 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003418#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003419 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3420 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3421 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003422 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003423 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003425 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003426 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003427 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 } else
3429#endif
3430
3431#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003432 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3433 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003434 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003435 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003436 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003437 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3439 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003440 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 } else
3442#endif
3443
Chet Lanctot186b5732013-03-18 10:26:30 -07003444#ifdef WLAN_FEATURE_11W
3445 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3446 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3447 } else
3448#endif
3449
Shailender Karmuchia734f332013-04-19 14:02:48 -07003450 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003452 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3453 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003454 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3455 == IW_AUTH_KEY_MGMT_PSK) {
3456 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003457 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003461 break;
3462
Jeff Johnson295189b2012-06-20 16:38:30 -07003463 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003464
3465 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 break;
3467 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003468
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003469#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08003470 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003471#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3473 break;
3474 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003475
Jeff Johnson295189b2012-06-20 16:38:30 -07003476 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003477 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003478
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 EXIT();
3480 return 0;
3481}
3482
3483/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003484
3485 \brief iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003487 to the CSR roam profile.
3488
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 \param - dev - Pointer to the net device.
3490 - info - Pointer to the iw_request_info.
3491 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003492 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003493 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003494
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 --------------------------------------------------------------------------*/
3496
Shailender Karmuchia734f332013-04-19 14:02:48 -07003497int iw_set_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 struct iw_request_info *info,
3499 union iwreq_data *wrqu, char *extra)
3500{
3501 v_U32_t status = 0;
3502 hdd_wext_state_t *pWextState;
3503 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3504 v_U32_t roamId;
3505 tCsrRoamProfile *pRoamProfile;
3506 eMib_dot11DesiredBssType connectedBssType;
3507 eCsrAuthType RSNAuthType;
3508 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3509 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003510
3511 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3512
Jeff Johnson295189b2012-06-20 16:38:30 -07003513 ENTER();
3514
3515 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3516 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003518 "%s:LOGP in Progress. Ignore!!!",__func__);
3519 return 0;
3520 }
3521
3522 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
3523 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
3524 return -EBUSY;
3525 }
3526 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
3527 return -EINVAL;
3528 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003529 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 {
3531 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
3532 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
3533 {
3534 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003535 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07003536 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3537 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
3538
3539 if(VOS_STATUS_SUCCESS == vosStatus)
3540 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3541 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3542 }
3543 }
3544 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003545 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 {
3547 return -EINVAL;
3548 }
3549 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003550 /** when cfg80211 defined, wpa_supplicant wext driver uses
3551 zero-length, null-string ssid for force disconnection.
3552 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 driver MUST return success */
3554 if ( 0 == wrqu->essid.length ) {
3555 return 0;
3556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003557
3558 status = hdd_wmm_get_uapsd_mask(pAdapter,
3559 &pWextState->roamProfile.uapsd_mask);
3560 if (VOS_STATUS_SUCCESS != status)
3561 {
3562 pWextState->roamProfile.uapsd_mask = 0;
3563 }
3564 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003565
Jeff Johnson295189b2012-06-20 16:38:30 -07003566 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003567
3568 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
3570 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
3571 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003572
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 //set gen ie
3574 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
3575
3576 //set auth
3577 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
3578 }
3579#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003580 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 if (pAdapter->wapi_info.nWapiMode)
3582 {
3583 switch (pAdapter->wapi_info.wapiAuthMode)
3584 {
3585 case WAPI_AUTH_MODE_PSK:
3586 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003587 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003588 pRoamProfile->AuthType.numEntries = 1;
3589 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3590 break;
3591 }
3592 case WAPI_AUTH_MODE_CERT:
3593 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003594 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003595 pRoamProfile->AuthType.numEntries = 1;
3596 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3597 break;
3598 }
3599 } // End of switch
3600 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
3601 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
3602 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003603 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 pRoamProfile->EncryptionType.numEntries = 1;
3605 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3606 pRoamProfile->mcEncryptionType.numEntries = 1;
3607 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3608 }
3609 }
3610#endif /* FEATURE_WLAN_WAPI */
3611 /* if previous genIE is not NULL, update AssocIE */
3612 if (0 != pWextState->genIE.length)
3613 {
3614 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
3615 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
3616 pWextState->genIE.length);
3617 pWextState->assocAddIE.length = pWextState->genIE.length;
3618 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
3619 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
3620
3621 /* clear previous genIE after use it */
3622 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
3623 }
3624
3625 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
3626 pWextState->roamProfile.bWPSAssociation = FALSE;
3627
3628 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
3629 pWextState->roamProfile.nAddIEAssocLength))
3630 pWextState->roamProfile.bWPSAssociation = TRUE;
3631
3632
3633 // Disable auto BMPS entry by PMC until DHCP is done
3634 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
3635
Shailender Karmuchia734f332013-04-19 14:02:48 -07003636 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003637 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003638
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003639 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
3640 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003641 hdd_select_cbmode(pAdapter,
3642 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
3643 }
3644 status = sme_RoamConnect( hHal,pAdapter->sessionId,
3645 &(pWextState->roamProfile), &roamId);
3646 pRoamProfile->ChannelInfo.ChannelList = NULL;
3647 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003648
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003649 EXIT();
3650 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003651}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003652
Jeff Johnson295189b2012-06-20 16:38:30 -07003653/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003654
3655 \brief iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003656 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003657
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 \param - dev - Pointer to the net device.
3659 - info - Pointer to the iw_request_info.
3660 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003661 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003662 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003663
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 --------------------------------------------------------------------------*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003665int iw_get_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 struct iw_request_info *info,
3667 struct iw_point *dwrq, char *extra)
3668{
3669 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003670 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003671 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3672 ENTER();
3673
3674 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
3675 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
3676 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
3677 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
3678 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
3679 {
3680 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
3681 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
3682 dwrq->flags = 1;
3683 } else {
3684 memset(extra, 0, dwrq->length);
3685 dwrq->length = 0;
3686 dwrq->flags = 0;
3687 }
3688 EXIT();
3689 return 0;
3690}
3691/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003692
3693 \brief iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003695
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 \param - dev - Pointer to the net device.
3697 - info - Pointer to the iw_request_info.
3698 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003699 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003700 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003701
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 --------------------------------------------------------------------------*/
3703int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
3704 union iwreq_data *wrqu,char *extra)
3705{
3706 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003707 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3709 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003710 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 eCsrEncryptionType ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003712
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003714
3715 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3716 {
3717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3718 "%s:LOGP in Progress. Ignore!!!", __func__);
3719 return -EBUSY;
3720 }
3721
Jeff Johnson295189b2012-06-20 16:38:30 -07003722 switch(wrqu->param.flags & IW_AUTH_INDEX)
3723 {
3724 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003725
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003727
Jeff Johnson295189b2012-06-20 16:38:30 -07003728 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003729
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 case IW_AUTH_CIPHER_PAIRWISE:
3731 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003732 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3736 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003737 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3739 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003740 }
3741
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003743
3744 if( (IW_AUTH_KEY_MGMT_802_1X
3745 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003746 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
3747 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003748 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 else
3750 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003751 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3752 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003754
3755 if( ( IW_AUTH_KEY_MGMT_802_1X
3756 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003757 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3758 /*Dynamic WEP key*/
3759 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3760 else
3761 /*Static WEP key*/
3762 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003763
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 }
3765 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003766
Jeff Johnson295189b2012-06-20 16:38:30 -07003767 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003768 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 return -EINVAL;
3770 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003771
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 pRoamProfile->EncryptionType.numEntries = 1;
3773 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003774 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003775 break;
3776 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003777 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003778 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
3779 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3780 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003781
Jeff Johnson295189b2012-06-20 16:38:30 -07003782 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3783 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
3784 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003785
3786 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003787 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
3788 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003789
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003791
3792 if( ( IW_AUTH_KEY_MGMT_802_1X
3793 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
3794 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3795
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003797
3798 else
3799 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003801
3802 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3803 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003804 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003805 if( ( IW_AUTH_KEY_MGMT_802_1X
3806 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003807 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3808 {
3809 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3810 }
3811 else
3812 {
3813 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3814 }
3815 }
3816 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003817
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003819 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003820 return -EINVAL;
3821 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003822
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 pRoamProfile->mcEncryptionType.numEntries = 1;
3824 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3825 }
3826 break;
3827
3828 case IW_AUTH_80211_AUTH_ALG:
3829 {
3830 /*Save the auth algo here and set auth type to SME Roam profile
3831 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003832 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07003833 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003834
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3836 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3837
3838 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3839 /*Not supported*/
3840 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3841 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3842 }
3843 break;
3844
3845 case IW_AUTH_KEY_MGMT:
3846 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003847#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003848#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3849 /*Check for CCKM AKM type */
3850 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003851 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
3852 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003853 /* Set the CCKM bit in authKeyMgmt */
3854 /* Right now, this breaks all ref to authKeyMgmt because our
3855 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 */
3857 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3858 /*Set the key management to 802.1X*/
3859 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003860 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3862 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3863 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3864 /*Save the key management*/
3865 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3866 //pWextState->authKeyMgmt = wrqu->param.value;
3867 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3868 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3869 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3870 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3871 /*Save the key management anyway*/
3872 pWextState->authKeyMgmt = wrqu->param.value;
3873 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3874 /*Save the key management*/
3875 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3876 //pWextState->authKeyMgmt = wrqu->param.value;
3877 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3878 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3879 }
3880#else
3881 /*Save the key management*/
3882 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003883#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 }
3885 break;
3886
3887 case IW_AUTH_TKIP_COUNTERMEASURES:
3888 {
3889 if(wrqu->param.value) {
3890 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3891 "Counter Measure started %d", wrqu->param.value);
3892 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3893 }
3894 else {
3895 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3896 "Counter Measure stopped=%d", wrqu->param.value);
3897 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3898 }
3899 }
3900 break;
3901 case IW_AUTH_DROP_UNENCRYPTED:
3902 case IW_AUTH_WPA_ENABLED:
3903 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3904 case IW_AUTH_ROAMING_CONTROL:
3905 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003906
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003908
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003909 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003910 wrqu->param.flags & IW_AUTH_INDEX);
3911 break;
3912 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003913
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 EXIT();
3915 return 0;
3916}
3917/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003918
3919 \brief iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003921
Jeff Johnson295189b2012-06-20 16:38:30 -07003922 \param - dev - Pointer to the net device.
3923 - info - Pointer to the iw_request_info.
3924 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003925 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003927
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 --------------------------------------------------------------------------*/
3929int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3930 union iwreq_data *wrqu,char *extra)
3931{
3932 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003933 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3935 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003936
3937 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3938 {
3939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3940 "%s:LOGP in Progress. Ignore!!!", __func__);
3941 return -EBUSY;
3942 }
3943
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 switch(pRoamProfile->negotiatedAuthType)
3945 {
3946 case eCSR_AUTH_TYPE_WPA_NONE:
3947 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3948 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
3949 break;
3950 case eCSR_AUTH_TYPE_WPA:
3951 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3952 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
3953 break;
3954#ifdef WLAN_FEATURE_VOWIFI_11R
3955 case eCSR_AUTH_TYPE_FT_RSN:
3956#endif
3957 case eCSR_AUTH_TYPE_RSN:
3958 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3959 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
3960 break;
3961 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3962 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3963 break;
3964 case eCSR_AUTH_TYPE_SHARED_KEY:
3965 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
3966 break;
3967 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003968 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3970 break;
3971 case eCSR_AUTH_TYPE_AUTOSWITCH:
3972 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3973 break;
3974 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303975 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003976 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3977 return -EIO;
3978#ifdef WLAN_FEATURE_VOWIFI_11R
3979 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3980#endif
3981 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07003982#ifdef WLAN_FEATURE_11W
3983 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3984#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05303985 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3987 return -EIO;
3988 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303989 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3991 return -EIO;
3992 }
3993 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
3994 {
3995 switch(pRoamProfile->negotiatedUCEncryptionType)
3996 {
3997 case eCSR_ENCRYPT_TYPE_NONE:
3998 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3999 break;
4000 case eCSR_ENCRYPT_TYPE_WEP40:
4001 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4002 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4003 break;
4004 case eCSR_ENCRYPT_TYPE_TKIP:
4005 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4006 break;
4007 case eCSR_ENCRYPT_TYPE_WEP104:
4008 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4009 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4010 break;
4011 case eCSR_ENCRYPT_TYPE_AES:
4012 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4013 break;
4014 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304015 hddLog(LOG1, "%s called with unknown auth type %d ",
4016 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004017 return -EIO;
4018 }
4019 }
4020
Shailender Karmuchia734f332013-04-19 14:02:48 -07004021 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004022 {
4023 switch(pRoamProfile->negotiatedMCEncryptionType)
4024 {
4025 case eCSR_ENCRYPT_TYPE_NONE:
4026 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4027 break;
4028 case eCSR_ENCRYPT_TYPE_WEP40:
4029 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4030 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4031 break;
4032 case eCSR_ENCRYPT_TYPE_TKIP:
4033 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4034 break;
4035 case eCSR_ENCRYPT_TYPE_WEP104:
4036 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4037 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4038 break;
4039 case eCSR_ENCRYPT_TYPE_AES:
4040 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4041 break;
4042 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304043 hddLog(LOG1, "%s called with unknown auth type %d ",
4044 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 return -EIO;
4046 }
4047 }
4048
4049 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004050 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 EXIT();
4052 return 0;
4053}
4054/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004055
4056 \brief iw_set_ap_address() -
4057 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004059
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 \param - dev - Pointer to the net device.
4061 - info - Pointer to the iw_request_info.
4062 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004063 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004065
Jeff Johnson295189b2012-06-20 16:38:30 -07004066 --------------------------------------------------------------------------*/
4067int iw_set_ap_address(struct net_device *dev,
4068 struct iw_request_info *info,
4069 union iwreq_data *wrqu, char *extra)
4070{
4071 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
4072 v_U8_t *pMacAddress=NULL;
4073 ENTER();
4074 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4076 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
4078 EXIT();
Shailender Karmuchia734f332013-04-19 14:02:48 -07004079
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 return 0;
4081}
4082/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004083
4084 \brief iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 This function returns the BSSID to the wpa_supplicant
4086 \param - dev - Pointer to the net device.
4087 - info - Pointer to the iw_request_info.
4088 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004089 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004091
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 --------------------------------------------------------------------------*/
4093int iw_get_ap_address(struct net_device *dev,
4094 struct iw_request_info *info,
4095 union iwreq_data *wrqu, char *extra)
4096{
4097 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4098 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
4099
4100 ENTER();
4101
4102 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4103 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4104 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004105 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 }
4107 else
4108 {
4109 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4110 }
4111 EXIT();
4112 return 0;
4113}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004114
Chet Lanctot186b5732013-03-18 10:26:30 -07004115#ifdef WLAN_FEATURE_11W
4116/**---------------------------------------------------------------------------
4117
4118 \brief hdd_indicateUnprotMgmtFrame -
4119 This function forwards the unprotected management frame to the supplicant
4120 \param - pAdapter - Pointer to HDD adapter
4121 - nFrameLength - Length of the unprotected frame being passed
4122 - pbFrames - Pointer to the frame buffer
4123 - frameType - 802.11 frame type
4124 \return - nothing
4125
4126 --------------------------------------------------------------------------*/
4127void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4128 tANI_U32 nFrameLength,
4129 tANI_U8* pbFrames,
4130 tANI_U8 frameType )
4131{
4132 tANI_U8 type = 0;
4133 tANI_U8 subType = 0;
4134
4135 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4136 __func__, frameType, nFrameLength);
4137
4138 /* Sanity Checks */
4139 if (NULL == pAdapter)
4140 {
4141 hddLog( LOGE, FL("pAdapter is NULL"));
4142 return;
4143 }
4144
4145 if (NULL == pAdapter->dev)
4146 {
4147 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4148 return;
4149 }
4150
4151 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4152 {
4153 hddLog( LOGE, FL("pAdapter has invalid magic"));
4154 return;
4155 }
4156
4157 if( !nFrameLength )
4158 {
4159 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4160 return;
4161 }
4162
4163 if (NULL == pbFrames) {
4164 hddLog( LOGE, FL("pbFrames is NULL"));
4165 return;
4166 }
4167
4168 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4169 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4170
4171 /* Get pAdapter from Destination mac address of the frame */
4172 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
4173 {
4174 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
4175 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4176 }
4177 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
4178 {
4179 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
4180 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4181 }
4182 else
4183 {
4184 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
4185 return;
4186 }
4187}
4188#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004189
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004190#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004191void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
4192 tANI_U8 state,
4193 tANI_U16 measInterval )
4194{
4195 union iwreq_data wrqu;
4196 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004197 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004198
4199 if (NULL == pAdapter)
4200 return;
4201
4202 // create the event
4203 memset(&wrqu, '\0', sizeof(wrqu));
4204 memset(buf, '\0', sizeof(buf));
4205
4206 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
4207 tid, state, measInterval);
4208
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004209 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004210
4211 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004212 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004213 // send the event
4214 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4215}
4216
4217void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4218{
4219 union iwreq_data wrqu;
4220 char buf[IW_CUSTOM_MAX + 1];
4221 char *pos = buf;
4222 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4223
4224 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4225 return;
4226
4227 // create the event
4228 memset(&wrqu, '\0', sizeof(wrqu));
4229 memset(buf, '\0', sizeof(buf));
4230
4231 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304232 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
4233 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
4234 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
4235 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004236
4237 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4238 pos += nBytes;
4239 freeBytes -= nBytes;
4240
4241 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
4242 pos += WNI_CFG_BSSID_LEN;
4243 freeBytes -= WNI_CFG_BSSID_LEN;
4244
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004245 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4246 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004247
4248 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004249 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004250
4251 // send the event
4252 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4253}
4254
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004255void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004256{
4257 union iwreq_data wrqu;
4258 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004259 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004260
4261 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4262 return;
4263
4264 // create the event
4265 memset(&wrqu, '\0', sizeof(wrqu));
4266 memset(buf, '\0', sizeof(buf));
4267
4268 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
4269
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004270 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004271
4272 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004273 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004274
4275 // send the event
4276 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4277}
4278
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004279void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
4280 const tANI_U16 measurementToken,
4281 const tANI_BOOLEAN flag,
4282 const tANI_U8 numBss)
4283{
4284 union iwreq_data wrqu;
4285 char buf[IW_CUSTOM_MAX];
4286 char *pos = buf;
4287 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4288
4289 memset(&wrqu, '\0', sizeof(wrqu));
4290 memset(buf, '\0', sizeof(buf));
4291
4292 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
4293 numBss);
4294
4295 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4296 flag, numBss);
4297
4298 wrqu.data.pointer = buf;
4299 wrqu.data.length = nBytes;
4300 // send the event
4301 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4302}
4303
4304
4305static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004306 const tCsrRoamInfo *pRoamInfo)
4307{
4308 union iwreq_data wrqu;
4309 char buf[IW_CUSTOM_MAX + 1];
4310 char *pos = buf;
4311 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4312 tANI_U8 i = 0, len = 0;
4313 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
4314 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004315 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
4316 tANI_U8 ieLenByte = 1;
4317 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
4318#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004319
4320 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4321 return;
4322
4323 /* Custom event can pass maximum of 256 bytes of data,
4324 based on the IE len we need to identify how many BSS info can
4325 be filled in to custom event data */
4326 /*
4327 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4328 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4329 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4330 */
4331
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004332 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004333 {
4334 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
4335 /* If the measurement is none and no scan results found,
4336 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004337 hdd_indicateEseBcnReportNoResults(pAdapter,
4338 pRoamInfo->pEseBcnReportRsp->measurementToken,
4339 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004340 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004341 }
4342 else
4343 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004344 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004345 {
4346 memset(&wrqu, '\0', sizeof(wrqu));
4347 memset(buf, '\0', sizeof(buf));
4348 tot_bcn_ieLen = 0;
4349 sendBss = 0;
4350 pos = buf;
4351 freeBytes = IW_CUSTOM_MAX;
4352
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004353 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004354 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004355 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
4356 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004357 {
4358 break;
4359 }
4360 tot_bcn_ieLen += len;
4361 sendBss++;
4362 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
4363 "IeLength(%d) Length of Ie(%d) totLen(%d)",
4364 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004365 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004366 tot_bcn_ieLen);
4367 }
4368
4369 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
4370 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004371 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4372 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004373
4374 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004375 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4376 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004377 pos += nBytes;
4378 freeBytes -= nBytes;
4379
4380 /* Copy total Beacon report data length */
4381 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
4382 pos += sizeof(tot_bcn_ieLen);
4383 freeBytes -= sizeof(tot_bcn_ieLen);
4384
4385 for (i = 0; i < sendBss; i++)
4386 {
4387 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304388 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4389 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004390 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004391 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
4392 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
4393 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
4394 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
4395 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
4396 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
4397 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
4398 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
4399 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
4400 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
4401 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
4402 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
4403 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
4404 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
4405 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
4406 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004407
4408 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004409 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
4410 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004411 pos += len;
4412 freeBytes -= len;
4413
4414 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004415 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004416 vos_mem_copy(pos, (char*)&len, sizeof(len));
4417 pos += sizeof(len);
4418 freeBytes -= sizeof(len);
4419
4420 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004421 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004422 pos += len;
4423 freeBytes -= len;
4424 }
4425
4426 wrqu.data.pointer = buf;
4427 wrqu.data.length = strlen(buf);
4428
4429 // send the event
4430 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4431 lastSent += sendBss;
4432 }
4433 }
4434}
4435
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004436#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004437