blob: 448454dddc7d740a39a57271566064d09d794159 [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
Abhishek Singhae408032014-09-25 17:22:04 +0530100/* RSN-8021X-SHA256 */
101v_U8_t ccpRSNOui08[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 };
Chet Lanctot186b5732013-03-18 10:26:30 -0700102#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700103
Shailender Karmuchia734f332013-04-19 14:02:48 -0700104#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700105// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700106#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
107#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700108#endif
109
110#define BEACON_FRAME_IES_OFFSET 12
111
Chet Lanctot186b5732013-03-18 10:26:30 -0700112#ifdef WLAN_FEATURE_11W
113void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
114 tANI_U32 nFrameLength,
115 tANI_U8* pbFrames,
116 tANI_U8 frameType );
117#endif
118
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800119#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700120static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
121 tANI_U8 state,
122 tANI_U16 measInterval );
123static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800124static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
125static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700126
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800127#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700128
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530129static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
130 tCsrRoamInfo *pRoamInfo,
131 tANI_U32 roamId,
132 eRoamCmdStatus roamStatus,
133 eCsrRoamResult roamResult );
134
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530135v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
136 eConnectionState connState )
137{
138 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530139 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
140 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700141 pHddStaCtx->conn_info.connState = connState;
142}
143
144// returns FALSE if not connected.
145// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
146// returns the connection state. Can specify NULL if you dont' want to get the actual state.
147
Shailender Karmuchia734f332013-04-19 14:02:48 -0700148static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
149 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700150{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700151 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700152 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700153
Jeff Johnson295189b2012-06-20 16:38:30 -0700154 // get the connection state.
155 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700156 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700157 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700158 eConnectionState_IbssConnected == connState ||
159 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700160 {
161 fConnected = VOS_TRUE;
162 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700163 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700164 {
165 fConnected = VOS_FALSE;
166 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700167
Jeff Johnson295189b2012-06-20 16:38:30 -0700168 if ( pConnState )
169 {
170 *pConnState = connState;
171 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700172
Jeff Johnson295189b2012-06-20 16:38:30 -0700173 return( fConnected );
174}
175
176v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
177{
178 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700179}
Jeff Johnson295189b2012-06-20 16:38:30 -0700180
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530181eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
182{
183 v_U8_t staChannel = 0;
184
185 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
186 {
187 staChannel = pHddStaCtx->conn_info.operationChannel;
188 }
189
190 if ( staChannel > 0 && staChannel < 14 )
191 return eCSR_BAND_24;
192 else if (staChannel >= 36 && staChannel <= 165 )
193 return eCSR_BAND_5G;
194 else /* If station is not connected return as eCSR_BAND_ALL */
195 return eCSR_BAND_ALL;
196}
197
198
Jeff Johnson295189b2012-06-20 16:38:30 -0700199//TODO - Not used anyhwere. Can be removed.
200#if 0
201//
202v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
203{
204 v_BOOL_t fConnectedInfra = FALSE;
205 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700206
Jeff Johnson295189b2012-06-20 16:38:30 -0700207 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700208 {
209 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700210 {
211 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700212 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700213 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700214
Jeff Johnson295189b2012-06-20 16:38:30 -0700215 return( fConnectedInfra );
216}
217#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700218
Jeff Johnson295189b2012-06-20 16:38:30 -0700219static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
220{
221 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700222
Jeff Johnson295189b2012-06-20 16:38:30 -0700223 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700224
225 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700226 {
227 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
228 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700229
Jeff Johnson295189b2012-06-20 16:38:30 -0700230 return( fConnected );
231}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700232
Jeff Johnson295189b2012-06-20 16:38:30 -0700233inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
234{
235 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700236
Jeff Johnson295189b2012-06-20 16:38:30 -0700237 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700238
239 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700240 {
241 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
242 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700243
Jeff Johnson295189b2012-06-20 16:38:30 -0700244 return( fConnected );
245}
246
247static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
248{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700249 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700250 {
251 case eCSR_BSS_TYPE_INFRASTRUCTURE:
252 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
253 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700254
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 case eCSR_BSS_TYPE_IBSS:
256 case eCSR_BSS_TYPE_START_IBSS:
257 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
258 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700259
260 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700262 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700263 default:
264 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700265 break;
266 }
267
Jeff Johnson295189b2012-06-20 16:38:30 -0700268}
269
270void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
271{
272 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
273 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700274
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700276
277 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700279 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700280 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
281 {
282 VOS_ASSERT( pRoamInfo->pBssDesc );
283 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
284
285 // Save the Station ID for this station from the 'Roam Info'.
286 //For IBSS mode, staId is assigned in NEW_PEER_IND
287 //For reassoc, the staID doesn't change and it may be invalid in this structure
288 //so no change here.
289 if( !pRoamInfo->fReassocReq )
290 {
291 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
292 }
293 }
294 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700295 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700296 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700297 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700298 else
299 {
300 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
301 // or we can't function.
302 VOS_ASSERT( 0 );
303 }
304
305 // notify WMM
306 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
307
308 if( !pRoamInfo->u.pConnectedProfile )
309 {
310 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
311 }
312 else
313 {
314 // Get Multicast Encryption Type
315 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
316 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
317 // Get Unicast Encrytion Type
318 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
319 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
320
321 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
322
323 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
324
325 // Save the ssid for the connection
326 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530327
328 // Save dot11mode in which STA associated to AP
329 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700330 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700331 }
332
Jeff Johnson295189b2012-06-20 16:38:30 -0700333 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700334 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
335
Jeff Johnson295189b2012-06-20 16:38:30 -0700336}
337
338#if defined(WLAN_FEATURE_VOWIFI_11R)
339/*
340 * Send the 11R key information to the supplicant.
341 * Only then can the supplicant generate the PMK-R1.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800342 * (BTW, the ESE supplicant also needs the Assoc Resp IEs
Jeff Johnson295189b2012-06-20 16:38:30 -0700343 * for the same purpose.)
344 *
345 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
346 * this contains the R1KHID, R0KHID and the MDID.
347 * For FT, this consists of the Reassoc Rsp FTIEs.
348 * This is the Assoc Response.
349 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700350static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 tCsrRoamInfo *pCsrRoamInfo)
352{
353 union iwreq_data wrqu;
354 char *buff;
355 unsigned int len = 0;
356 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700357
358 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 {
360 hddLog(LOGE,
361 "%s: pCsrRoamInfo->nAssocRspLength=%d",
362 __func__, (int)pCsrRoamInfo->nAssocRspLength);
363 return;
364 }
365
Shailender Karmuchia734f332013-04-19 14:02:48 -0700366 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700367 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700368 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700370 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700371 return;
372 }
373
374 // pFTAssocRsp needs to point to the IEs
375 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
376 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
377 (unsigned int)pFTAssocRsp[0],
378 (unsigned int)pFTAssocRsp[1]);
379
380 // We need to send the IEs to the supplicant.
381 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700382 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700383 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700384 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700385 return;
386 }
387
388 // Send the Assoc Resp, the supplicant needs this for initial Auth.
389 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700390 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700392 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700393 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
394
395 kfree(buff);
396}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700397#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700398
399#ifdef WLAN_FEATURE_VOWIFI_11R
400
401/*---------------------------------------------------
402 *
403 * Send the FTIEs, RIC IEs during FT. This is eventually
404 * used to send the FT events to the supplicant
405 *
406 * At the reception of Auth2 we send the RIC followed
407 * by the auth response IEs to the supplicant.
408 * Once both are received in the supplicant, an FT
409 * event is generated to the supplicant.
410 *
411 *---------------------------------------------------
412 */
413void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
414{
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 tANI_U16 auth_resp_len = 0;
416 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700417 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
418
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530419#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700420 struct cfg80211_ft_event_params ftEvent;
421 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
422 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
423 struct net_device *dev = pAdapter->dev;
424#else
425 char *buff;
426 union iwreq_data wrqu;
427 tANI_U16 str_len;
428#endif
429
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530430#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530431 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
432 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700433
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530434 sme_GetRICIEs( pHddCtx->hHal, (u8 *)ricIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800435 DOT11F_IE_FTINFO_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530436 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700437 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530438 hddLog(LOGW,
439 "%s: RIC IEs is of length 0 not sending RIC Information for now",
440 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700441 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700442
443 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530444 ftEvent.ric_ies_len = ric_ies_length;
445 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700446
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530447 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800448 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700449
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530450 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700451 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530452 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700453 return;
454 }
455
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530456 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530457
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530458 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700459
460 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
461 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
462
Jeff Johnson59a121e2013-11-30 09:46:08 -0800463 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
464 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
465 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530466 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800467 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
468 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
469 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700470
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530471 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700472
473#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530474 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700475 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530476 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530478 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700479 return;
480 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530481 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700482
Shailender Karmuchia734f332013-04-19 14:02:48 -0700483 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -0700484 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530485 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800486 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530487 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530489 hddLog(LOGW,
490 "%s: RIC IEs is of length 0 not sending RIC Information for now",
491 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 }
493 else
494 {
495 wrqu.data.length = str_len + ric_ies_length;
496 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
497 }
498
499 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530500 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530502 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
503 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700504
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530505 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530507 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 return;
509 }
510
511 wrqu.data.length = str_len + auth_resp_len;
512 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
513
514 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700515#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700516}
517
518#endif /* WLAN_FEATURE_VOWIFI_11R */
519
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800520#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700521
522/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800523 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 * (This keeps the supplicant "up to date" on the current channel.)
525 *
526 * The current (new AP) channel information is passed in.
527 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700528static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700529 tCsrRoamInfo *pCsrRoamInfo)
530{
531 union iwreq_data wrqu;
532 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700533
Shailender Karmuchia734f332013-04-19 14:02:48 -0700534
535 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700536 {
537 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800538 "%s: pCsrRoamInfo->pBssDesc=%p",
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 __func__, descriptor);
540 return;
541 }
542
543 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -0800544 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 memset(&wrqu, '\0', sizeof(wrqu));
546 wrqu.freq.m = descriptor->channelId;
547 wrqu.freq.e = 0;
548 wrqu.freq.i = 0;
549 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
550}
551
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800552#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700553
554void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
555{
556 union iwreq_data wrqu;
557 u8 *pBeaconIes;
558 u8 currentLen = 0;
559 char *buff;
560 int totalIeLen = 0, currentOffset = 0, strLen;
561
562 memset(&wrqu, '\0', sizeof(wrqu));
563
564 if (0 == pCsrRoamInfo->nBeaconLength)
565 {
566 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
567 return;
568 }
569 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700570 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700572 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 return;
574 }
575
576 // pBeaconIes needs to point to the IEs
577 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
578 (unsigned int)pBeaconIes[0],
579 (unsigned int)pBeaconIes[1]);
580 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700581
Jeff Johnson295189b2012-06-20 16:38:30 -0700582 // We need to send the IEs to the supplicant.
583 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700584 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700586 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 return;
588 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700589 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700590
591 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
592 currentLen = strLen + 1;
593
594 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
595 do
596 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700597 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700598 * max size and send it to supplicant. Changes are done in supplicant to handle this */
599 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
600 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
601 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
602 currentOffset += currentLen;
603 totalIeLen -= currentLen;
604 wrqu.data.length = strLen + 1 + currentLen;
605 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700606 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 else
608 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
609
610 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
611 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
612 } while (totalIeLen > 0);
613
614 kfree(buff);
615}
616
617static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
618{
619 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
620 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
621 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
622 union iwreq_data wrqu;
623 int we_event;
624 char *msg;
625 int type = -1;
626
Shailender Karmuchia734f332013-04-19 14:02:48 -0700627#if defined (WLAN_FEATURE_VOWIFI_11R)
628 // Added to find the auth type on the fly at run time
629 // rather than with cfg to see if FT is enabled
630 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
632#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700633
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700635 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700637
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
639 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530640 /* In case of roaming ; We are not doing disconnect.
641 * If disconnect is not being done for roam; We will not
642 * decrease count for Active sessions. We should not increase active
643 * active session in case of roaming.
644 */
Padma, Santhosh Kumar87ba40f2014-11-26 19:40:15 +0530645 if((pHddStaCtx->ft_carrier_on == FALSE) && !pCsrRoamInfo->fReassocReq)
Agarwal Ashish51325b52014-06-16 16:50:49 +0530646 {
647 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
648 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
650 type = WLAN_STA_ASSOC_DONE_IND;
651
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700652#ifdef WLAN_FEATURE_P2P_DEBUG
653 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
654 {
655 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
656 {
657 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
658 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
659 "Connecting state to Connected State for 8-way "
660 "Handshake");
661 }
662 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
663 {
664 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
665 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
666 "Connecting state to P2P Client Connection Completed");
667 }
668 }
669#endif
Arif Hussain77d044f2014-01-03 19:56:04 -0800670 pr_info("wlan: " MAC_ADDRESS_STR " connected to " MAC_ADDRESS_STR "\n",
671 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
Kiet Lam34947452014-01-21 23:23:40 -0800672 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
674
675 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
676 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
677 * and fFTEnable is TRUE */
678#ifdef WLAN_FEATURE_VOWIFI_11R
679 // Send FT Keys to the supplicant when FT is enabled
680 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700681 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800682#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
684 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
685#endif
686 )
687 {
688 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
689 }
690#endif
691 }
692 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
693 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530694 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -0700695 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 type = WLAN_STA_ASSOC_DONE_IND;
Arif Hussain24bafea2013-11-15 15:10:03 -0800697 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR"\n",
698 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 }
700 else /* Not Associated */
701 {
702 pr_info("wlan: disconnected\n");
703 type = WLAN_STA_DISASSOC_DONE_IND;
704 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
705 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700706 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700707
708 msg = NULL;
709 /*During the WLAN uninitialization,supplicant is stopped before the
710 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530711 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700712 {
713 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800714#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700716 {
717 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
718 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
720 }
721#endif
722 }
723 send_btc_nlink_msg(type, 0);
724}
725
726void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
727{
728 // Remove staId, bssId and peerMacAddress
729 pHddStaCtx->conn_info.staId [ 0 ] = 0;
730 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
731 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
732
733 // Clear all security settings
734 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
735 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
736 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
737
738 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700739 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700740
741 // Set not-connected state
742 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700743
744 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
745}
746/* TODO Revist this function. and data path */
747static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
748{
749 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700750 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
751
752 if (WLAN_HDD_IBSS != pAdapter->device_mode)
753 {
754 hdd_disconnect_tx_rx(pAdapter);
755 }
756 else
757 {
758 // Need to cleanup all queues only if the last peer leaves
759 if (eConnectionState_IbssDisconnected == pHddStaCtx->conn_info.connState)
760 {
761 netif_tx_disable(pAdapter->dev);
762 netif_carrier_off(pAdapter->dev);
763 hdd_disconnect_tx_rx(pAdapter);
764 }
765 else
766 {
767 // There is atleast one more peer, do not cleanup all queues
768 hdd_flush_ibss_tx_queues(pAdapter, staId);
769 }
770 }
771
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
773 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
774 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530775 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700776 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700777 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700778 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700779 }
780 return( vosStatus );
781}
782
783
784static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
785 tANI_U32 roamId, eRoamCmdStatus roamStatus,
786 eCsrRoamResult roamResult )
787{
788 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700789 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700790 struct net_device *dev = pAdapter->dev;
791 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
792 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700793 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530794 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700795
796 // Sanity check
797 if(dev == NULL)
798 {
Agarwal Ashish971c2882013-10-30 20:11:12 +0530799 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700800 "%s: net_dev is released return", __func__);
801 return eHAL_STATUS_FAILURE;
802 }
803
Jeff Johnson295189b2012-06-20 16:38:30 -0700804 // notify apps that we can't pass traffic anymore
805 netif_tx_disable(dev);
806 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +0530807 //TxTimeoutCount need to reset in case of disconnect handler
808 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700809
Jeff Johnsone7245742012-09-05 17:12:55 -0700810 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530811 /* HDD has initiated disconnect, do not send disconnect indication
812 * to kernel as it will be handled by __cfg80211_disconnect.
813 */
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530814 /* If only STA mode is on */
815 if((pHddCtx->concurrency_mode <= 1) &&
816 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
817 {
818 pHddCtx->isAmpAllowed = VOS_TRUE;
819 }
820
Agarwal Ashish47d18112014-08-04 19:55:07 +0530821 /* Need to apply spin lock before decreasing active sessions
822 * as there can be chance for double decrement if context switch
823 * Calls wlan_hdd_disconnect.
824 */
825
826 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530827 if ( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState )
828 {
829 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
830 FL(" HDD has initiated a disconnect, no need to send"
831 " disconnect indication to kernel"));
832 sendDisconInd = FALSE;
833 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530834 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530836 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +0530837 FL(" Set HDD connState to eConnectionState_Disconnecting from %d "),
838 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530839 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
840 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 }
Agarwal Ashish47d18112014-08-04 19:55:07 +0530842 spin_unlock_bh(&pAdapter->lock_for_active_session);
843
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -0700845
846 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -0700847
848 // indicate 'disconnect' status to wpa_supplicant...
849 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700850 /* indicate disconnected event to nl80211 */
851 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
852 {
853 /*During the WLAN uninitialization,supplicant is stopped before the
854 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530855 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700857 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
858 "%s: sent disconnected event to nl80211",
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700860#ifdef WLAN_FEATURE_P2P_DEBUG
861 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
862 {
863 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
864 {
865 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
866 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
867 "and moved to disconnected state");
868 }
869 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
870 {
871 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
872 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
873 "and moved to inactive state");
874 }
875 }
876#endif
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530877 /*Only send indication to kernel if not initiated by kernel*/
878 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530880 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
881 if ( eCSR_ROAM_LOSTLINK == roamStatus )
882 {
883 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
884 }
885 else
886 {
887 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
888 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 //If the Device Mode is Station
891 // and the P2P Client is Connected
892 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700893
894 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -0700895 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -0700896 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 {
898 //Enable BMPS only of other Session is P2P Client
899 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700900 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -0700901
902 if (NULL != pVosContext)
903 {
904 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
905
906 if(NULL != pHddCtx)
907 {
908 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +0530909 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
910 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530912 if (pHddCtx->hdd_wlan_suspended)
913 {
914 hdd_set_pwrparams(pHddCtx);
915 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530917 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 }
919 }
920 }
921 }
922 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700923
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +0530924 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +0530925#if defined(WLAN_FEATURE_VOWIFI_11R)
926 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
927#endif
Katya Nigam63ce1772014-09-26 15:53:49 +0530928
929 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
930 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530931 v_U8_t i;
932
Katya Nigam63ce1772014-09-26 15:53:49 +0530933 sta_id = IBSS_BROADCAST_STAID;
934 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
935 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
936 {
937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530938 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
939 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +0530940 sta_id, status, status );
941
942 status = eHAL_STATUS_FAILURE;
943 }
Katya Nigam63ce1772014-09-26 15:53:49 +0530944 pHddCtx->sta_to_adapter[sta_id] = NULL;
945
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530946 /*Clear all the peer sta register with TL.*/
947 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
948 {
949 if (0 != pHddStaCtx->conn_info.staId[i])
950 {
951 sta_id = pHddStaCtx->conn_info.staId[i];
952
953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
954 FL("Deregister StaID %d"),sta_id);
955 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
956 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
957 {
958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
959 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
960 "Status= %d [0x%x]"),
961 sta_id, status, status );
962 status = eHAL_STATUS_FAILURE;
963 }
964
965 /*set the staid and peer mac as 0, all other reset are
966 * done in hdd_connRemoveConnectInfo.
967 */
968 pHddStaCtx->conn_info.staId[i]= 0;
969 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
970
971 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
972 pHddCtx->sta_to_adapter[sta_id] = NULL;
973 }
974 }
975
Katya Nigam63ce1772014-09-26 15:53:49 +0530976 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530977 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530979 sta_id = pHddStaCtx->conn_info.staId[0];
980
981 //We should clear all sta register with TL, for now, only one.
982 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
983 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
984 {
985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
986 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
987 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -0700988 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700989
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530990 status = eHAL_STATUS_FAILURE;
991 }
992
993 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700994 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700995 // Clear saved connection information in HDD
996 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +0530997 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
998 "%s: Set HDD connState to eConnectionState_NotConnected",
999 __func__);
1000 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301001#ifdef WLAN_FEATURE_GTK_OFFLOAD
1002 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1003 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1004 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301005 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1006 sizeof (tSirGtkOffloadParams));
1007 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301008 }
1009#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001010
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001011#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001012 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1013 {
1014 wlan_hdd_tdls_disconnection_callback(pAdapter);
1015 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001016#endif
1017
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 //Unblock anyone waiting for disconnect to complete
1019 complete(&pAdapter->disconnect_comp_var);
1020 return( status );
1021}
1022static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
1023 tCsrRoamInfo *pRoamInfo,
1024 v_U8_t staId,
1025 v_MACADDR_t *pPeerMacAddress,
1026 tSirBssDescription *pBssDesc )
1027{
1028 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1029 WLAN_STADescType staDesc = {0};
1030 eCsrEncryptionType connectedCipherAlgo;
1031 v_BOOL_t fConnected;
1032 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1033 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001034 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001035
1036 if ( NULL == pBssDesc)
1037 {
1038 return VOS_STATUS_E_FAILURE;
1039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001040 // Get the Station ID from the one saved during the assocation.
1041 staDesc.ucSTAId = staId;
1042
1043 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001045 staDesc.wSTAType = WLAN_STA_INFRA;
1046
1047 // grab the bssid from the connection info in the adapter structure and hand that
1048 // over to TL when registering.
1049 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
1050 }
1051 else
1052 {
1053 // for an IBSS 'connect', setup the Station Descriptor for TL.
Jeff Johnson295189b2012-06-20 16:38:30 -07001054 staDesc.wSTAType = WLAN_STA_IBSS;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001055
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
1057 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
1058 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
1059 // pass when making an Infrastructure connection.
1060 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
1061 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
1062 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001063
Jeff Johnson295189b2012-06-20 16:38:30 -07001064 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1065
1066 // set the QoS field appropriately
1067 if (hdd_wmm_is_active(pAdapter))
1068 {
1069 staDesc.ucQosEnabled = 1;
1070 }
1071 else
1072 {
1073 staDesc.ucQosEnabled = 0;
1074 }
1075
1076 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1077 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1078 {
1079 staDesc.ucProtectedFrame = 1;
1080 }
1081 else
1082 {
1083 staDesc.ucProtectedFrame = 0;
1084
1085 }
1086
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001087#ifdef FEATURE_WLAN_ESE
1088 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1089#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001090
1091#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1092 /* check whether replay check is valid for the station or not */
1093 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1094 {
1095 /* Encryption mode is either TKIP or AES
1096 and replay check is valid for only these
1097 two encryption modes */
1098 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1099 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1100 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1101 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001102
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 else
1104 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001105 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001106 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001107 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1109 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1110 }
1111#endif
1112
1113#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001114 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 if (pAdapter->wapi_info.fIsWapiSta)
1116 {
1117 staDesc.ucIsWapiSta = 1;
1118 }
1119 else
1120 {
1121 staDesc.ucIsWapiSta = 0;
1122 }
1123#endif /* FEATURE_WLAN_WAPI */
1124
1125 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1126 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1127
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 // UMA is Not ready yet, Xlation will be done by TL
1129 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 staDesc.ucSwFrameRXXlation = 1;
1131 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001132 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 staDesc.ucQosEnabled );
1134 // Initialize signatures and state
1135 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1136 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1137 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1138 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001139 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001140 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 -07001141 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1142 hdd_rx_packet_cbk,
1143 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001144 hdd_tx_fetch_packet_cbk, &staDesc,
1145 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001146
Jeff Johnson295189b2012-06-20 16:38:30 -07001147 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1148 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001149 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001150 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001151 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001152 return vosStatus;
1153 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001154
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001155 if ( cfg_param->dynSplitscan &&
1156 ( VOS_TIMER_STATE_RUNNING !=
1157 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1158 {
1159 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1160 cfg_param->trafficMntrTmrForSplitScan);
1161 }
1162
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301163 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1164 // then go to 'authenticated'. For all other authentication types
1165 // (those that donot require upper layer authentication) we can put
1166 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001167 if (staDesc.wSTAType != WLAN_STA_IBSS)
1168 VOS_ASSERT( fConnected );
1169
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301170 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001171 {
1172 // Connections that do not need Upper layer auth, transition TL directly
1173 // to 'Authenticated' state.
1174 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1175 WLANTL_STA_AUTHENTICATED );
1176
1177 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1178 }
1179 else
1180 {
1181 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301182 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1183 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001184 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301185 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001186 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001188 return( vosStatus );
1189}
1190
Jeff Johnson295189b2012-06-20 16:38:30 -07001191static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1192 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1193{
1194 unsigned int len = 0;
1195 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001196 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 tANI_U32 rspRsnLength = 0;
1198 struct ieee80211_channel *chan;
1199
Agarwal Ashish51325b52014-06-16 16:50:49 +05301200 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001201 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001202 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001203 }
1204
Agarwal Ashish51325b52014-06-16 16:50:49 +05301205 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001206 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1207 goto done;
1208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001209
Agarwal Ashish51325b52014-06-16 16:50:49 +05301210 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001211 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1212 goto done;
1213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001214
1215 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1216 pCsrRoamInfo->nAssocReqLength);
1217 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001218 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001219
1220 //pFTAssocRsp needs to point to the IEs
1221 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001222 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 (unsigned int)pFTAssocRsp[0],
1224 (unsigned int)pFTAssocRsp[1]);
1225
1226 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001227 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001230 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001231
1232 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1233 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1234 reqRsnIe, reqRsnLength,
1235 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001236
1237done:
1238 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001239}
Jeff Johnson295189b2012-06-20 16:38:30 -07001240
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301241void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1242{
1243 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1244 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1245 tCsrRoamInfo roamInfo;
1246 roamInfo.fAuthRequired = FALSE;
1247 vos_mem_copy(roamInfo.bssid,
1248 pHddStaCtx->roam_info.bssid,
1249 WNI_CFG_BSSID_LEN);
1250 vos_mem_copy(roamInfo.peerMac,
1251 pHddStaCtx->roam_info.peerMac,
1252 WNI_CFG_BSSID_LEN);
1253
1254 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1255 &roamInfo,
1256 pHddStaCtx->roam_info.roamId,
1257 pHddStaCtx->roam_info.roamStatus,
1258 eCSR_ROAM_RESULT_AUTHENTICATED);
1259 if (halStatus != eHAL_STATUS_SUCCESS)
1260 {
1261 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1262 }
1263 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1264}
1265
Shailender Karmuchia734f332013-04-19 14:02:48 -07001266static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1267 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 eCsrRoamResult roamResult )
1269{
1270 struct net_device *dev = pAdapter->dev;
1271 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1272 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301273 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05301274 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001275 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1276 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001277#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001278 int ft_carrier_on = FALSE;
1279#endif
1280 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301281 v_BOOL_t hddDisconInProgress = FALSE;
1282
1283 /* HDD has initiated disconnect, do not send connect result indication
1284 * to kernel as it will be handled by __cfg80211_disconnect.
1285 */
1286 if(( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) &&
1287 (( eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1288 ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)) )
1289 {
1290 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1291 FL(" Disconnect from HDD in progress "));
1292 hddDisconInProgress = TRUE;
1293 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001294
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1296 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301297 if ( !hddDisconInProgress )
1298 {
1299 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301300 "%s: Set HDD connState to eConnectionState_Associated",
1301 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301302 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001304
c_hpothu44ff4e02014-05-08 00:13:57 +05301305 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001306 // Save the connection info from CSR...
1307 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1308#ifdef FEATURE_WLAN_WAPI
1309 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1310 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1311 {
1312 pAdapter->wapi_info.fIsWapiSta = 1;
1313 }
1314 else
1315 {
1316 pAdapter->wapi_info.fIsWapiSta = 0;
1317 }
1318#endif /* FEATURE_WLAN_WAPI */
1319
1320 // indicate 'connect' status to userspace
1321 hdd_SendAssociationEvent(dev,pRoamInfo);
1322
1323
Shailender Karmuchia734f332013-04-19 14:02:48 -07001324 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 INIT_COMPLETION(pAdapter->linkup_event_var);
1326
1327 /*
1328 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1329 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 -07001330 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 know that the device is getting activated properly.
1332 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001333#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05301334 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 {
1336#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001337 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 pAdapter->isLinkUpSvcNeeded = TRUE;
1339
Shailender Karmuchia734f332013-04-19 14:02:48 -07001340 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 pAdapter->isLinkUpSvcNeeded = TRUE;
1342
1343 // Switch on the Carrier to activate the device
1344 netif_carrier_on(dev);
1345
1346 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1347 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1348 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001349 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001350 {
1351 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1352 }
1353
1354 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1355 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001356#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001358 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 }
1362#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301363 /* Check for STAID */
1364 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1365 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1366 else
1367 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001368
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001369#ifdef FEATURE_WLAN_TDLS
1370 wlan_hdd_tdls_connection_callback(pAdapter);
1371#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 //For reassoc, the station is already registered, all we need is to change the state
1373 //of the STA in TL.
1374 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05301375 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07001376 if( !pRoamInfo->fReassocReq )
1377 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001378 struct cfg80211_bss *bss;
1379#ifdef WLAN_FEATURE_VOWIFI_11R
1380 u8 *pFTAssocRsp = NULL;
1381 unsigned int assocRsplen = 0;
1382 u8 *pFTAssocReq = NULL;
1383 unsigned int assocReqlen = 0;
1384 struct ieee80211_channel *chan;
1385#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001386 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001388
1389 /* add bss_id to cfg80211 data base */
1390 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1391 if (NULL == bss)
1392 {
1393 pr_err("wlan: Not able to create BSS entry\n");
Katya Nigam346d4e92014-09-02 16:16:12 +05301394 netif_carrier_off(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 return eHAL_STATUS_FAILURE;
1396 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001397#ifdef WLAN_FEATURE_VOWIFI_11R
1398 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001399 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001401
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001402 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001403 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001404 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001405 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001406 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001407 // pFTAssocRsp needs to point to the IEs
1408 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1409 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1410 (unsigned int)pFTAssocRsp[0],
1411 (unsigned int)pFTAssocRsp[1]);
1412 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001413 }
1414 else
1415 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001416 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1417 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001418 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001419
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001420 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001421 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001422 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001423 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001424 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001425 if(!ft_carrier_on)
1426 {
1427 // pFTAssocReq needs to point to the IEs
1428 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1429 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1430 (unsigned int)pFTAssocReq[0],
1431 (unsigned int)pFTAssocReq[1]);
1432 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1433 }
1434 else
1435 {
1436 /* This should contain only the FTIEs */
1437 assocReqlen = pRoamInfo->nAssocReqLength;
1438 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001439 }
1440 else
1441 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001442 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1443 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001444 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001445
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001446 if(ft_carrier_on)
1447 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301448 if ( !hddDisconInProgress )
1449 {
1450 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001451 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301452 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001453 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301454 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001455 assocRsplen);
Girish Gowlidf0ed732014-08-11 12:39:39 +05301456#ifdef DEBUG_ROAM_DELAY
1457 //HACK we are using the buff len as Auth Type
1458 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1459#endif
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301460 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001461 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1462 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301463 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301464 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1465 {
1466 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1467 pRoamInfo->fAuthRequired = FALSE;
1468
1469 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1470 pRoamInfo->bssid,
1471 HDD_MAC_ADDR_LEN);
1472 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1473 pRoamInfo->peerMac,
1474 HDD_MAC_ADDR_LEN);
1475 pHddStaCtx->roam_info.roamId = roamId;
1476 pHddStaCtx->roam_info.roamStatus = roamStatus;
1477 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1478 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001479 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301480 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001481 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001482 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001483 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001484 cfg80211_connect_result(dev, pRoamInfo->bssid,
1485 pFTAssocReq, assocReqlen,
1486 pFTAssocRsp, assocRsplen,
1487 WLAN_STATUS_SUCCESS,
1488 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001489 }
1490 }
1491 else
1492#endif
1493 {
1494 /* wpa supplicant expecting WPA/RSN IE in connect result */
1495 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1496 pAdapter->sessionId,
1497 &reqRsnLength,
1498 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001499
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001500 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1501 pAdapter->sessionId,
1502 &rspRsnLength,
1503 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301504 if ( !hddDisconInProgress )
1505 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001506#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301507 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301508 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301509 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Mukul Sharma84f27252014-07-14 18:11:42 +05301510#ifdef DEBUG_ROAM_DELAY
1511 //HACK we are using the buff len as Auth Type
1512 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1513#endif
1514 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301515 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001516#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001517
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301518 {
1519 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301520 "%s: sending connect indication to nl80211:"
1521 " for bssid " MAC_ADDRESS_STR
1522 " reason:%d and Status:%d\n",
1523 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1524 roamResult, roamStatus);
1525
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301526 /* inform connect result to nl80211 */
1527 cfg80211_connect_result(dev, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001528 reqRsnIe, reqRsnLength,
1529 rspRsnIe, rspRsnLength,
1530 WLAN_STATUS_SUCCESS,
1531 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301532 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001534 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301535 if ( !hddDisconInProgress )
1536 {
1537 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001538#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301539 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001540#endif
1541 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301542 // Register the Station with TL after associated...
1543 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 pRoamInfo,
1545 pHddStaCtx->conn_info.staId[ 0 ],
1546 NULL,
1547 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001549 }
1550 else
1551 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001552 /* wpa supplicant expecting WPA/RSN IE in connect result */
1553 /* in case of reassociation also need to indicate it to supplicant */
1554 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1555 pAdapter->sessionId,
1556 &reqRsnLength,
1557 reqRsnIe);
1558
1559 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001560 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301561 if( pRoamInfo->fAuthRequired )
1562 {
1563 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1564 pHddStaCtx->conn_info.staId[ 0 ],
1565 WLANTL_STA_CONNECTED );
1566 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1567 }
1568 else
1569 {
1570 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1571 "%s: staId: %d Changing TL state to AUTHENTICATED",
1572 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1573 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1574 pHddStaCtx->conn_info.staId[ 0 ],
1575 WLANTL_STA_AUTHENTICATED );
1576 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 }
1579
1580 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1581 {
1582 // perform any WMM-related association processing
1583 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1584 }
1585 else
1586 {
1587 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001588 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 vosStatus, vosStatus );
1590 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001591#ifdef WLAN_FEATURE_11W
1592 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1593 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1594#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001595 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05301596 if ( !hddDisconInProgress )
1597 netif_tx_wake_all_queues(dev);
Mukul Sharma84f27252014-07-14 18:11:42 +05301598#ifdef DEBUG_ROAM_DELAY
1599 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1600#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001601 }
1602 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1605
1606 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001607 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001608 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1609 " reason:%d and Status:%d\n",
1610 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1611 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001612 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001613 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1614 " reason:%d and Status:%d\n",
1615 MAC_ADDR_ARRAY(pWextState->req_bssId),
1616 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001617
Abhishek Singhf4669da2014-05-26 15:07:49 +05301618 /* Set connection state to eConnectionState_NotConnected only when CSR
1619 * has completed operation - with a ASSOCIATION_FAILURE status
1620 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301621 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301622 {
1623 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1624 "%s: Set HDD connState to eConnectionState_NotConnected",
1625 __func__);
1626 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1627 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05301628 if((pHddCtx->concurrency_mode <= 1) &&
1629 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 {
1631 pHddCtx->isAmpAllowed = VOS_TRUE;
1632 }
1633
1634 //If the Device Mode is Station
1635 // and the P2P Client is Connected
1636 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001637
1638 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001639 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001640 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1641 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05301642 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07001643 {
1644 //Enable BMPS only of other Session is P2P Client
1645 hdd_context_t *pHddCtx = NULL;
1646 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1647
1648 if (NULL != pVosContext)
1649 {
1650 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1651
1652 if(NULL != pHddCtx)
1653 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301654 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301655 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1656 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301657 {
1658 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001659 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301660 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001661 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301662 hdd_enable_bmps_imps(pHddCtx);
1663 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001664 }
1665 }
1666 }
1667
James Zmudafbf5ffc2013-03-25 12:45:35 -07001668 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001669 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301670 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07001671 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301672 if (pRoamInfo)
1673 hddLog(VOS_TRACE_LEVEL_ERROR,
1674 "%s: send connect failure to nl80211:"
1675 " for bssid " MAC_ADDRESS_STR
1676 " reason:%d and Status:%d\n" ,
1677 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1678 roamResult, roamStatus);
1679 else
1680 hddLog(VOS_TRACE_LEVEL_ERROR,
1681 "%s: connect failed:"
1682 " for bssid " MAC_ADDRESS_STR
1683 " reason:%d and Status:%d\n" ,
1684 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1685 roamResult, roamStatus);
1686
c_hpothudaa90e22014-06-24 17:23:43 +05301687 /*Clear the roam profile*/
1688 hdd_clearRoamProfileIe( pAdapter );
1689
James Zmudafbf5ffc2013-03-25 12:45:35 -07001690 /* inform association failure event to nl80211 */
1691 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1692 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001693 if (pRoamInfo)
1694 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1695 NULL, 0, NULL, 0,
1696 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1697 GFP_KERNEL );
1698 else
1699 cfg80211_connect_result ( dev, pWextState->req_bssId,
1700 NULL, 0, NULL, 0,
1701 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1702 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001703 }
1704 else
1705 {
Sushant Kaushik21f28232014-12-18 11:42:46 +05301706 if (pRoamInfo){
1707 eCsrAuthType authType =
1708 pWextState->roamProfile.AuthType.authType[0];
1709 v_BOOL_t isWep = (authType == eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
1710 (authType == eCSR_AUTH_TYPE_SHARED_KEY);
1711
1712 /* In case of OPEN-WEP or SHARED-WEP authentication,
1713 * send exact protocol reason code. This enables user
1714 * applications to reconnect the station with correct
1715 * configuration.
1716 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001717 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1718 NULL, 0, NULL, 0,
Sushant Kaushik21f28232014-12-18 11:42:46 +05301719 isWep ? pRoamInfo->reasonCode :
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001720 WLAN_STATUS_UNSPECIFIED_FAILURE,
1721 GFP_KERNEL );
Sushant Kaushik21f28232014-12-18 11:42:46 +05301722 } else
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001723 cfg80211_connect_result ( dev, pWextState->req_bssId,
1724 NULL, 0, NULL, 0,
1725 WLAN_STATUS_UNSPECIFIED_FAILURE,
1726 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001727 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001728 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001729
Kumar Anand82c009f2014-05-29 00:29:42 -07001730 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001731
c_hpothu24f40982014-04-18 18:00:36 +05301732 if (pRoamInfo)
1733 {
1734 WLANTL_AssocFailed(pRoamInfo->staId);
1735 }
Mihir Sheteb7337272014-04-11 15:53:08 +05301736
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 netif_tx_disable(dev);
1738 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001739
Jeff Johnson295189b2012-06-20 16:38:30 -07001740 }
1741
Sushant Kaushikbf584e92014-08-06 17:59:20 +05301742 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301743 {
1744 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
1745 if (pHostapdAdapter != NULL)
1746 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05301747 /* Restart SAP if its operating channel is different
1748 * from AP channel.
1749 */
1750 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
1751 (int)pRoamInfo->pBssDesc->channelId)
1752 {
1753 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
1754 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
1755 (int)pRoamInfo->pBssDesc->channelId);
Deepthi Gowric9c777d2014-12-10 16:17:11 +05301756 hdd_hostapd_stop(pHostapdAdapter->dev);
Sushant Kaushikbf584e92014-08-06 17:59:20 +05301757 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301758 }
1759 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 return eHAL_STATUS_SUCCESS;
1761}
1762
1763/**============================================================================
1764 *
Jeff Johnson81c17882013-05-03 09:53:35 -07001765 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07001766 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07001767
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07001769static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
1770 tCsrRoamInfo *pRoamInfo,
1771 tANI_U32 roamId,
1772 eRoamCmdStatus roamStatus,
1773 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07001774{
Jeff Johnson81c17882013-05-03 09:53:35 -07001775 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
1776 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
1777
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 switch( roamResult )
1779 {
1780 // both IBSS Started and IBSS Join should come in here.
1781 case eCSR_ROAM_RESULT_IBSS_STARTED:
1782 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001783 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001785 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1786 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001787
Jeff Johnson81c17882013-05-03 09:53:35 -07001788 if (NULL == pRoamInfo)
1789 {
1790 VOS_ASSERT(0);
1791 return;
1792 }
1793
1794 /* When IBSS Started comes from CSR, we need to move
1795 * connection state to IBSS Disconnected (meaning no peers
1796 * are in the IBSS).
1797 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05301798 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1799 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
1800 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07001801 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
1802 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05301803 /*notify wmm */
1804 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001805 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1806 hdd_roamRegisterSTA (pAdapter, pRoamInfo,
1807 IBSS_BROADCAST_STAID,
1808 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001809
Jeff Johnson81c17882013-05-03 09:53:35 -07001810 if (pRoamInfo->pBssDesc)
1811 {
1812 struct cfg80211_bss *bss;
1813
1814 /* we created the IBSS, notify supplicant */
1815 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
1816 MAC_ADDRESS_STR,
1817 __func__, pAdapter->dev->name,
1818 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
1819
1820 /* we must first give cfg80211 the BSS information */
1821 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1822 if (NULL == bss)
1823 {
1824 hddLog(VOS_TRACE_LEVEL_ERROR,
1825 "%s: %s: unable to create IBSS entry",
1826 __func__, pAdapter->dev->name);
1827 return;
1828 }
1829
1830 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001831 cfg80211_put_bss(
1832#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1833 pHddCtx->wiphy,
1834#endif
1835 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07001836 }
1837
Jeff Johnson295189b2012-06-20 16:38:30 -07001838 break;
1839 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001840
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1842 {
Jeff Johnson81c17882013-05-03 09:53:35 -07001843 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
1844 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 break;
1846 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001847
Jeff Johnson295189b2012-06-20 16:38:30 -07001848 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07001849 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
1850 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001851 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001852 }
1853
Jeff Johnson81c17882013-05-03 09:53:35 -07001854 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001855}
1856
1857/**============================================================================
1858 *
1859 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1860 This information is passed to iwconfig later. The peer that joined
1861 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001862 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001864
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 ===========================================================================*/
1866static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1867{
1868 int fSuccess = FALSE;
1869 int idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001870
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1872 {
1873 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1874 {
1875 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001876
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001878
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 fSuccess = TRUE;
1880 break;
1881 }
1882 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001883
1884 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07001885}
1886/**============================================================================
1887 *
1888 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001889 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001891
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07001893static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07001894{
1895 int fSuccess = FALSE;
1896 int idx = 0;
1897 v_U8_t valid_idx = 0;
1898 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07001899 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001900 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001901
Jeff Johnson295189b2012-06-20 16:38:30 -07001902 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1903 {
1904 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1905 {
1906 pHddStaCtx->conn_info.staId[ idx ] = 0;
1907
1908 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1909
1910 fSuccess = TRUE;
Ravi Joshi8a934352013-09-25 16:46:58 -07001911
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 // Note the deleted Index, if its 0 we need special handling
1913 del_idx = idx;
Ravi Joshi8a934352013-09-25 16:46:58 -07001914
1915 empty_slots++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 }
1917 else
1918 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001919 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 {
1921 valid_idx = idx;
1922 }
Ravi Joshi8a934352013-09-25 16:46:58 -07001923 else
1924 {
1925 // Found an empty slot
1926 empty_slots++;
1927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 }
1929 }
1930
Ravi Joshi8a934352013-09-25 16:46:58 -07001931 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
1932 {
1933 // Last peer departed, set the IBSS state appropriately
1934 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001935 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07001936 "Last IBSS Peer Departed!!!" );
1937 }
1938
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 // Find next active staId, to have a valid sta trigger for TL.
1940 if (fSuccess == TRUE)
1941 {
1942 if (del_idx == 0)
1943 {
1944 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1945 {
1946 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1947 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1948 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1949
1950 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1951 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1952 }
1953 }
1954 }
1955 return( fSuccess );
1956}
1957
1958/**============================================================================
1959 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001960 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07001961 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001962
Jeff Johnson295189b2012-06-20 16:38:30 -07001963 ===========================================================================*/
1964static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1965{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001966 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05301967 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1968 "%s: IBSS Connect Indication from SME!!! "
1969 "Set HDD connState to eConnectionState_IbssConnected",
1970 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1972 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1973
1974 // Save the connection info from CSR...
1975 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1976
1977 // Send the bssid address to the wext.
1978 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001979 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001980 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1981 if (NULL == bss)
1982 {
1983 hddLog(VOS_TRACE_LEVEL_ERROR,
1984 "%s: %s: unable to create IBSS entry",
1985 __func__, pAdapter->dev->name);
1986 return eHAL_STATUS_FAILURE;
1987 }
Yue Maf49ba872013-08-19 12:04:25 -07001988 cfg80211_put_bss(
1989#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1990 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
1991#endif
1992 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001993
1994 return( eHAL_STATUS_SUCCESS );
1995}
1996/**============================================================================
1997 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05301998 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
1999 suspend related data which was cleared during roaming in FWR.
2000
2001 ===========================================================================*/
2002static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
2003{
2004 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
2005 hdd_adapter_t *pAdapter;
2006 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
2007 ENTER();
2008
2009 spin_lock(&pHddCtx->filter_lock);
2010 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
2011 {
2012 pHddCtx->sus_res_mcastbcast_filter =
2013 pHddCtx->configuredMcastBcastFilter;
2014 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
2015 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
2016 hddLog(VOS_TRACE_LEVEL_INFO,
2017 FL("saving configuredMcastBcastFilter = %d"),
2018 pHddCtx->configuredMcastBcastFilter);
2019 hddLog(VOS_TRACE_LEVEL_INFO,
2020 FL("offload: calling hdd_conf_mcastbcast_filter"));
2021 }
2022 spin_unlock(&pHddCtx->filter_lock);
2023
2024 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
2025 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
2026 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
2027
2028 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
2029 //No need to configure GTK Offload from here because it might possible
2030 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
2031 //be handled as part of cfg80211_set_rekey_data processing.
2032 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
2033 {
2034 pAdapter = pAdapterNode->pAdapter;
2035 if( pAdapter &&
2036 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
2037 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
2038 {
2039 if (pHddCtx->cfg_ini->fhostArpOffload)
2040 {
2041 //Configure ARPOFFLOAD
2042 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
2043 if (!VOS_IS_STATUS_SUCCESS(vstatus))
2044 {
2045 hddLog(VOS_TRACE_LEVEL_ERROR,
2046 FL("Failed to disable ARPOffload Feature %d"), vstatus);
2047 }
2048 }
2049#ifdef WLAN_NS_OFFLOAD
2050 //Configure NSOFFLOAD
2051 if (pHddCtx->cfg_ini->fhostNSOffload)
2052 {
2053 hdd_conf_ns_offload(pAdapter, TRUE);
2054 }
2055#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05302056#ifdef WLAN_FEATURE_PACKET_FILTERING
2057 /* During suspend, configure MC Addr list filter to the firmware
2058 * function takes care of checking necessary conditions before
2059 * configuring.
2060 */
2061 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
2062#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05302063 }
2064 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2065 pAdapterNode = pNext;
2066 }
2067 EXIT();
2068}
2069
2070/**============================================================================
2071 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002073
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002075static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2076 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 eCsrRoamResult roamResult )
2078{
2079 eCsrEncryptionType connectedCipherAlgo;
2080 v_BOOL_t fConnected = FALSE;
2081 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2082 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2083 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2084 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002085
2086 if (NULL == pRoamInfo)
2087 {
2088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2089 return eHAL_STATUS_FAILURE;
2090 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002092 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 // not require upper layer authentication) we can put TL directly into 'authenticated'
2094 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2096 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2097 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002098
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2100 if( fConnected )
2101 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002102 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2103 {
2104 v_U8_t staId;
2105
2106 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2107
2108 if ( 0 == memcmp( pRoamInfo->peerMac,
2109 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2110 {
2111 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2112 IBSS_BROADCAST_STAID);
2113 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2114 }
2115 else
2116 {
2117 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2118 (v_MACADDR_t*)pRoamInfo->peerMac,
2119 &staId);
2120 if ( VOS_STATUS_SUCCESS == vosStatus )
2121 {
2122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2123 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2124 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2125 staId);
2126 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2127 }
2128 }
2129 }
2130 else
2131 {
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302132 // TODO: Considering getting a state machine in HDD later.
2133 // This routine is invoked twice. 1)set PTK 2)set GTK.
2134 // The folloing if statement will be TRUE when setting GTK.
2135 // At this time we don't handle the state in detail.
2136 // Related CR: 174048 - TL not in authenticated state
2137 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2138 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2139 {
2140 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2141 "for StaId= %d. Changing TL state to AUTHENTICATED",
2142 pHddStaCtx->conn_info.staId[ 0 ] );
2143
2144 // Connections that do not need Upper layer authentication,
2145 // transition TL to 'Authenticated' state after the keys are set.
2146 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2147 pHddStaCtx->conn_info.staId[ 0 ],
2148 WLANTL_STA_AUTHENTICATED );
2149
2150 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Mukul Sharmad2589a52014-04-23 21:06:25 +05302151 //Need to call offload because when roaming happen at that time fwr
2152 //clean offload info as part of the DelBss
2153 // No need to configure offload if host was not suspended
2154 spin_lock(&pHddCtx->filter_lock);
2155 if(pHddCtx->hdd_wlan_suspended)
2156 {
2157 spin_unlock(&pHddCtx->filter_lock);
2158 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2159 }
2160 else
2161 {
2162 spin_unlock(&pHddCtx->filter_lock);
2163 }
Mukul Sharma84f27252014-07-14 18:11:42 +05302164#ifdef DEBUG_ROAM_DELAY
2165 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2166#endif
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302167 }
2168 else
2169 {
2170 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2171 pHddStaCtx->conn_info.staId[ 0 ]);
Mukul Sharma84f27252014-07-14 18:11:42 +05302172#ifdef DEBUG_ROAM_DELAY
2173 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2174#endif
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302175 }
2176
2177 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302180 else
2181 {
2182 // possible disassoc after issuing set key and waiting set key complete
2183 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2184 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002185
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 EXIT();
2187 return( eHAL_STATUS_SUCCESS );
2188}
2189/**============================================================================
2190 *
2191 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2192 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002193static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002194 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002195{
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2197
2198 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2199 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2200 {
2201 struct iw_michaelmicfailure msg;
2202 union iwreq_data wreq;
2203 memset(&msg, '\0', sizeof(msg));
2204 msg.src_addr.sa_family = ARPHRD_ETHER;
2205 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002206 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2207 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002208
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2210 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002211 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 msg.flags = IW_MICFAILURE_PAIRWISE;
2213 memset(&wreq, 0, sizeof(wreq));
2214 wreq.data.length = sizeof(msg);
2215 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002216 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002217 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002218 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2219 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2220 NL80211_KEYTYPE_GROUP :
2221 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002222 pRoamInfo->u.pMICFailureInfo->keyId,
2223 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002224 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002225
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002227
Jeff Johnson295189b2012-06-20 16:38:30 -07002228 return( eHAL_STATUS_SUCCESS );
2229}
2230
2231/**============================================================================
2232 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002233 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002235
Jeff Johnson295189b2012-06-20 16:38:30 -07002236 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002237static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2238 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002239 eCsrRoamResult roamResult )
2240{
2241 VOS_STATUS vosStatus;
2242
2243 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2244 switch( roamResult )
2245 {
2246 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2247 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002248 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002249 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002250
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002251 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002252 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2253 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2254 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002256
Jeff Johnson295189b2012-06-20 16:38:30 -07002257 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
2258 {
2259 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2260 "New IBSS peer but we already have the max we can handle. Can't register this one" );
2261 break;
2262 }
2263
2264 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2265
Shailender Karmuchia734f332013-04-19 14:02:48 -07002266 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2267 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2268 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2269
2270 // Register the Station with TL for the new peer.
Jeff Johnson295189b2012-06-20 16:38:30 -07002271 vosStatus = hdd_roamRegisterSTA( pAdapter,
2272 pRoamInfo,
2273 pRoamInfo->staId,
2274 (v_MACADDR_t *)pRoamInfo->peerMac,
2275 pRoamInfo->pBssDesc );
2276 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2277 {
2278 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002279 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 vosStatus, vosStatus );
2281 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002282 pHddStaCtx->ibss_sta_generation++;
2283 memset(&staInfo, 0, sizeof(staInfo));
2284 staInfo.filled = 0;
2285 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2286
2287 cfg80211_new_sta(pAdapter->dev,
2288 (const u8 *)pRoamInfo->peerMac,
2289 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002290
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002291 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2292 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2293 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2294 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2295 {
2296 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2297 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2298 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2299
2300 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002301 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002302 pHddStaCtx->ibss_enc_key.encType);
2303
2304 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2305 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2306
2307 if ( VOS_STATUS_SUCCESS != vosStatus )
2308 {
2309 hddLog(VOS_TRACE_LEVEL_ERROR,
2310 "%s: sme_RoamSetKey failed, returned %d",
2311 __func__, vosStatus);
2312 return VOS_STATUS_E_FAILURE;
2313 }
2314 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 netif_carrier_on(pAdapter->dev);
2316 netif_tx_start_all_queues(pAdapter->dev);
2317 break;
2318 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002319
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2321 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002322
Jeff Johnson295189b2012-06-20 16:38:30 -07002323 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002324
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002326 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2328 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002329 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002330
Ravi Joshicc57ed42013-10-12 16:31:25 -07002331 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 {
2333 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2334 "IBSS peer departed by cannot find peer in our registration table with TL" );
2335 }
2336
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002337 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002338 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2339 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2340 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2341 pRoamInfo->staId );
2342
Jeff Johnson295189b2012-06-20 16:38:30 -07002343 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
2344
2345 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002346 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002347
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002348 cfg80211_del_sta(pAdapter->dev,
2349 (const u8 *)&pRoamInfo->peerMac,
2350 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 break;
2352 }
2353 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2354 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002355 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2356 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002357 // Stop only when we are inactive
2358 netif_tx_disable(pAdapter->dev);
2359 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302360 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2361 "%s: Set HDD connState to eConnectionState_NotConnected",
2362 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002363 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002364
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 // Send the bssid address to the wext.
2366 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2367 // clean up data path
2368 hdd_disconnect_tx_rx(pAdapter);
2369 break;
2370 }
2371 default:
2372 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002373
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002375
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 return( eHAL_STATUS_SUCCESS );
2377}
2378
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002379#ifdef FEATURE_WLAN_TDLS
2380/**============================================================================
2381 *
2382 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2383 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2384 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002385
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002386 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002387VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2388 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002389{
2390 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002391 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002392 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2393 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002394 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2395 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002396 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2397 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002398
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002399 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2400 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002401 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002402 "%s not connected. ignored", __func__);
2403 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002404 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002405
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002406 /*
2407 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2408 * be peer MAC, here we are wokrking on direct Link
2409 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002410 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002411
2412 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002413
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002414 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002415 sizeof(tSirMacAddr) );
2416
2417 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2418 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2419
2420 /* set the QoS field appropriately ..*/
2421 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2422 : (staDesc.ucQosEnabled = 0) ;
2423
2424 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002425 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002426
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002427 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002428
2429 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002430 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002431
Shailender Karmuchia734f332013-04-19 14:02:48 -07002432 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002433 * UMA is ready we inform TL to do frame translation.
2434 */
2435 staDesc.ucSwFrameTXXlation = 1;
2436 staDesc.ucSwFrameRXXlation = 1;
2437 staDesc.ucAddRmvLLC = 1;
2438
2439 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002440 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002441
2442 /* tdls Direct Link do not need bcastSig */
2443 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002444
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002445#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2446 if(staDesc.ucProtectedFrame)
2447 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2448 else
2449 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2450#endif
2451
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302452 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002453
Shailender Karmuchia734f332013-04-19 14:02:48 -07002454 /* Register the Station with TL... */
2455 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2456 hdd_rx_packet_cbk,
2457 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002458 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002459
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002460 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2461 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002462 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002463 "%s: WLANTL_RegisterSTAClient() failed to register. "
2464 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002465 return vosStatus;
2466 }
2467
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002468 if ( cfg_param->dynSplitscan &&
2469 ( VOS_TIMER_STATE_RUNNING !=
2470 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2471 {
2472 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2473 cfg_param->trafficMntrTmrForSplitScan);
2474 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002475 return( vosStatus );
2476}
2477
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002478static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
2479{
2480 VOS_STATUS vosStatus;
2481 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2482 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2483 {
2484 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2485 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002486 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002487 __func__, staId, vosStatus, vosStatus );
2488 }
2489 return( vosStatus );
2490}
2491
2492
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002493/*
2494 * HDD interface between SME and TL to ensure TDLS client registration with
2495 * TL in case of new TDLS client is added and deregistration at the time
2496 * TDLS client is deleted.
2497 */
2498
Shailender Karmuchia734f332013-04-19 14:02:48 -07002499eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2500 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002501 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002502 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002503 eCsrRoamResult roamResult)
2504{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002505 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002506 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002507 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002508
2509#ifdef WLAN_FEATURE_TDLS_DEBUG
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002511 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2512 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2513 "ADD_TDLS_PEER" :
2514 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2515 "DEL_TDLS_PEER" :
2516 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2517 "DEL_TDLS_PEER_IND" :
2518 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2519 "DEL_ALL_TDLS_PEER_IND" :
2520 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2521 "UPDATE_TDLS_PEER" :
2522 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2523 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2524 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002525#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002526 switch( roamResult )
2527 {
2528 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2529 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002530 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2531 {
2532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002533 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002534 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002535 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002536 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002537
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002538 /* check if there is available index for this new TDLS STA */
2539 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2540 {
2541 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2542 {
2543 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2544 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2545
2546 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002547 ("TDLS: STA IDX at %d is %d "
2548 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002549 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002550 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002551
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002552 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002553 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2554 status = eHAL_STATUS_SUCCESS ;
2555 break ;
2556 }
2557 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002558 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002559 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002560 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002561 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2562 "wlan_hdd_tdls_set_sta_id() failed");
2563 return VOS_FALSE;
2564 }
2565
2566 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302567 /* store the ucast signature , if required for further reference. */
2568
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002569 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302570 /* start TDLS client registration with TL */
2571 status = hdd_roamRegisterTDLSSTA( pAdapter,
2572 pRoamInfo->peerMac,
2573 pRoamInfo->staId,
2574 pRoamInfo->ucastSig);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002575 }
2576 else
2577 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002578 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002580 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002581 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002582 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002583 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002584 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002585 break ;
2586 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002587 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2588 {
2589 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2590 {
2591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2592 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2593 }
2594 /* store the ucast signature which will be used later when
2595 * registering to TL
2596 */
2597 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2598 complete(&pAdapter->tdls_add_station_comp);
2599 break;
2600 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302601 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
2602 {
2603 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2604 {
2605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2606 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
2607 }
2608 complete(&pAdapter->tdls_link_establish_req_comp);
2609 break;
2610 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002611 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002612 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002613 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002614 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002615 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002616 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2617 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002618 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002620 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2621
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302622 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05302623 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002624 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05302625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2626 " Current status for peer" MAC_ADDRESS_STR "is %d",
2627 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
2628 if (TDLS_IS_CONNECTED(curr_peer))
2629 {
2630 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2631 wlan_hdd_tdls_decrement_peer_count(pAdapter);
2632 }
2633 else if (eTDLS_LINK_CONNECTING == curr_peer->link_status)
2634 {
2635 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2636 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002637 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002638 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002639
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002640 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2641 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2642 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002643 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002644 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002645 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002646 break ;
2647 }
2648 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002649 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002650 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002651 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002652 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2653 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002654 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002655 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2656 "%s: Sending teardown to supplicant with reason code %u",
2657 __func__, pRoamInfo->reasonCode);
2658
2659#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302660 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002661 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002662#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002663 status = eHAL_STATUS_SUCCESS ;
2664 break ;
2665 }
2666 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2667 {
2668 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002669 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002670 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002671 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2672 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002673 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002675 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002676 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002677 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002678 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2679 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2680 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002681
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002682 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002683 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002684 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2685 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002686
2687 status = eHAL_STATUS_SUCCESS ;
2688 }
2689 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05302690 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002691 break ;
2692 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002693 default:
2694 {
2695 break ;
2696 }
2697 }
2698
2699 return status ;
2700}
2701#endif
2702
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002703static void iw_full_power_cbfn (void *pContext, eHalStatus status)
2704{
2705 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
2706 hdd_context_t *pHddCtx = NULL;
2707 int ret;
2708
2709 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
2710 {
2711 hddLog(VOS_TRACE_LEVEL_ERROR,
2712 "%s: Bad param, pAdapter [%p]",
2713 __func__, pAdapter);
2714 return;
2715 }
2716
2717 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2718 ret = wlan_hdd_validate_context(pHddCtx);
2719 if (0 != ret)
2720 {
2721 hddLog(VOS_TRACE_LEVEL_ERROR,
2722 "%s: HDD context is not valid (%d)", __func__, ret);
2723 return;
2724 }
2725
2726 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2727 {
2728 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
2729 }
2730}
2731
Shailender Karmuchia734f332013-04-19 14:02:48 -07002732eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2734{
2735 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2736 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302737 hdd_wext_state_t *pWextState = NULL;
2738 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002739 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07002740 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002741
2742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002743 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002744 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002745
2746 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302747 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002748 {
2749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302750 "invalid adapter or adapter has invalid magic");
2751 return eHAL_STATUS_FAILURE;
2752 }
2753
2754 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2755 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2756
2757 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2758 {
2759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2760 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002761 return eHAL_STATUS_FAILURE;
2762 }
2763
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 switch( roamStatus )
2765 {
2766 case eCSR_ROAM_SESSION_OPENED:
2767 if(pAdapter != NULL)
2768 {
2769 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2770 complete(&pAdapter->session_open_comp_var);
2771 }
2772 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002773
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002774#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
2775 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07002777 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07002778 * interface down */
2779 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05302780 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
2781 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05302782 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2784 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2785 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2787 }
2788 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302789 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 break;
2791
2792 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002793 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07002795 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 // eCSR_ROAM_SHOULD_ROAM will be received.
2797 // Where in we will not mark the link down
2798 // Also we want to stop tx at this point when we will be
2799 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002800 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002801 {
2802 struct net_device *dev = pAdapter->dev;
2803 netif_tx_disable(dev);
Mukul Sharma84f27252014-07-14 18:11:42 +05302804#ifdef DEBUG_ROAM_DELAY
2805 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
2806#endif
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002807 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002808 * Deregister for this STA with TL with the objective to flush
2809 * all the packets for this STA from wmm_tx_queue. If not done here,
2810 * we would run into a race condition (CR390567) wherein TX
2811 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2812 * been deleted. And, these packets get assigned with a STA idx of
2813 * self-sta (since the peer STA has been deleted) and get transmitted
2814 * on the new channel before the reassoc request. Since there will be
2815 * no ACK on the new channel, each packet gets retransmitted which
2816 * takes several seconds before the transmission of reassoc request.
2817 * This leads to reassoc-timeout and roam failure.
2818 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002819 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2820 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2821 {
2822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2823 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2824 pHddStaCtx->conn_info.staId[0], status, status );
2825 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 }
2828 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002829 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 break;
2831#endif
2832
2833 case eCSR_ROAM_SHOULD_ROAM:
2834 // Dont need to do anything
2835 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 struct net_device *dev = pAdapter->dev;
2837 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2838 // notify apps that we can't pass traffic anymore
2839 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002840#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002841 if (pHddStaCtx->ft_carrier_on == FALSE)
2842 {
2843#endif
2844 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002845#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 }
2847#endif
2848
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002849#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002850 //We should clear all sta register with TL, for now, only one.
2851 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2852 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2853 {
2854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2855 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2856 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002857 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002859#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 }
2861 break;
2862 case eCSR_ROAM_LOSTLINK:
2863 case eCSR_ROAM_DISASSOCIATED:
2864 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2866 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05302867 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2869 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07002870 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2871 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302872 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07002873 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08002874
2875 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
2876 pHddCtx->configuredMcastBcastFilter =
2877 pHddCtx->sus_res_mcastbcast_filter;
2878 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
2879 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302880
Amar Singhald53568e2013-09-26 11:03:45 -07002881 hddLog(VOS_TRACE_LEVEL_INFO,
2882 "offload: disassociation happening, restoring configuredMcastBcastFilter");
2883 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
2884 pHddCtx->configuredMcastBcastFilter);
2885 hddLog(VOS_TRACE_LEVEL_INFO,
2886 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2888 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002889#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302890 /* Call to clear any MC Addr List filter applied after
2891 * successful connection.
2892 */
2893 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002894#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002895 }
2896 break;
2897 case eCSR_ROAM_IBSS_LEAVE:
2898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2899 "****eCSR_ROAM_IBSS_LEAVE****");
2900 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2901 break;
2902 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2904 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302905 // To Do - address probable memory leak with WEP encryption upon successful association
2906 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302908 //Clear saved connection information in HDD
2909 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302911 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002912
2913 break;
2914 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002915 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002916 pRoamInfo, roamId, roamStatus, roamResult );
2917 break;
2918 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07002919 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
2920 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 break;
2922
2923 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2924 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002925 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002926
2927 case eCSR_ROAM_MIC_ERROR_IND:
2928 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2929 break;
2930
2931 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002932 {
2933 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2934
2935 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002936 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
2937 (TRUE == pHddCtx->hdd_wlan_suspended) &&
2938 (eCSR_ROAM_RESULT_NONE == roamResult))
2939 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002940 /* Send DTIM period to the FW; only if the wlan is already
2941 in suspend. This is the case with roaming (reassoc),
2942 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
2943 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
2944 before the ENTER_BMPS_REQ ensures Listen Interval is
2945 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002946 hdd_set_pwrparams(pHddCtx);
2947 pHddStaCtx->hdd_ReassocScenario = VOS_FALSE;
2948
2949 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002950 if due to unexpected scenario, if we are in BMPS,
2951 then trigger Exit and Enter BMPS to take DTIM period
2952 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002953 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
2954 {
2955 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
2956
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002957 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2958 iw_full_power_cbfn, pAdapter,
2959 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002960 }
2961 }
2962 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302963 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002964 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002965 break;
2966#ifdef WLAN_FEATURE_VOWIFI_11R
2967 case eCSR_ROAM_FT_RESPONSE:
2968 hdd_SendFTEvent(pAdapter);
2969 break;
2970#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002971#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002972 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002973 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07002974 {
2975 /* Notify the supplicant of a new candidate */
2976 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2977 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002978 break;
2979#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002980
Yue Maef608272013-04-08 23:09:17 -07002981#ifdef FEATURE_WLAN_LFR_METRICS
2982 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
2983 /* This event is to notify pre-auth initiation */
2984 if (VOS_STATUS_SUCCESS !=
2985 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
2986 {
2987 halStatus = eHAL_STATUS_FAILURE;
2988 }
2989 break;
2990 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
2991 /* This event will notify pre-auth completion in case of success */
2992 if (VOS_STATUS_SUCCESS !=
2993 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2994 pRoamInfo, 1))
2995 {
2996 halStatus = eHAL_STATUS_FAILURE;
2997 }
2998 break;
2999 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
3000 /* This event will notify pre-auth completion in case of failure. */
3001 if (VOS_STATUS_SUCCESS !=
3002 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3003 pRoamInfo, 0))
3004 {
3005 halStatus = eHAL_STATUS_FAILURE;
3006 }
3007 break;
3008 case eCSR_ROAM_HANDOVER_SUCCESS:
3009 /* This event is to notify handover success.
3010 It will be only invoked on success */
3011 if (VOS_STATUS_SUCCESS !=
3012 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
3013 {
3014 halStatus = eHAL_STATUS_FAILURE;
3015 }
3016 break;
3017#endif
3018
Jeff Johnson295189b2012-06-20 16:38:30 -07003019 case eCSR_ROAM_INDICATE_MGMT_FRAME:
3020 hdd_indicateMgmtFrame( pAdapter,
3021 pRoamInfo->nFrameLength,
3022 pRoamInfo->pbFrames,
3023 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05303024 pRoamInfo->rxChan,
3025 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07003026 break;
3027 case eCSR_ROAM_REMAIN_CHAN_READY:
3028 hdd_remainChanReadyHandler( pAdapter );
3029 break;
3030 case eCSR_ROAM_SEND_ACTION_CNF:
3031 hdd_sendActionCnf( pAdapter,
3032 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
3033 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003034#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08003035 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003036 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08003037 roamId, roamStatus, roamResult );
3038 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003039 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
3040 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
3041 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003042#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003043#ifdef WLAN_FEATURE_11W
3044 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
3045 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
3046 pRoamInfo->pbFrames,
3047 pRoamInfo->frameType);
3048 break;
3049#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003050#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003051 case eCSR_ROAM_TSM_IE_IND:
3052 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
3053 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
3054 break;
3055
3056 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
3057 {
3058 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
3059 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
3060 {
3061 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
3062 }
3063 break;
3064 }
3065
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003066 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003067 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003068 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003069 break;
3070 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003071
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003072 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003073 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003074 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003075 break;
3076 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003077#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 default:
3079 break;
3080 }
3081 return( halStatus );
3082}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003083eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003084{
3085 eCsrAuthType auth_type;
3086 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003087 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 {
3089 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003090 } else
3091 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 {
3093 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003094 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003095#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003096 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003097 {
3098 // Check for 11r FT Authentication with PSK
3099 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003100 } else
3101 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 {
3103 // Check for 11R FT Authentication with 802.1X
3104 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003105 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003106#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003107#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003108 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003109 {
3110 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3111 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003112#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003113#ifdef WLAN_FEATURE_11W
3114 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3115 {
3116 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3117 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303118 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
3119 {
3120 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3121 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003122#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003123 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3125 }
3126 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003127}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003128
Shailender Karmuchia734f332013-04-19 14:02:48 -07003129eCsrAuthType
3130hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003131{
3132 eCsrAuthType auth_type;
3133 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003134 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 {
3136 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003137 } else
3138 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003139 {
3140 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003141 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003142#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003143 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003144 {
3145 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003146 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003147#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003148 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3150 }
3151 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3152 return auth_type;
3153}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003154
Shailender Karmuchia734f332013-04-19 14:02:48 -07003155eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003156hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003157{
3158 eCsrEncryptionType cipher_type;
3159 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003160 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 {
3162 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003163 }
3164 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 {
3166 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003167 }
3168 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 {
3170 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003171 }
3172 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003173 {
3174 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003175 }
3176 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3177 {
3178 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3179 }
3180 else
3181 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3183 }
3184 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3185 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003186}
Jeff Johnson295189b2012-06-20 16:38:30 -07003187/* To find if the MAC address is NULL */
3188static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3189{
3190 int i;
3191 for (i = 0; i < length; i++)
3192 {
3193 if (0x00 != (macAddr[i]))
3194 {
3195 return FALSE;
3196 }
3197 }
3198 return TRUE;
3199} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003200
Shailender Karmuchia734f332013-04-19 14:02:48 -07003201eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003202hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003203{
3204 eCsrEncryptionType cipher_type;
3205 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003206 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 {
3208 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003209 } else
3210 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 {
3212 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003213 } else
3214 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 {
3216 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003217 } else
3218 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 {
3220 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003221 } else
3222 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003224 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3225 } else
3226 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3228 }
3229 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3230 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003231}
Jeff Johnson295189b2012-06-20 16:38:30 -07003232
Shailender Karmuchia734f332013-04-19 14:02:48 -07003233static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3234 struct ether_addr *pBssid,
3235 eCsrEncryptionType *pEncryptType,
3236 eCsrEncryptionType *mcEncryptType,
3237 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003238#ifdef WLAN_FEATURE_11W
3239 u_int8_t *pMfpRequired,
3240 u_int8_t *pMfpCapable,
3241#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003242 u_int16_t gen_ie_len,
3243 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003244{
3245 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003246 eHalStatus result;
3247 tDot11fIERSN dot11RSNIE;
3248 tDot11fIEWPA dot11WPAIE;
3249 tANI_U32 i;
3250 tANI_U8 *pRsnIe;
3251 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003253 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003254
3255 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3256 flag to 0 */
3257 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3258 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3259
3260 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003261 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
3262 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303263 {
3264 hddLog(LOGE, "%s: Invalid DOT11F IE Length passed :%d",
3265 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 return -EINVAL;
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003268 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003269 if ( gen_ie[0] == DOT11F_EID_RSN)
3270 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003271 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003272 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3274 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303275 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3276 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 return -EINVAL;
3278 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003279 // Skip past the EID byte and length byte
3280 pRsnIe = gen_ie + 2;
3281 RSNIeLen = gen_ie_len - 2;
3282 // Unpack the RSN IE
3283 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3284 pRsnIe,
3285 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003287 // Copy out the encryption and authentication types
3288 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003289 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003290 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003291 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003292 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 but probably I suspect we can do something different*/
3294 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003295 // Just translate the FIRST one
3296 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3297 //dot11RSNIE.pwise_cipher_suite_count
3298 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3299 //dot11RSNIE.gp_cipher_suite_count
3300 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003301#ifdef WLAN_FEATURE_11W
3302 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3303 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3304#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003306 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003308 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303310 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 break;
3312 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003313 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303315 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 break;
3317 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003318 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 // For right now, I assume setASSOCIATE() has passed in the bssid.
3320 vos_mem_copy(PMKIDCache[i].BSSID,
3321 pBssid, ETHER_ADDR_LEN);
3322 vos_mem_copy(PMKIDCache[i].PMKID,
3323 dot11RSNIE.pmkid[i],
3324 CSR_RSN_PMKID_SIZE);
3325 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003326
3327 if (updatePMKCache)
3328 {
3329 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003330 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003331 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003332 // Finally set the PMKSA ID Cache in CSR
3333 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3334 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303335 dot11RSNIE.pmkid_count,
3336 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07003337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 }
3339 else if (gen_ie[0] == DOT11F_EID_WPA)
3340 {
3341 // Validity checks
3342 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3343 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3344 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303345 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3346 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 return -EINVAL;
3348 }
3349 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003350 pRsnIe = gen_ie + 2 + 4;
3351 RSNIeLen = gen_ie_len - (2 + 4);
3352 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003353 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3354 pRsnIe,
3355 RSNIeLen,
3356 &dot11WPAIE);
3357 // Copy out the encryption and authentication types
3358 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003359 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003361 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 //dot11WPAIE.auth_suite_count
3363 // Just translate the FIRST one
3364 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3365 //dot11WPAIE.unicast_cipher_count
3366 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3367 //dot11WPAIE.unicast_cipher_count
3368 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3369 }
3370 else
3371 {
3372 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003373 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 }
3375 return 0;
3376}
3377int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3378{
3379 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3380 v_U32_t status = 0;
3381 eCsrEncryptionType RSNEncryptType;
3382 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003383#ifdef WLAN_FEATURE_11W
3384 u_int8_t RSNMfpRequired;
3385 u_int8_t RSNMfpCapable;
3386#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 struct ether_addr bSsid; // MAC address of assoc peer
3388 // MAC address of assoc peer
3389 // But, this routine is only called when we are NOT associated.
3390 vos_mem_copy(bSsid.ether_addr_octet,
3391 pWextState->roamProfile.BSSIDs.bssid,
3392 sizeof(bSsid.ether_addr_octet));
3393 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3394 {
3395 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003396 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 else
3398 {
3399 return 0;
3400 }
3401 // The actual processing may eventually be more extensive than this.
3402 // Right now, just consume any PMKIDs that are sent in by the app.
3403 status = hdd_ProcessGENIE(pAdapter,
3404 &bSsid, // MAC address of assoc peer
3405 &RSNEncryptType,
3406 &mcRSNEncryptType,
3407 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003408#ifdef WLAN_FEATURE_11W
3409 &RSNMfpRequired,
3410 &RSNMfpCapable,
3411#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003412 pWextState->WPARSNIE[1]+2,
3413 pWextState->WPARSNIE);
3414 if (status == 0)
3415 {
3416 // Now copy over all the security attributes you have parsed out
3417 pWextState->roamProfile.EncryptionType.numEntries = 1;
3418 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003419
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3421 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003422
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003423 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3424 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3425 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3426 {
3427 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3428 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3429 either AES/TKIP based on group cipher configuration
3430 mentioned in the wpa_supplicant.conf.*/
3431
3432 /*Set the unicast cipher same as multicast cipher*/
3433 pWextState->roamProfile.EncryptionType.encryptionType[0]
3434 = mcRSNEncryptType;
3435 }
3436
Chet Lanctot186b5732013-03-18 10:26:30 -07003437#ifdef WLAN_FEATURE_11W
3438 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3439 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3440#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003441 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 }
3443 return 0;
3444}
3445int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3446{
3447 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3448 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3449 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3450 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003451
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003453 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003454
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 switch( pHddStaCtx->conn_info.authType)
3456 {
3457 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003458#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 case eCSR_AUTH_TYPE_CCKM_WPA:
3460 case eCSR_AUTH_TYPE_CCKM_RSN:
3461#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003462 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3463
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003465 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003467
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003468#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003469 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3470 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3471 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003472 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003473 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3474 } else
3475 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003476 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003477 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 } else
3479#endif
3480 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3481 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003482 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3483 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003484 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3485 == IW_AUTH_KEY_MGMT_PSK) {
3486 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003487 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003488 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003489 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 }
3491 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003492#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003493 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3494 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3495 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003496 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003497 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003499 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003500 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003501 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003502 } else
3503#endif
3504
3505#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003506 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3507 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003509 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003510 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003511 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3513 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003514 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 } else
3516#endif
3517
Chet Lanctot186b5732013-03-18 10:26:30 -07003518#ifdef WLAN_FEATURE_11W
3519 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3520 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3521 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303522 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
3523 pRoamProfile->AuthType.authType[0] =
3524 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3525 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003526#endif
3527
Shailender Karmuchia734f332013-04-19 14:02:48 -07003528 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003530 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3531 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3533 == IW_AUTH_KEY_MGMT_PSK) {
3534 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003535 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003536 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003538 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003539 break;
3540
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003542
3543 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 break;
3545 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003546
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003547#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08003548 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003549#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3551 break;
3552 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003553
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003555 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003556
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 EXIT();
3558 return 0;
3559}
3560
3561/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003562
3563 \brief iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003564 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003565 to the CSR roam profile.
3566
Jeff Johnson295189b2012-06-20 16:38:30 -07003567 \param - dev - Pointer to the net device.
3568 - info - Pointer to the iw_request_info.
3569 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003570 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003572
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 --------------------------------------------------------------------------*/
3574
Shailender Karmuchia734f332013-04-19 14:02:48 -07003575int iw_set_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 struct iw_request_info *info,
3577 union iwreq_data *wrqu, char *extra)
3578{
3579 v_U32_t status = 0;
3580 hdd_wext_state_t *pWextState;
3581 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3582 v_U32_t roamId;
3583 tCsrRoamProfile *pRoamProfile;
3584 eMib_dot11DesiredBssType connectedBssType;
3585 eCsrAuthType RSNAuthType;
3586 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3587 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003588
3589 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3590
Jeff Johnson295189b2012-06-20 16:38:30 -07003591 ENTER();
3592
3593 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3594 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 "%s:LOGP in Progress. Ignore!!!",__func__);
3597 return 0;
3598 }
3599
3600 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
3601 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
3602 return -EBUSY;
3603 }
3604 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
3605 return -EINVAL;
3606 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003607 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003608 {
3609 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
3610 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
3611 {
3612 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003613 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3615 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
3616
3617 if(VOS_STATUS_SUCCESS == vosStatus)
3618 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3619 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3620 }
3621 }
3622 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003623 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003624 {
3625 return -EINVAL;
3626 }
3627 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003628 /** when cfg80211 defined, wpa_supplicant wext driver uses
3629 zero-length, null-string ssid for force disconnection.
3630 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 driver MUST return success */
3632 if ( 0 == wrqu->essid.length ) {
3633 return 0;
3634 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003635
3636 status = hdd_wmm_get_uapsd_mask(pAdapter,
3637 &pWextState->roamProfile.uapsd_mask);
3638 if (VOS_STATUS_SUCCESS != status)
3639 {
3640 pWextState->roamProfile.uapsd_mask = 0;
3641 }
3642 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003643
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003645
3646 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003647 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
3648 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
3649 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003650
Jeff Johnson295189b2012-06-20 16:38:30 -07003651 //set gen ie
3652 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
3653
3654 //set auth
3655 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
3656 }
3657#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003658 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 if (pAdapter->wapi_info.nWapiMode)
3660 {
3661 switch (pAdapter->wapi_info.wapiAuthMode)
3662 {
3663 case WAPI_AUTH_MODE_PSK:
3664 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003665 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 pRoamProfile->AuthType.numEntries = 1;
3667 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3668 break;
3669 }
3670 case WAPI_AUTH_MODE_CERT:
3671 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003672 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003673 pRoamProfile->AuthType.numEntries = 1;
3674 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3675 break;
3676 }
3677 } // End of switch
3678 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
3679 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
3680 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003681 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003682 pRoamProfile->EncryptionType.numEntries = 1;
3683 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3684 pRoamProfile->mcEncryptionType.numEntries = 1;
3685 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3686 }
3687 }
3688#endif /* FEATURE_WLAN_WAPI */
3689 /* if previous genIE is not NULL, update AssocIE */
3690 if (0 != pWextState->genIE.length)
3691 {
3692 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
3693 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
3694 pWextState->genIE.length);
3695 pWextState->assocAddIE.length = pWextState->genIE.length;
3696 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
3697 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
3698
3699 /* clear previous genIE after use it */
3700 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
3701 }
3702
3703 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
3704 pWextState->roamProfile.bWPSAssociation = FALSE;
3705
3706 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
3707 pWextState->roamProfile.nAddIEAssocLength))
3708 pWextState->roamProfile.bWPSAssociation = TRUE;
3709
3710
3711 // Disable auto BMPS entry by PMC until DHCP is done
3712 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
3713
Shailender Karmuchia734f332013-04-19 14:02:48 -07003714 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003715 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003716
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003717 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
3718 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003719 hdd_select_cbmode(pAdapter,
3720 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
3721 }
3722 status = sme_RoamConnect( hHal,pAdapter->sessionId,
3723 &(pWextState->roamProfile), &roamId);
3724 pRoamProfile->ChannelInfo.ChannelList = NULL;
3725 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003726
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003727 EXIT();
3728 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003729}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003730
Jeff Johnson295189b2012-06-20 16:38:30 -07003731/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003732
3733 \brief iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003735
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 \param - dev - Pointer to the net device.
3737 - info - Pointer to the iw_request_info.
3738 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003739 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003741
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 --------------------------------------------------------------------------*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003743int iw_get_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 struct iw_request_info *info,
3745 struct iw_point *dwrq, char *extra)
3746{
3747 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003748 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3750 ENTER();
3751
3752 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
3753 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
3754 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
3755 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
3756 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
3757 {
3758 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
3759 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
3760 dwrq->flags = 1;
3761 } else {
3762 memset(extra, 0, dwrq->length);
3763 dwrq->length = 0;
3764 dwrq->flags = 0;
3765 }
3766 EXIT();
3767 return 0;
3768}
3769/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003770
3771 \brief iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003773
Jeff Johnson295189b2012-06-20 16:38:30 -07003774 \param - dev - Pointer to the net device.
3775 - info - Pointer to the iw_request_info.
3776 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003777 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003778 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003779
Jeff Johnson295189b2012-06-20 16:38:30 -07003780 --------------------------------------------------------------------------*/
3781int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
3782 union iwreq_data *wrqu,char *extra)
3783{
3784 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003785 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003786 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3787 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003788 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 eCsrEncryptionType ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003790
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003792
3793 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3794 {
3795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3796 "%s:LOGP in Progress. Ignore!!!", __func__);
3797 return -EBUSY;
3798 }
3799
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 switch(wrqu->param.flags & IW_AUTH_INDEX)
3801 {
3802 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003803
Jeff Johnson295189b2012-06-20 16:38:30 -07003804 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003805
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003807
Jeff Johnson295189b2012-06-20 16:38:30 -07003808 case IW_AUTH_CIPHER_PAIRWISE:
3809 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003810 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003812 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3814 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3817 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003818 }
3819
Jeff Johnson295189b2012-06-20 16:38:30 -07003820 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003821
3822 if( (IW_AUTH_KEY_MGMT_802_1X
3823 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
3825 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003826 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 else
3828 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003829 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003832
3833 if( ( IW_AUTH_KEY_MGMT_802_1X
3834 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3836 /*Dynamic WEP key*/
3837 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3838 else
3839 /*Static WEP key*/
3840 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003841
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 }
3843 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003844
Jeff Johnson295189b2012-06-20 16:38:30 -07003845 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003846 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 return -EINVAL;
3848 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003849
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 pRoamProfile->EncryptionType.numEntries = 1;
3851 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 break;
3854 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003855 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
3857 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3858 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003859
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3861 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
3862 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003863
3864 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
3866 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003867
Jeff Johnson295189b2012-06-20 16:38:30 -07003868 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003869
3870 if( ( IW_AUTH_KEY_MGMT_802_1X
3871 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
3872 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3873
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003875
3876 else
3877 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003878 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003879
3880 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3881 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003883 if( ( IW_AUTH_KEY_MGMT_802_1X
3884 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3886 {
3887 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3888 }
3889 else
3890 {
3891 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3892 }
3893 }
3894 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003895
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003897 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 return -EINVAL;
3899 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003900
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 pRoamProfile->mcEncryptionType.numEntries = 1;
3902 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3903 }
3904 break;
3905
3906 case IW_AUTH_80211_AUTH_ALG:
3907 {
3908 /*Save the auth algo here and set auth type to SME Roam profile
3909 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003910 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003912
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3914 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3915
3916 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3917 /*Not supported*/
3918 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3919 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3920 }
3921 break;
3922
3923 case IW_AUTH_KEY_MGMT:
3924 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003925#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003926#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3927 /*Check for CCKM AKM type */
3928 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003929 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
3930 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003931 /* Set the CCKM bit in authKeyMgmt */
3932 /* Right now, this breaks all ref to authKeyMgmt because our
3933 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 */
3935 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3936 /*Set the key management to 802.1X*/
3937 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003938 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3940 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3941 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3942 /*Save the key management*/
3943 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3944 //pWextState->authKeyMgmt = wrqu->param.value;
3945 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3946 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3947 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3948 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3949 /*Save the key management anyway*/
3950 pWextState->authKeyMgmt = wrqu->param.value;
3951 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3952 /*Save the key management*/
3953 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3954 //pWextState->authKeyMgmt = wrqu->param.value;
3955 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3956 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3957 }
3958#else
3959 /*Save the key management*/
3960 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003961#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 }
3963 break;
3964
3965 case IW_AUTH_TKIP_COUNTERMEASURES:
3966 {
3967 if(wrqu->param.value) {
3968 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3969 "Counter Measure started %d", wrqu->param.value);
3970 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3971 }
3972 else {
3973 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3974 "Counter Measure stopped=%d", wrqu->param.value);
3975 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3976 }
3977 }
3978 break;
3979 case IW_AUTH_DROP_UNENCRYPTED:
3980 case IW_AUTH_WPA_ENABLED:
3981 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3982 case IW_AUTH_ROAMING_CONTROL:
3983 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003984
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003986
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003987 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 wrqu->param.flags & IW_AUTH_INDEX);
3989 break;
3990 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003991
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 EXIT();
3993 return 0;
3994}
3995/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003996
3997 \brief iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003998 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003999
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 \param - dev - Pointer to the net device.
4001 - info - Pointer to the iw_request_info.
4002 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004003 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004005
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 --------------------------------------------------------------------------*/
4007int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4008 union iwreq_data *wrqu,char *extra)
4009{
4010 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004011 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004012 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4013 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004014
4015 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4016 {
4017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4018 "%s:LOGP in Progress. Ignore!!!", __func__);
4019 return -EBUSY;
4020 }
4021
Jeff Johnson295189b2012-06-20 16:38:30 -07004022 switch(pRoamProfile->negotiatedAuthType)
4023 {
4024 case eCSR_AUTH_TYPE_WPA_NONE:
4025 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4026 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
4027 break;
4028 case eCSR_AUTH_TYPE_WPA:
4029 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4030 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
4031 break;
4032#ifdef WLAN_FEATURE_VOWIFI_11R
4033 case eCSR_AUTH_TYPE_FT_RSN:
4034#endif
4035 case eCSR_AUTH_TYPE_RSN:
4036 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4037 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
4038 break;
4039 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4040 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4041 break;
4042 case eCSR_AUTH_TYPE_SHARED_KEY:
4043 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
4044 break;
4045 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004046 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004047 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4048 break;
4049 case eCSR_AUTH_TYPE_AUTOSWITCH:
4050 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4051 break;
4052 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304053 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4055 return -EIO;
4056#ifdef WLAN_FEATURE_VOWIFI_11R
4057 case eCSR_AUTH_TYPE_FT_RSN_PSK:
4058#endif
4059 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07004060#ifdef WLAN_FEATURE_11W
4061 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05304062 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07004063#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05304064 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4066 return -EIO;
4067 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304068 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4070 return -EIO;
4071 }
4072 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
4073 {
4074 switch(pRoamProfile->negotiatedUCEncryptionType)
4075 {
4076 case eCSR_ENCRYPT_TYPE_NONE:
4077 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4078 break;
4079 case eCSR_ENCRYPT_TYPE_WEP40:
4080 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4081 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4082 break;
4083 case eCSR_ENCRYPT_TYPE_TKIP:
4084 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4085 break;
4086 case eCSR_ENCRYPT_TYPE_WEP104:
4087 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4088 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4089 break;
4090 case eCSR_ENCRYPT_TYPE_AES:
4091 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4092 break;
4093 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304094 hddLog(LOG1, "%s called with unknown auth type %d ",
4095 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004096 return -EIO;
4097 }
4098 }
4099
Shailender Karmuchia734f332013-04-19 14:02:48 -07004100 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 {
4102 switch(pRoamProfile->negotiatedMCEncryptionType)
4103 {
4104 case eCSR_ENCRYPT_TYPE_NONE:
4105 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4106 break;
4107 case eCSR_ENCRYPT_TYPE_WEP40:
4108 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4109 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4110 break;
4111 case eCSR_ENCRYPT_TYPE_TKIP:
4112 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4113 break;
4114 case eCSR_ENCRYPT_TYPE_WEP104:
4115 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4116 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4117 break;
4118 case eCSR_ENCRYPT_TYPE_AES:
4119 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4120 break;
4121 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304122 hddLog(LOG1, "%s called with unknown auth type %d ",
4123 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 return -EIO;
4125 }
4126 }
4127
4128 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004129 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 EXIT();
4131 return 0;
4132}
4133/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004134
4135 \brief iw_set_ap_address() -
4136 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004138
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 \param - dev - Pointer to the net device.
4140 - info - Pointer to the iw_request_info.
4141 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004142 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004143 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004144
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 --------------------------------------------------------------------------*/
4146int iw_set_ap_address(struct net_device *dev,
4147 struct iw_request_info *info,
4148 union iwreq_data *wrqu, char *extra)
4149{
4150 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
4151 v_U8_t *pMacAddress=NULL;
4152 ENTER();
4153 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4155 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
4157 EXIT();
Shailender Karmuchia734f332013-04-19 14:02:48 -07004158
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 return 0;
4160}
4161/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004162
4163 \brief iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004164 This function returns the BSSID to the wpa_supplicant
4165 \param - dev - Pointer to the net device.
4166 - info - Pointer to the iw_request_info.
4167 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004168 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004170
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 --------------------------------------------------------------------------*/
4172int iw_get_ap_address(struct net_device *dev,
4173 struct iw_request_info *info,
4174 union iwreq_data *wrqu, char *extra)
4175{
4176 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4177 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
4178
4179 ENTER();
4180
4181 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4182 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4183 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004184 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 }
4186 else
4187 {
4188 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4189 }
4190 EXIT();
4191 return 0;
4192}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004193
Chet Lanctot186b5732013-03-18 10:26:30 -07004194#ifdef WLAN_FEATURE_11W
4195/**---------------------------------------------------------------------------
4196
4197 \brief hdd_indicateUnprotMgmtFrame -
4198 This function forwards the unprotected management frame to the supplicant
4199 \param - pAdapter - Pointer to HDD adapter
4200 - nFrameLength - Length of the unprotected frame being passed
4201 - pbFrames - Pointer to the frame buffer
4202 - frameType - 802.11 frame type
4203 \return - nothing
4204
4205 --------------------------------------------------------------------------*/
4206void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4207 tANI_U32 nFrameLength,
4208 tANI_U8* pbFrames,
4209 tANI_U8 frameType )
4210{
4211 tANI_U8 type = 0;
4212 tANI_U8 subType = 0;
4213
4214 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4215 __func__, frameType, nFrameLength);
4216
4217 /* Sanity Checks */
4218 if (NULL == pAdapter)
4219 {
4220 hddLog( LOGE, FL("pAdapter is NULL"));
4221 return;
4222 }
4223
4224 if (NULL == pAdapter->dev)
4225 {
4226 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4227 return;
4228 }
4229
4230 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4231 {
4232 hddLog( LOGE, FL("pAdapter has invalid magic"));
4233 return;
4234 }
4235
4236 if( !nFrameLength )
4237 {
4238 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4239 return;
4240 }
4241
4242 if (NULL == pbFrames) {
4243 hddLog( LOGE, FL("pbFrames is NULL"));
4244 return;
4245 }
4246
4247 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4248 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4249
4250 /* Get pAdapter from Destination mac address of the frame */
4251 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
4252 {
4253 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
4254 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4255 }
4256 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
4257 {
4258 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
4259 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4260 }
4261 else
4262 {
4263 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
4264 return;
4265 }
4266}
4267#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004268
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004269#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004270void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
4271 tANI_U8 state,
4272 tANI_U16 measInterval )
4273{
4274 union iwreq_data wrqu;
4275 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004276 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004277
4278 if (NULL == pAdapter)
4279 return;
4280
4281 // create the event
4282 memset(&wrqu, '\0', sizeof(wrqu));
4283 memset(buf, '\0', sizeof(buf));
4284
4285 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
4286 tid, state, measInterval);
4287
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004288 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004289
4290 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004291 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004292 // send the event
4293 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4294}
4295
4296void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4297{
4298 union iwreq_data wrqu;
4299 char buf[IW_CUSTOM_MAX + 1];
4300 char *pos = buf;
4301 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4302
4303 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4304 return;
4305
4306 // create the event
4307 memset(&wrqu, '\0', sizeof(wrqu));
4308 memset(buf, '\0', sizeof(buf));
4309
4310 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304311 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
4312 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
4313 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
4314 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004315
4316 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4317 pos += nBytes;
4318 freeBytes -= nBytes;
4319
4320 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
4321 pos += WNI_CFG_BSSID_LEN;
4322 freeBytes -= WNI_CFG_BSSID_LEN;
4323
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004324 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4325 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004326
4327 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004328 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004329
4330 // send the event
4331 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4332}
4333
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004334void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004335{
4336 union iwreq_data wrqu;
4337 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004338 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004339
4340 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4341 return;
4342
4343 // create the event
4344 memset(&wrqu, '\0', sizeof(wrqu));
4345 memset(buf, '\0', sizeof(buf));
4346
4347 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
4348
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004349 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004350
4351 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004352 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004353
4354 // send the event
4355 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4356}
4357
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004358void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
4359 const tANI_U16 measurementToken,
4360 const tANI_BOOLEAN flag,
4361 const tANI_U8 numBss)
4362{
4363 union iwreq_data wrqu;
4364 char buf[IW_CUSTOM_MAX];
4365 char *pos = buf;
4366 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4367
4368 memset(&wrqu, '\0', sizeof(wrqu));
4369 memset(buf, '\0', sizeof(buf));
4370
4371 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
4372 numBss);
4373
4374 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4375 flag, numBss);
4376
4377 wrqu.data.pointer = buf;
4378 wrqu.data.length = nBytes;
4379 // send the event
4380 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4381}
4382
4383
4384static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004385 const tCsrRoamInfo *pRoamInfo)
4386{
4387 union iwreq_data wrqu;
4388 char buf[IW_CUSTOM_MAX + 1];
4389 char *pos = buf;
4390 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4391 tANI_U8 i = 0, len = 0;
4392 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
4393 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004394 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
4395 tANI_U8 ieLenByte = 1;
4396 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
4397#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004398
4399 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4400 return;
4401
4402 /* Custom event can pass maximum of 256 bytes of data,
4403 based on the IE len we need to identify how many BSS info can
4404 be filled in to custom event data */
4405 /*
4406 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4407 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4408 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4409 */
4410
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004411 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004412 {
4413 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
4414 /* If the measurement is none and no scan results found,
4415 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004416 hdd_indicateEseBcnReportNoResults(pAdapter,
4417 pRoamInfo->pEseBcnReportRsp->measurementToken,
4418 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004419 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004420 }
4421 else
4422 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004423 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004424 {
4425 memset(&wrqu, '\0', sizeof(wrqu));
4426 memset(buf, '\0', sizeof(buf));
4427 tot_bcn_ieLen = 0;
4428 sendBss = 0;
4429 pos = buf;
4430 freeBytes = IW_CUSTOM_MAX;
4431
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004432 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004433 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004434 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
4435 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004436 {
4437 break;
4438 }
4439 tot_bcn_ieLen += len;
4440 sendBss++;
4441 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
4442 "IeLength(%d) Length of Ie(%d) totLen(%d)",
4443 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004444 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004445 tot_bcn_ieLen);
4446 }
4447
4448 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
4449 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004450 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4451 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004452
4453 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004454 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4455 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004456 pos += nBytes;
4457 freeBytes -= nBytes;
4458
4459 /* Copy total Beacon report data length */
4460 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
4461 pos += sizeof(tot_bcn_ieLen);
4462 freeBytes -= sizeof(tot_bcn_ieLen);
4463
4464 for (i = 0; i < sendBss; i++)
4465 {
4466 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304467 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4468 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004469 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004470 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
4471 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
4472 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
4473 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
4474 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
4475 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
4476 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
4477 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
4478 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
4479 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
4480 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
4481 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
4482 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
4483 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
4484 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
4485 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004486
4487 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004488 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
4489 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004490 pos += len;
4491 freeBytes -= len;
4492
4493 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004494 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004495 vos_mem_copy(pos, (char*)&len, sizeof(len));
4496 pos += sizeof(len);
4497 freeBytes -= sizeof(len);
4498
4499 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004500 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004501 pos += len;
4502 freeBytes -= len;
4503 }
4504
4505 wrqu.data.pointer = buf;
4506 wrqu.data.length = strlen(buf);
4507
4508 // send the event
4509 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4510 lastSent += sendBss;
4511 }
4512 }
4513}
4514
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004515#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004516