blob: bed4281d36e7caa052918fd1588a8448f70f3590 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028/**========================================================================
29
30 \file wlan_hdd_assoc.c
31 \brief WLAN Host Device Driver implementation
Shailender Karmuchia734f332013-04-19 14:02:48 -070032
Jeff Johnson295189b2012-06-20 16:38:30 -070033 ========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070034/**=========================================================================
35 EDIT HISTORY FOR FILE
36
37
38 This section contains comments describing changes made to the module.
39 Notice that changes are listed in reverse chronological order.
40
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070046 -------- --- --------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -070047 05/06/09 Shailender Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070048 ==========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070049
Jeff Johnson295189b2012-06-20 16:38:30 -070050#include "wlan_hdd_includes.h"
51#include <aniGlobal.h>
52#include "dot11f.h"
53#include "wlan_nlink_common.h"
54#include "wlan_btc_svc.h"
55#include "wlan_hdd_power.h"
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"
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053062#include <vos_sched.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080063#ifdef FEATURE_WLAN_TDLS
64#include "wlan_hdd_tdls.h"
65#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070066#include "sme_Api.h"
Sushant Kaushikba6764e2014-06-30 19:52:09 +053067#include "wlan_hdd_hostapd.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053068#include "vos_utils.h"
Siddharth Bhalda0d1622015-04-24 15:47:49 +053069#include <wlan_hdd_wext.h>
Mukul Sharma84f27252014-07-14 18:11:42 +053070
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
Kanchanapally, Vidyullatha31b8d142015-01-30 14:25:18 +0530434 sme_GetRICIEs(pHddCtx->hHal, (u8 *)ricIe,
435 DOT11F_IE_RICDESCRIPTOR_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__);
Bhargav Shah8b5b2f72015-07-14 11:53:46 +0530508 kfree(buff);
Jeff Johnson295189b2012-06-20 16:38:30 -0700509 return;
510 }
511
512 wrqu.data.length = str_len + auth_resp_len;
513 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
514
515 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700516#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700517}
518
519#endif /* WLAN_FEATURE_VOWIFI_11R */
520
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800521#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700522
523/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800524 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 * (This keeps the supplicant "up to date" on the current channel.)
526 *
527 * The current (new AP) channel information is passed in.
528 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700529static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700530 tCsrRoamInfo *pCsrRoamInfo)
531{
532 union iwreq_data wrqu;
533 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700534
Shailender Karmuchia734f332013-04-19 14:02:48 -0700535
536 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 {
538 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800539 "%s: pCsrRoamInfo->pBssDesc=%p",
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 __func__, descriptor);
541 return;
542 }
543
544 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -0800545 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700546 memset(&wrqu, '\0', sizeof(wrqu));
547 wrqu.freq.m = descriptor->channelId;
548 wrqu.freq.e = 0;
549 wrqu.freq.i = 0;
550 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
551}
552
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800553#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700554
555void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
556{
557 union iwreq_data wrqu;
558 u8 *pBeaconIes;
559 u8 currentLen = 0;
560 char *buff;
561 int totalIeLen = 0, currentOffset = 0, strLen;
562
563 memset(&wrqu, '\0', sizeof(wrqu));
564
565 if (0 == pCsrRoamInfo->nBeaconLength)
566 {
567 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
568 return;
569 }
570 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700571 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700573 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 return;
575 }
576
577 // pBeaconIes needs to point to the IEs
578 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
579 (unsigned int)pBeaconIes[0],
580 (unsigned int)pBeaconIes[1]);
581 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700582
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 // We need to send the IEs to the supplicant.
584 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700585 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700587 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 return;
589 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700590 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700591
592 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
593 currentLen = strLen + 1;
594
595 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
596 do
597 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700598 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 * max size and send it to supplicant. Changes are done in supplicant to handle this */
600 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
601 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
602 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
603 currentOffset += currentLen;
604 totalIeLen -= currentLen;
605 wrqu.data.length = strLen + 1 + currentLen;
606 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700607 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 else
609 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
610
611 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
612 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
613 } while (totalIeLen > 0);
614
615 kfree(buff);
616}
617
618static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
619{
620 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
621 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
622 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
623 union iwreq_data wrqu;
624 int we_event;
625 char *msg;
626 int type = -1;
627
Shailender Karmuchia734f332013-04-19 14:02:48 -0700628#if defined (WLAN_FEATURE_VOWIFI_11R)
629 // Added to find the auth type on the fly at run time
630 // rather than with cfg to see if FT is enabled
631 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
633#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700634
Jeff Johnson295189b2012-06-20 16:38:30 -0700635 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700636 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700638
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
640 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530641 /* In case of roaming ; We are not doing disconnect.
642 * If disconnect is not being done for roam; We will not
643 * decrease count for Active sessions. We should not increase active
644 * active session in case of roaming.
645 */
Padma, Santhosh Kumar87ba40f2014-11-26 19:40:15 +0530646 if((pHddStaCtx->ft_carrier_on == FALSE) && !pCsrRoamInfo->fReassocReq)
Agarwal Ashish51325b52014-06-16 16:50:49 +0530647 {
648 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
649 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700650 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
651 type = WLAN_STA_ASSOC_DONE_IND;
652
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700653#ifdef WLAN_FEATURE_P2P_DEBUG
654 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
655 {
656 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
657 {
658 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
659 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
660 "Connecting state to Connected State for 8-way "
661 "Handshake");
662 }
663 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
664 {
665 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
666 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
667 "Connecting state to P2P Client Connection Completed");
668 }
669 }
670#endif
Arif Hussain77d044f2014-01-03 19:56:04 -0800671 pr_info("wlan: " MAC_ADDRESS_STR " connected to " MAC_ADDRESS_STR "\n",
672 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
Kiet Lam34947452014-01-21 23:23:40 -0800673 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
675
676 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
677 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
678 * and fFTEnable is TRUE */
679#ifdef WLAN_FEATURE_VOWIFI_11R
680 // Send FT Keys to the supplicant when FT is enabled
681 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700682 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800683#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700684 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
685 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
686#endif
687 )
688 {
689 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
690 }
691#endif
692 }
693 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
694 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530695 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -0700696 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 type = WLAN_STA_ASSOC_DONE_IND;
Arif Hussain24bafea2013-11-15 15:10:03 -0800698 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR"\n",
699 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 }
701 else /* Not Associated */
702 {
703 pr_info("wlan: disconnected\n");
704 type = WLAN_STA_DISASSOC_DONE_IND;
705 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
706 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700707 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700708
709 msg = NULL;
710 /*During the WLAN uninitialization,supplicant is stopped before the
711 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530712 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 {
714 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800715#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700717 {
718 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
719 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
721 }
722#endif
723 }
724 send_btc_nlink_msg(type, 0);
725}
726
727void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
728{
729 // Remove staId, bssId and peerMacAddress
730 pHddStaCtx->conn_info.staId [ 0 ] = 0;
731 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
732 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
733
734 // Clear all security settings
735 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
736 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
737 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
738
739 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700740 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700741
742 // Set not-connected state
743 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700744
745 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
746}
Katya Nigam47528772015-02-11 12:24:49 +0530747
748VOS_STATUS hdd_ibss_deinit_tx_rx_sta ( hdd_adapter_t *pAdapter, v_U8_t STAId )
749{
Katya Nigam1fd24402015-02-16 14:52:19 +0530750 v_U8_t ac;
751 /**Track whether OS TX queue has been disabled.*/
752 v_BOOL_t txSuspended[NUM_TX_QUEUES];
753 v_U8_t tlAC;
Katya Nigam47528772015-02-11 12:24:49 +0530754 v_U8_t i;
755 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
756 hdd_ibss_peer_info_t *pPeerInfo;
757
758 if( NULL == pHddStaCtx )
759 {
760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
761 "%s: HDD station context NULL ",__func__);
762 return VOS_STATUS_E_FAILURE;
763 }
Katya Nigam1fd24402015-02-16 14:52:19 +0530764
Katya Nigam47528772015-02-11 12:24:49 +0530765 pPeerInfo = &pHddStaCtx->ibss_peer_info;
766 if (FALSE == pPeerInfo->ibssStaInfo[STAId].isUsed)
767 {
768 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
769 "%s: Deinit station not inited %d", __func__, STAId );
770 return VOS_STATUS_E_FAILURE;
771 }
772
773 hdd_flush_ibss_tx_queues(pAdapter, STAId);
Katya Nigam1fd24402015-02-16 14:52:19 +0530774
775 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
776 {
777 tlAC = hdd_QdiscAcToTlAC[ac];
778 txSuspended[ac] = pPeerInfo->ibssStaInfo[STAId].txSuspended[tlAC];
779 }
780
Katya Nigam47528772015-02-11 12:24:49 +0530781 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
782
Katya Nigam1fd24402015-02-16 14:52:19 +0530783 /* re-init hdd list, since netdev can still open adapter until
784 * driver gets unloaded
785 */
786 for (i = 0; i < NUM_TX_QUEUES; i ++)
787 {
788 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i],
789 HDD_TX_QUEUE_MAX_LEN);
790 }
791
792 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
793 {
794 if (txSuspended[ac])
795 {
796 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
797 "%s: TX queue re-enabled", __func__);
798 netif_wake_subqueue(pAdapter->dev, ac);
799 }
800 }
Katya Nigam47528772015-02-11 12:24:49 +0530801 return VOS_STATUS_SUCCESS;
802}
803
804static VOS_STATUS hdd_ibss_DeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
805{
806 VOS_STATUS vosStatus;
807
808 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
809 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
810 {
811 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
812 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
813 "Status= %d [0x%08X]",
814 __func__, staId, vosStatus, vosStatus );
815 }
816
817 vosStatus = hdd_ibss_deinit_tx_rx_sta ( pAdapter, staId );
818 if( VOS_STATUS_E_FAILURE == vosStatus )
819 {
820 VOS_TRACE ( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
821 "hdd_ibss_deinit_tx_rx_sta() failed for staID %d. "
822 "Status = %d [0x%08X]",
823 staId, vosStatus, vosStatus );
824 }
825
826 return( vosStatus );
827}
828
829VOS_STATUS hdd_ibss_init_tx_rx_sta( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA)
830{
831 v_U8_t i = 0;
832 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
833 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
834
835 if (pPeerInfo->ibssStaInfo[STAId].isUsed)
836 {
837 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
838 "%s: Reinit station %d", __func__, STAId );
839 return VOS_STATUS_E_FAILURE;
840 }
841
842 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
843 for (i = 0; i < NUM_TX_QUEUES; i ++)
844 {
845 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i], HDD_TX_QUEUE_MAX_LEN);
846 }
847
848 pPeerInfo->ibssStaInfo[STAId].isUsed = VOS_TRUE;
849 pPeerInfo->ibssStaInfo[STAId].isDeauthInProgress = VOS_FALSE;
850 vos_copy_macaddr( &pPeerInfo->ibssStaInfo[STAId].macAddrSTA, pmacAddrSTA);
851
852 return VOS_STATUS_SUCCESS;
853}
854
855static VOS_STATUS hdd_ibss_RegisterSTA( hdd_adapter_t *pAdapter,
856 tCsrRoamInfo *pRoamInfo,
857 v_U8_t staId,
858 v_MACADDR_t *pPeerMacAddress,
859 tSirBssDescription *pBssDesc )
860{
861 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
862 WLAN_STADescType staDesc = {0};
863 eCsrEncryptionType connectedCipherAlgo;
864 v_BOOL_t fConnected;
865 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
866 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
867 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
868
869 if ( pPeerInfo->ibssStaInfo[staId].isUsed )
870 {
871 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
872 "clean up old entry for STA %d", staId);
873 hdd_ibss_DeregisterSTA( pAdapter, staId );
874 }
875
876 staDesc.ucSTAId = staId;
877 staDesc.wSTAType = WLAN_STA_IBSS;
878
879 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
880 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
881 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
882 // pass when making an Infrastructure connection.
883 vos_mem_copy(staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes));
884 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId, 6 );
885 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
886
887 if (hdd_wmm_is_active(pAdapter))
888 {
889 staDesc.ucQosEnabled = 1;
890 }
891 else
892 {
893 staDesc.ucQosEnabled = 0;
894 }
895 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
896 "HDD SOFTAP register TL QoS_enabled=%d",
897 staDesc.ucQosEnabled );
898
899 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
900 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
901 {
902 staDesc.ucProtectedFrame = 1;
903 }
904 else
905 {
906 staDesc.ucProtectedFrame = 0;
907
908 }
909
910 hdd_ibss_init_tx_rx_sta(pAdapter, staId, &staDesc.vSTAMACAddress);
911
912 // UMA is Not ready yet, Xlation will be done by TL
913 staDesc.ucSwFrameTXXlation = 1;
914 staDesc.ucSwFrameRXXlation = 1;
915 staDesc.ucAddRmvLLC = 1;
916 // Initialize signatures and state
917 staDesc.ucUcastSig = pRoamInfo->ucastSig;
918 staDesc.ucBcastSig = pRoamInfo->bcastSig;
919 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED;
920
921 staDesc.ucIsReplayCheckValid = VOS_FALSE;
922
923 // Register the Station with TL.
924 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
925 hdd_rx_packet_cbk,
926 hdd_tx_complete_cbk,
927 hdd_ibss_tx_fetch_packet_cbk, &staDesc,
928 pBssDesc->rssi );
929 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
930 {
931 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
932 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
933 vosStatus, vosStatus );
934 return vosStatus;
935 }
936
937 //Timer value should be in milliseconds
938 if ( pHddCtx->cfg_ini->dynSplitscan &&
939 ( VOS_TIMER_STATE_RUNNING !=
940 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
941 {
942 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
943 pHddCtx->cfg_ini->trafficMntrTmrForSplitScan);
944 }
945
946 pPeerInfo->ibssStaInfo[staId].ucSTAId = staId;
947 pPeerInfo->ibssStaInfo[staId].isQosEnabled = staDesc.ucQosEnabled;
948
949 vosStatus = WLANTL_ChangeSTAState( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId,
950 WLANTL_STA_AUTHENTICATED );
951
952 pPeerInfo->ibssStaInfo[staId].tlSTAState = WLANTL_STA_AUTHENTICATED;
953 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
954
955 return( vosStatus );
956}
957
Jeff Johnson295189b2012-06-20 16:38:30 -0700958/* TODO Revist this function. and data path */
959static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
960{
961 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700962
Katya Nigam47528772015-02-11 12:24:49 +0530963 hdd_disconnect_tx_rx(pAdapter);
Ravi Joshif9520d62013-10-18 04:11:46 -0700964
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
966 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
967 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530968 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700970 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700971 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 }
973 return( vosStatus );
974}
975
976
977static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
978 tANI_U32 roamId, eRoamCmdStatus roamStatus,
979 eCsrRoamResult roamResult )
980{
981 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700982 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700983 struct net_device *dev = pAdapter->dev;
984 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
985 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700986 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530987 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700988
989 // Sanity check
990 if(dev == NULL)
991 {
Agarwal Ashish971c2882013-10-30 20:11:12 +0530992 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700993 "%s: net_dev is released return", __func__);
994 return eHAL_STATUS_FAILURE;
995 }
996
Jeff Johnson295189b2012-06-20 16:38:30 -0700997 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530998 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 netif_tx_disable(dev);
1000 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +05301001 //TxTimeoutCount need to reset in case of disconnect handler
1002 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001003
Jeff Johnsone7245742012-09-05 17:12:55 -07001004 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301005 /* HDD has initiated disconnect, do not send disconnect indication
1006 * to kernel as it will be handled by __cfg80211_disconnect.
1007 */
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301008 /* If only STA mode is on */
1009 if((pHddCtx->concurrency_mode <= 1) &&
1010 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
1011 {
1012 pHddCtx->isAmpAllowed = VOS_TRUE;
1013 }
1014
Agarwal Ashish47d18112014-08-04 19:55:07 +05301015 /* Need to apply spin lock before decreasing active sessions
1016 * as there can be chance for double decrement if context switch
1017 * Calls wlan_hdd_disconnect.
1018 */
1019
1020 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301021 if ( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState )
1022 {
1023 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1024 FL(" HDD has initiated a disconnect, no need to send"
1025 " disconnect indication to kernel"));
1026 sendDisconInd = FALSE;
1027 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301028 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -07001029 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301030 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +05301031 FL(" Set HDD connState to eConnectionState_Disconnecting from %d "),
1032 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301033 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
1034 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001035 }
Agarwal Ashish47d18112014-08-04 19:55:07 +05301036 spin_unlock_bh(&pAdapter->lock_for_active_session);
1037
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -07001039
1040 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07001041
1042 // indicate 'disconnect' status to wpa_supplicant...
1043 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 /* indicate disconnected event to nl80211 */
1045 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
1046 {
1047 /*During the WLAN uninitialization,supplicant is stopped before the
1048 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301049 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001050 {
Sushant Kaushik0b343422015-05-25 17:15:55 +05301051 if (sendDisconInd)
1052 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1053 "%s: sent disconnected event to nl80211",
1054 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001055#ifdef WLAN_FEATURE_P2P_DEBUG
1056 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1057 {
1058 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
1059 {
1060 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
1061 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
1062 "and moved to disconnected state");
1063 }
1064 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
1065 {
1066 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
1067 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
1068 "and moved to inactive state");
1069 }
1070 }
1071#endif
Sushant Kaushikbad61892015-07-10 16:43:28 +05301072 if ((roamStatus == eCSR_ROAM_LOSTLINK) &&
1073 !pRoamInfo->reasonCode)
1074 wlan_hdd_get_frame_logs(pAdapter,
1075 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301076 /*Only send indication to kernel if not initiated by kernel*/
1077 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301079 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
1080 if ( eCSR_ROAM_LOSTLINK == roamStatus )
1081 {
1082 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
1083 }
1084 else
1085 {
1086 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
1087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301089 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
1090 (TRUE == sme_IsFeatureSupportedByFW(TDLS))) {
1091 if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION)
1092 /* Enable TDLS support Once P2P session ends since
1093 * upond detection of concurrency TDLS would be disabled
1094 */
1095 wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_ENABLED,
1096 FALSE);
1097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001098 //If the Device Mode is Station
1099 // and the P2P Client is Connected
1100 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001101
1102 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001103 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001104 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 {
1106 //Enable BMPS only of other Session is P2P Client
1107 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001108 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001109
1110 if (NULL != pVosContext)
1111 {
1112 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1113
1114 if(NULL != pHddCtx)
1115 {
1116 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301117 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1118 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301120 if (pHddCtx->hdd_wlan_suspended)
1121 {
1122 hdd_set_pwrparams(pHddCtx);
1123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 }
1127 }
1128 }
1129 }
1130 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001131
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301132 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +05301133#if defined(WLAN_FEATURE_VOWIFI_11R)
1134 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1135#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301136
1137 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1138 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301139 v_U8_t i;
1140
Katya Nigam63ce1772014-09-26 15:53:49 +05301141 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301142 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301143 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1144 {
1145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301146 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1147 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301148 sta_id, status, status );
1149
1150 status = eHAL_STATUS_FAILURE;
1151 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301152 pHddCtx->sta_to_adapter[sta_id] = NULL;
1153
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301154 /*Clear all the peer sta register with TL.*/
1155 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1156 {
1157 if (0 != pHddStaCtx->conn_info.staId[i])
1158 {
1159 sta_id = pHddStaCtx->conn_info.staId[i];
1160
1161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1162 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301163 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301164 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1165 {
1166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1167 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1168 "Status= %d [0x%x]"),
1169 sta_id, status, status );
1170 status = eHAL_STATUS_FAILURE;
1171 }
1172
Nirav Shah7e3c8132015-06-22 23:51:42 +05301173 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1174 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1175 if (vstatus != VOS_STATUS_SUCCESS) {
1176 hddLog(VOS_TRACE_LEVEL_ERROR,
1177 FL("Not able to remove staid hash %d"),
1178 sta_id);
1179 status = eHAL_STATUS_FAILURE;
1180 } else {
1181 hddLog(VOS_TRACE_LEVEL_INFO,
1182 FL("ibss station removed sta_id %d mac:"
1183 MAC_ADDRESS_STR), sta_id,
1184 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1185 }
1186
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301187 /*set the staid and peer mac as 0, all other reset are
1188 * done in hdd_connRemoveConnectInfo.
1189 */
1190 pHddStaCtx->conn_info.staId[i]= 0;
1191 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1192
1193 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1194 pHddCtx->sta_to_adapter[sta_id] = NULL;
1195 }
1196 }
1197
Katya Nigam63ce1772014-09-26 15:53:49 +05301198 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301199 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301201 sta_id = pHddStaCtx->conn_info.staId[0];
1202
1203 //We should clear all sta register with TL, for now, only one.
1204 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1205 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1206 {
1207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1208 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1209 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001210 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001211
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301212 status = eHAL_STATUS_FAILURE;
1213 }
1214
1215 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001216 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301217
1218#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1219 if (VOS_STATUS_SUCCESS !=
1220 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1221 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1222 {
1223 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1224 "WLANTL_ClearInterfaceStats Failed", __func__);
1225 }
1226 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1227 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1228 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1229 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1230#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1231
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 // Clear saved connection information in HDD
1233 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +05301234 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1235 "%s: Set HDD connState to eConnectionState_NotConnected",
1236 __func__);
1237 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301238#ifdef WLAN_FEATURE_GTK_OFFLOAD
1239 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1240 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1241 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301242 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1243 sizeof (tSirGtkOffloadParams));
1244 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301245 }
1246#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001247
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001248#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001249 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1250 {
1251 wlan_hdd_tdls_disconnection_callback(pAdapter);
1252 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001253#endif
1254
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 //Unblock anyone waiting for disconnect to complete
1256 complete(&pAdapter->disconnect_comp_var);
1257 return( status );
1258}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301259
1260static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
1261 v_U8_t staId)
1262{
1263 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1264 v_SINT_t i;
1265 v_SIZE_t size;
1266 VOS_STATUS status;
1267 v_BOOL_t granted = VOS_FALSE;
1268
1269 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1270 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
1271 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
1272 {
1273 //Indicate to TL that there is pending data if a queue is non empty
1274 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
1275 {
1276 size = 0;
1277 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
1278 if (size > 0)
1279 {
1280 if (i != WLANTL_AC_HIGH_PRIO)
1281 {
1282 if (VOS_FALSE ==
1283 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
1284 {
1285 hdd_wmm_acquire_access(pAdapter,
1286 (WLANTL_ACEnumType)i, &granted);
1287 pAdapter->psbChanged |= (1 << i);
1288 }
1289 else
1290 granted = VOS_TRUE;
1291 }
1292
1293 if (granted || (i == WLANTL_AC_HIGH_PRIO))
1294 {
1295 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
1296 staId, (WLANTL_ACEnumType)i);
1297 if (!VOS_IS_STATUS_SUCCESS(status))
1298 {
1299 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1300 "%s: Failure in indicating pkt to TL for QID=%d",
1301 __func__, i);
1302 }
1303 }
1304 }
1305 }
1306 }
1307}
1308
Jeff Johnson295189b2012-06-20 16:38:30 -07001309static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
1310 tCsrRoamInfo *pRoamInfo,
1311 v_U8_t staId,
1312 v_MACADDR_t *pPeerMacAddress,
1313 tSirBssDescription *pBssDesc )
1314{
1315 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1316 WLAN_STADescType staDesc = {0};
1317 eCsrEncryptionType connectedCipherAlgo;
1318 v_BOOL_t fConnected;
1319 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1320 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001321 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001322
1323 if ( NULL == pBssDesc)
1324 {
1325 return VOS_STATUS_E_FAILURE;
1326 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001327 // Get the Station ID from the one saved during the assocation.
1328 staDesc.ucSTAId = staId;
1329
Katya Nigam47528772015-02-11 12:24:49 +05301330 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001331
Katya Nigam47528772015-02-11 12:24:49 +05301332 // grab the bssid from the connection info in the adapter structure and hand that
1333 // over to TL when registering.
1334 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
1335 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001336
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1338
1339 // set the QoS field appropriately
1340 if (hdd_wmm_is_active(pAdapter))
1341 {
1342 staDesc.ucQosEnabled = 1;
1343 }
1344 else
1345 {
1346 staDesc.ucQosEnabled = 0;
1347 }
1348
1349 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1350 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1351 {
1352 staDesc.ucProtectedFrame = 1;
1353 }
1354 else
1355 {
1356 staDesc.ucProtectedFrame = 0;
1357
1358 }
1359
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001360#ifdef FEATURE_WLAN_ESE
1361 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1362#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001363
1364#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1365 /* check whether replay check is valid for the station or not */
1366 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1367 {
1368 /* Encryption mode is either TKIP or AES
1369 and replay check is valid for only these
1370 two encryption modes */
1371 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1372 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1373 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1374 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001375
Jeff Johnson295189b2012-06-20 16:38:30 -07001376 else
1377 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001378 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001380 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001381 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1382 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1383 }
1384#endif
1385
1386#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001387 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 if (pAdapter->wapi_info.fIsWapiSta)
1389 {
1390 staDesc.ucIsWapiSta = 1;
1391 }
1392 else
1393 {
1394 staDesc.ucIsWapiSta = 0;
1395 }
1396#endif /* FEATURE_WLAN_WAPI */
1397
1398 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1399 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1400
Jeff Johnson295189b2012-06-20 16:38:30 -07001401 // UMA is Not ready yet, Xlation will be done by TL
1402 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001403 staDesc.ucSwFrameRXXlation = 1;
1404 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001405 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 staDesc.ucQosEnabled );
1407 // Initialize signatures and state
1408 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1409 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1410 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1411 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001412 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001413 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 -07001414 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1415 hdd_rx_packet_cbk,
1416 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 hdd_tx_fetch_packet_cbk, &staDesc,
1418 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001419
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1421 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001422 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001423 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001425 return vosStatus;
1426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001427
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001428 if ( cfg_param->dynSplitscan &&
1429 ( VOS_TIMER_STATE_RUNNING !=
1430 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1431 {
1432 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1433 cfg_param->trafficMntrTmrForSplitScan);
1434 }
1435
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301436 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1437 // then go to 'authenticated'. For all other authentication types
1438 // (those that donot require upper layer authentication) we can put
1439 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001440 if (staDesc.wSTAType != WLAN_STA_IBSS)
1441 VOS_ASSERT( fConnected );
1442
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301443 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001444 {
1445 // Connections that do not need Upper layer auth, transition TL directly
1446 // to 'Authenticated' state.
1447 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1448 WLANTL_STA_AUTHENTICATED );
1449
1450 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301451
1452 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001453 }
1454 else
1455 {
1456 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301457 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1458 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001459 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301460 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001461 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1462 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 return( vosStatus );
1464}
1465
Jeff Johnson295189b2012-06-20 16:38:30 -07001466static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1467 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1468{
1469 unsigned int len = 0;
1470 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001471 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 tANI_U32 rspRsnLength = 0;
1473 struct ieee80211_channel *chan;
1474
Agarwal Ashish51325b52014-06-16 16:50:49 +05301475 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001476 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001477 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001478 }
1479
Agarwal Ashish51325b52014-06-16 16:50:49 +05301480 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001481 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1482 goto done;
1483 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001484
Agarwal Ashish51325b52014-06-16 16:50:49 +05301485 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001486 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1487 goto done;
1488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001489
1490 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1491 pCsrRoamInfo->nAssocReqLength);
1492 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001493 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001494
1495 //pFTAssocRsp needs to point to the IEs
1496 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001497 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 (unsigned int)pFTAssocRsp[0],
1499 (unsigned int)pFTAssocRsp[1]);
1500
1501 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001502 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001505 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001506
1507 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1508 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1509 reqRsnIe, reqRsnLength,
1510 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001511
1512done:
1513 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001514}
Jeff Johnson295189b2012-06-20 16:38:30 -07001515
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301516void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1517{
1518 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1519 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1520 tCsrRoamInfo roamInfo;
1521 roamInfo.fAuthRequired = FALSE;
1522 vos_mem_copy(roamInfo.bssid,
1523 pHddStaCtx->roam_info.bssid,
1524 WNI_CFG_BSSID_LEN);
1525 vos_mem_copy(roamInfo.peerMac,
1526 pHddStaCtx->roam_info.peerMac,
1527 WNI_CFG_BSSID_LEN);
1528
1529 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1530 &roamInfo,
1531 pHddStaCtx->roam_info.roamId,
1532 pHddStaCtx->roam_info.roamStatus,
1533 eCSR_ROAM_RESULT_AUTHENTICATED);
1534 if (halStatus != eHAL_STATUS_SUCCESS)
1535 {
1536 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1537 }
1538 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1539}
1540
Shailender Karmuchia734f332013-04-19 14:02:48 -07001541static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1542 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001543 eCsrRoamResult roamResult )
1544{
1545 struct net_device *dev = pAdapter->dev;
1546 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1547 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301548 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05301549 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001550 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1551 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001552#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 int ft_carrier_on = FALSE;
1554#endif
1555 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301556 v_BOOL_t hddDisconInProgress = FALSE;
1557
1558 /* HDD has initiated disconnect, do not send connect result indication
1559 * to kernel as it will be handled by __cfg80211_disconnect.
1560 */
1561 if(( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) &&
1562 (( eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1563 ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)) )
1564 {
1565 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1566 FL(" Disconnect from HDD in progress "));
1567 hddDisconInProgress = TRUE;
1568 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001569
Jeff Johnson295189b2012-06-20 16:38:30 -07001570 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1571 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301572 if ( !hddDisconInProgress )
1573 {
1574 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301575 "%s: Set HDD connState to eConnectionState_Associated",
1576 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301577 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001579
c_hpothu44ff4e02014-05-08 00:13:57 +05301580 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 // Save the connection info from CSR...
1582 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1583#ifdef FEATURE_WLAN_WAPI
1584 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1585 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1586 {
1587 pAdapter->wapi_info.fIsWapiSta = 1;
1588 }
1589 else
1590 {
1591 pAdapter->wapi_info.fIsWapiSta = 0;
1592 }
1593#endif /* FEATURE_WLAN_WAPI */
1594
1595 // indicate 'connect' status to userspace
1596 hdd_SendAssociationEvent(dev,pRoamInfo);
1597
1598
Shailender Karmuchia734f332013-04-19 14:02:48 -07001599 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001600 INIT_COMPLETION(pAdapter->linkup_event_var);
1601
1602 /*
1603 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1604 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 -07001605 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001606 know that the device is getting activated properly.
1607 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001608#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05301609 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 {
1611#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001612 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 pAdapter->isLinkUpSvcNeeded = TRUE;
1614
Shailender Karmuchia734f332013-04-19 14:02:48 -07001615 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 pAdapter->isLinkUpSvcNeeded = TRUE;
1617
1618 // Switch on the Carrier to activate the device
1619 netif_carrier_on(dev);
1620
1621 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1622 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1623 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001624 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001625 {
1626 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1627 }
1628
1629 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1630 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001631#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001633 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001636 }
1637#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301638 /* Check for STAID */
1639 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1640 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1641 else
1642 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001643
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001644#ifdef FEATURE_WLAN_TDLS
1645 wlan_hdd_tdls_connection_callback(pAdapter);
1646#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001647 //For reassoc, the station is already registered, all we need is to change the state
1648 //of the STA in TL.
1649 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05301650 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07001651 if( !pRoamInfo->fReassocReq )
1652 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001653 struct cfg80211_bss *bss;
1654#ifdef WLAN_FEATURE_VOWIFI_11R
1655 u8 *pFTAssocRsp = NULL;
1656 unsigned int assocRsplen = 0;
1657 u8 *pFTAssocReq = NULL;
1658 unsigned int assocReqlen = 0;
1659 struct ieee80211_channel *chan;
1660#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001663
1664 /* add bss_id to cfg80211 data base */
1665 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1666 if (NULL == bss)
1667 {
1668 pr_err("wlan: Not able to create BSS entry\n");
Katya Nigam346d4e92014-09-02 16:16:12 +05301669 netif_carrier_off(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 return eHAL_STATUS_FAILURE;
1671 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001672#ifdef WLAN_FEATURE_VOWIFI_11R
1673 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001674 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001676
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001677 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001678 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001679 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001680 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001681 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001682 // pFTAssocRsp needs to point to the IEs
1683 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1684 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1685 (unsigned int)pFTAssocRsp[0],
1686 (unsigned int)pFTAssocRsp[1]);
1687 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001688 }
1689 else
1690 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001691 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1692 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001693 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001694
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001695 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001696 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001697 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001698 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001699 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001700 if(!ft_carrier_on)
1701 {
1702 // pFTAssocReq needs to point to the IEs
1703 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1704 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1705 (unsigned int)pFTAssocReq[0],
1706 (unsigned int)pFTAssocReq[1]);
1707 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1708 }
1709 else
1710 {
1711 /* This should contain only the FTIEs */
1712 assocReqlen = pRoamInfo->nAssocReqLength;
1713 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001714 }
1715 else
1716 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001717 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1718 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001719 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001720
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001721 if(ft_carrier_on)
1722 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301723 if ( !hddDisconInProgress )
1724 {
1725 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001726 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301727 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001728 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301729 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001730 assocRsplen);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301731 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1732 {
1733 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1734 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301735 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001736 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1737 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301738 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301739 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1740 {
1741 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1742 pRoamInfo->fAuthRequired = FALSE;
1743
1744 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1745 pRoamInfo->bssid,
1746 HDD_MAC_ADDR_LEN);
1747 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1748 pRoamInfo->peerMac,
1749 HDD_MAC_ADDR_LEN);
1750 pHddStaCtx->roam_info.roamId = roamId;
1751 pHddStaCtx->roam_info.roamStatus = roamStatus;
1752 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1753 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001754 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301755 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001756 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001757 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001758 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001759 cfg80211_connect_result(dev, pRoamInfo->bssid,
1760 pFTAssocReq, assocReqlen,
1761 pFTAssocRsp, assocRsplen,
1762 WLAN_STATUS_SUCCESS,
1763 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001764 }
1765 }
1766 else
1767#endif
1768 {
1769 /* wpa supplicant expecting WPA/RSN IE in connect result */
1770 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1771 pAdapter->sessionId,
1772 &reqRsnLength,
1773 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001774
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001775 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1776 pAdapter->sessionId,
1777 &rspRsnLength,
1778 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301779 if ( !hddDisconInProgress )
1780 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001781#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301782 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301783 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301784 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301785 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1786 {
1787 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1788 }
Mukul Sharma84f27252014-07-14 18:11:42 +05301789 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301790 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001791#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001792
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301793 {
1794 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301795 "%s: sending connect indication to nl80211:"
1796 " for bssid " MAC_ADDRESS_STR
1797 " reason:%d and Status:%d\n",
1798 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1799 roamResult, roamStatus);
1800
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301801 /* inform connect result to nl80211 */
1802 cfg80211_connect_result(dev, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001803 reqRsnIe, reqRsnLength,
1804 rspRsnIe, rspRsnLength,
1805 WLAN_STATUS_SUCCESS,
1806 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301807 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001808 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001809 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301810 if ( !hddDisconInProgress )
1811 {
1812 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001813#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301814 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001815#endif
1816 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301817 // Register the Station with TL after associated...
1818 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 pRoamInfo,
1820 pHddStaCtx->conn_info.staId[ 0 ],
1821 NULL,
1822 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301823 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001824 }
1825 else
1826 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001827 /* wpa supplicant expecting WPA/RSN IE in connect result */
1828 /* in case of reassociation also need to indicate it to supplicant */
1829 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1830 pAdapter->sessionId,
1831 &reqRsnLength,
1832 reqRsnIe);
1833
1834 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301836 if( pRoamInfo->fAuthRequired )
1837 {
1838 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1839 pHddStaCtx->conn_info.staId[ 0 ],
1840 WLANTL_STA_CONNECTED );
1841 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1842 }
1843 else
1844 {
1845 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1846 "%s: staId: %d Changing TL state to AUTHENTICATED",
1847 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1848 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1849 pHddStaCtx->conn_info.staId[ 0 ],
1850 WLANTL_STA_AUTHENTICATED );
1851 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301852 hdd_postTLPacketPendingInd(pAdapter,
1853 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301854 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001855 }
1856
1857 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1858 {
1859 // perform any WMM-related association processing
1860 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1861 }
1862 else
1863 {
1864 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001865 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 vosStatus, vosStatus );
1867 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001868#ifdef WLAN_FEATURE_11W
1869 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1870 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1871#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301872
Jeff Johnson295189b2012-06-20 16:38:30 -07001873 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05301874 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301875 {
1876 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05301877 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301878 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301879 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1880 {
1881 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1882 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001883 }
1884 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001886 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1887
1888 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001889 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001890 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1891 " reason:%d and Status:%d\n",
1892 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1893 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001894 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001895 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1896 " reason:%d and Status:%d\n",
1897 MAC_ADDR_ARRAY(pWextState->req_bssId),
1898 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001899
Abhishek Singh611295e2015-07-09 11:11:54 +05301900 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)
1901 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05301902 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
1903
Abhishek Singhf4669da2014-05-26 15:07:49 +05301904 /* Set connection state to eConnectionState_NotConnected only when CSR
1905 * has completed operation - with a ASSOCIATION_FAILURE status
1906 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301907 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301908 {
1909 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1910 "%s: Set HDD connState to eConnectionState_NotConnected",
1911 __func__);
1912 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1913 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05301914 if((pHddCtx->concurrency_mode <= 1) &&
1915 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 {
1917 pHddCtx->isAmpAllowed = VOS_TRUE;
1918 }
1919
1920 //If the Device Mode is Station
1921 // and the P2P Client is Connected
1922 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001923
1924 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001925 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001926 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1927 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05301928 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07001929 {
1930 //Enable BMPS only of other Session is P2P Client
1931 hdd_context_t *pHddCtx = NULL;
1932 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1933
1934 if (NULL != pVosContext)
1935 {
1936 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1937
1938 if(NULL != pHddCtx)
1939 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301940 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301941 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1942 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301943 {
1944 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001945 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301946 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001947 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301948 hdd_enable_bmps_imps(pHddCtx);
1949 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 }
1951 }
1952 }
1953
James Zmudafbf5ffc2013-03-25 12:45:35 -07001954 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001955 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301956 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07001957 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301958 if (pRoamInfo)
1959 hddLog(VOS_TRACE_LEVEL_ERROR,
1960 "%s: send connect failure to nl80211:"
1961 " for bssid " MAC_ADDRESS_STR
1962 " reason:%d and Status:%d\n" ,
1963 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1964 roamResult, roamStatus);
1965 else
1966 hddLog(VOS_TRACE_LEVEL_ERROR,
1967 "%s: connect failed:"
1968 " for bssid " MAC_ADDRESS_STR
1969 " reason:%d and Status:%d\n" ,
1970 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1971 roamResult, roamStatus);
1972
c_hpothudaa90e22014-06-24 17:23:43 +05301973 /*Clear the roam profile*/
1974 hdd_clearRoamProfileIe( pAdapter );
1975
James Zmudafbf5ffc2013-03-25 12:45:35 -07001976 /* inform association failure event to nl80211 */
1977 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1978 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001979 if (pRoamInfo)
1980 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1981 NULL, 0, NULL, 0,
1982 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1983 GFP_KERNEL );
1984 else
1985 cfg80211_connect_result ( dev, pWextState->req_bssId,
1986 NULL, 0, NULL, 0,
1987 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1988 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001989 }
1990 else
1991 {
Sushant Kaushik21f28232014-12-18 11:42:46 +05301992 if (pRoamInfo){
1993 eCsrAuthType authType =
1994 pWextState->roamProfile.AuthType.authType[0];
1995 v_BOOL_t isWep = (authType == eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
1996 (authType == eCSR_AUTH_TYPE_SHARED_KEY);
1997
1998 /* In case of OPEN-WEP or SHARED-WEP authentication,
1999 * send exact protocol reason code. This enables user
2000 * applications to reconnect the station with correct
2001 * configuration.
2002 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002003 cfg80211_connect_result ( dev, pRoamInfo->bssid,
2004 NULL, 0, NULL, 0,
Sushant Kaushik21f28232014-12-18 11:42:46 +05302005 isWep ? pRoamInfo->reasonCode :
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002006 WLAN_STATUS_UNSPECIFIED_FAILURE,
2007 GFP_KERNEL );
Sushant Kaushik21f28232014-12-18 11:42:46 +05302008 } else
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002009 cfg80211_connect_result ( dev, pWextState->req_bssId,
2010 NULL, 0, NULL, 0,
2011 WLAN_STATUS_UNSPECIFIED_FAILURE,
2012 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07002013 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002014 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002015
Kumar Anand82c009f2014-05-29 00:29:42 -07002016 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002017
c_hpothu24f40982014-04-18 18:00:36 +05302018 if (pRoamInfo)
2019 {
2020 WLANTL_AssocFailed(pRoamInfo->staId);
2021 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302022
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302023 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 netif_tx_disable(dev);
2025 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002026
Jeff Johnson295189b2012-06-20 16:38:30 -07002027 }
2028
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302029 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302030 {
2031 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2032 if (pHostapdAdapter != NULL)
2033 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302034 /* Restart SAP if its operating channel is different
2035 * from AP channel.
2036 */
2037 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2038 (int)pRoamInfo->pBssDesc->channelId)
2039 {
2040 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2041 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2042 (int)pRoamInfo->pBssDesc->channelId);
Deepthi Gowric9c777d2014-12-10 16:17:11 +05302043 hdd_hostapd_stop(pHostapdAdapter->dev);
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302044 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302045 }
2046 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002047 return eHAL_STATUS_SUCCESS;
2048}
2049
2050/**============================================================================
2051 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002052 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002054
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002056static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2057 tCsrRoamInfo *pRoamInfo,
2058 tANI_U32 roamId,
2059 eRoamCmdStatus roamStatus,
2060 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002061{
Katya Nigam47528772015-02-11 12:24:49 +05302062 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2063 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2064 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302065 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302066
Jeff Johnson81c17882013-05-03 09:53:35 -07002067 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2068 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2069
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 switch( roamResult )
2071 {
2072 // both IBSS Started and IBSS Join should come in here.
2073 case eCSR_ROAM_RESULT_IBSS_STARTED:
2074 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002075 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002077 if (NULL == pRoamInfo)
2078 {
2079 VOS_ASSERT(0);
2080 return;
2081 }
2082
2083 /* When IBSS Started comes from CSR, we need to move
2084 * connection state to IBSS Disconnected (meaning no peers
2085 * are in the IBSS).
2086 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302087 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2088 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2089 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002090 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2091 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302092 /*notify wmm */
2093 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002094 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002095
Jeff Johnson81c17882013-05-03 09:53:35 -07002096 if (pRoamInfo->pBssDesc)
2097 {
Katya Nigam47528772015-02-11 12:24:49 +05302098 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2099 IBSS_BROADCAST_STAID,
2100 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002101
2102 /* we created the IBSS, notify supplicant */
2103 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2104 MAC_ADDRESS_STR,
2105 __func__, pAdapter->dev->name,
2106 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2107
2108 /* we must first give cfg80211 the BSS information */
2109 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2110 if (NULL == bss)
2111 {
2112 hddLog(VOS_TRACE_LEVEL_ERROR,
2113 "%s: %s: unable to create IBSS entry",
2114 __func__, pAdapter->dev->name);
2115 return;
2116 }
2117
2118 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07002119 cfg80211_put_bss(
2120#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2121 pHddCtx->wiphy,
2122#endif
2123 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07002124 }
Katya Nigam47528772015-02-11 12:24:49 +05302125 else
2126 {
2127 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2128 "%s: NULL Bss Desc",__func__);
2129 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05302130
2131 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
2132 * in IBSS_COALESCED will remove the BC key.
2133 */
2134 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
2135 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
2136 == pHddStaCtx->ibss_enc_key.encType
2137 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
2138 == pHddStaCtx->ibss_enc_key.encType
2139 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2140 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
2141 {
2142 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2143 VOS_STATUS vosStatus;
2144
2145 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2146
2147 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2148 grpmacaddr, WNI_CFG_BSSID_LEN);
2149 hddLog(VOS_TRACE_LEVEL_INFO,
2150 FL(" SET GTK in case of COALESCED"));
2151 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2152 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2153 if ( VOS_STATUS_SUCCESS != vosStatus )
2154 {
2155 hddLog(VOS_TRACE_LEVEL_ERROR,
2156 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
2157 }
2158 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 break;
2160 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002161
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
2163 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002164 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
2165 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 break;
2167 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002168
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07002170 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
2171 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002173 }
2174
Jeff Johnson81c17882013-05-03 09:53:35 -07002175 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002176}
2177
2178/**============================================================================
2179 *
2180 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
2181 This information is passed to iwconfig later. The peer that joined
2182 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002183 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002185
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05302187static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07002188{
2189 int fSuccess = FALSE;
2190 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302191 VOS_STATUS status;
2192 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002193
Jeff Johnson295189b2012-06-20 16:38:30 -07002194 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2195 {
2196 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
2197 {
2198 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002199
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002201
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 fSuccess = TRUE;
2203 break;
2204 }
2205 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002206
Nirav Shah7e3c8132015-06-22 23:51:42 +05302207 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
2208 if (status != VOS_STATUS_SUCCESS) {
2209 hddLog(VOS_TRACE_LEVEL_ERROR,
2210 FL("Not able to add staid hash %d"), staId);
2211 return FALSE;
2212 }
2213
2214 hddLog(VOS_TRACE_LEVEL_INFO,
2215 FL("New station added sta_id %d mac:"
2216 MAC_ADDRESS_STR), staId,
2217 MAC_ADDR_ARRAY(peerMacAddress->bytes));
2218
Shailender Karmuchia734f332013-04-19 14:02:48 -07002219 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07002220}
2221/**============================================================================
2222 *
2223 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002224 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002226
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07002228static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07002229{
2230 int fSuccess = FALSE;
2231 int idx = 0;
2232 v_U8_t valid_idx = 0;
2233 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07002234 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002235 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05302236 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002237
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2239 {
2240 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
2241 {
2242 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302243 status = hdd_sta_id_hash_remove_entry(pAdapter,
2244 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
2245 if (status != VOS_STATUS_SUCCESS) {
2246 hddLog(VOS_TRACE_LEVEL_ERROR,
2247 FL("Not able to remove staid hash %d"), staId );
2248 fSuccess = FALSE;
2249 } else {
2250 hddLog(VOS_TRACE_LEVEL_INFO,
2251 FL("station removed sta_id %d mac:"
2252 MAC_ADDRESS_STR), staId,
2253 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07002254
Nirav Shah7e3c8132015-06-22 23:51:42 +05302255 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002256
Nirav Shah7e3c8132015-06-22 23:51:42 +05302257 fSuccess = TRUE;
2258 // Note the deleted Index, if its 0 we need special handling
2259 del_idx = idx;
2260 empty_slots++;
2261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 }
2263 else
2264 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002265 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 {
2267 valid_idx = idx;
2268 }
Ravi Joshi8a934352013-09-25 16:46:58 -07002269 else
2270 {
2271 // Found an empty slot
2272 empty_slots++;
2273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002274 }
2275 }
2276
Ravi Joshi8a934352013-09-25 16:46:58 -07002277 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
2278 {
2279 // Last peer departed, set the IBSS state appropriately
2280 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002281 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07002282 "Last IBSS Peer Departed!!!" );
2283 }
2284
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 // Find next active staId, to have a valid sta trigger for TL.
2286 if (fSuccess == TRUE)
2287 {
2288 if (del_idx == 0)
2289 {
2290 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
2291 {
2292 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
2293 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
2294 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
2295
2296 pHddStaCtx->conn_info.staId[valid_idx] = 0;
2297 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
2298 }
2299 }
2300 }
2301 return( fSuccess );
2302}
2303
2304/**============================================================================
2305 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002306 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07002307 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002308
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 ===========================================================================*/
2310static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
2311{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002312 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05302313 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2314 "%s: IBSS Connect Indication from SME!!! "
2315 "Set HDD connState to eConnectionState_IbssConnected",
2316 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
2318 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
2319
2320 // Save the connection info from CSR...
2321 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
2322
2323 // Send the bssid address to the wext.
2324 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002326 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2327 if (NULL == bss)
2328 {
2329 hddLog(VOS_TRACE_LEVEL_ERROR,
2330 "%s: %s: unable to create IBSS entry",
2331 __func__, pAdapter->dev->name);
2332 return eHAL_STATUS_FAILURE;
2333 }
Yue Maf49ba872013-08-19 12:04:25 -07002334 cfg80211_put_bss(
2335#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2336 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
2337#endif
2338 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07002339
2340 return( eHAL_STATUS_SUCCESS );
2341}
2342/**============================================================================
2343 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05302344 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
2345 suspend related data which was cleared during roaming in FWR.
2346
2347 ===========================================================================*/
2348static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
2349{
2350 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
2351 hdd_adapter_t *pAdapter;
2352 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
2353 ENTER();
2354
2355 spin_lock(&pHddCtx->filter_lock);
2356 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
2357 {
2358 pHddCtx->sus_res_mcastbcast_filter =
2359 pHddCtx->configuredMcastBcastFilter;
2360 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
2361 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
2362 hddLog(VOS_TRACE_LEVEL_INFO,
2363 FL("saving configuredMcastBcastFilter = %d"),
2364 pHddCtx->configuredMcastBcastFilter);
2365 hddLog(VOS_TRACE_LEVEL_INFO,
2366 FL("offload: calling hdd_conf_mcastbcast_filter"));
2367 }
2368 spin_unlock(&pHddCtx->filter_lock);
2369
2370 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
2371 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
2372 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
2373
2374 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
2375 //No need to configure GTK Offload from here because it might possible
2376 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
2377 //be handled as part of cfg80211_set_rekey_data processing.
2378 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
2379 {
2380 pAdapter = pAdapterNode->pAdapter;
2381 if( pAdapter &&
2382 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
2383 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
2384 {
2385 if (pHddCtx->cfg_ini->fhostArpOffload)
2386 {
2387 //Configure ARPOFFLOAD
2388 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
2389 if (!VOS_IS_STATUS_SUCCESS(vstatus))
2390 {
2391 hddLog(VOS_TRACE_LEVEL_ERROR,
2392 FL("Failed to disable ARPOffload Feature %d"), vstatus);
2393 }
2394 }
2395#ifdef WLAN_NS_OFFLOAD
2396 //Configure NSOFFLOAD
2397 if (pHddCtx->cfg_ini->fhostNSOffload)
2398 {
2399 hdd_conf_ns_offload(pAdapter, TRUE);
2400 }
2401#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05302402#ifdef WLAN_FEATURE_PACKET_FILTERING
2403 /* During suspend, configure MC Addr list filter to the firmware
2404 * function takes care of checking necessary conditions before
2405 * configuring.
2406 */
2407 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
2408#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05302409 }
2410 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2411 pAdapterNode = pNext;
2412 }
2413 EXIT();
2414}
2415
2416/**============================================================================
2417 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002418 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002419
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002421static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2422 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002423 eCsrRoamResult roamResult )
2424{
2425 eCsrEncryptionType connectedCipherAlgo;
2426 v_BOOL_t fConnected = FALSE;
2427 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2428 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2429 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302430 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002432
2433 if (NULL == pRoamInfo)
2434 {
2435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2436 return eHAL_STATUS_FAILURE;
2437 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002438 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002439 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 // not require upper layer authentication) we can put TL directly into 'authenticated'
2441 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002442 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2443 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2444 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002445
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2447 if( fConnected )
2448 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002449 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2450 {
2451 v_U8_t staId;
2452
2453 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2454
2455 if ( 0 == memcmp( pRoamInfo->peerMac,
2456 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2457 {
2458 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2459 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05302460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2461 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002462 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2463 }
2464 else
2465 {
2466 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2467 (v_MACADDR_t*)pRoamInfo->peerMac,
2468 &staId);
2469 if ( VOS_STATUS_SUCCESS == vosStatus )
2470 {
2471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2472 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2473 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2474 staId);
2475 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2476 }
2477 }
2478 }
2479 else
2480 {
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302481 // TODO: Considering getting a state machine in HDD later.
2482 // This routine is invoked twice. 1)set PTK 2)set GTK.
2483 // The folloing if statement will be TRUE when setting GTK.
2484 // At this time we don't handle the state in detail.
2485 // Related CR: 174048 - TL not in authenticated state
2486 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2487 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2488 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302489 WLANTL_GetSTAState(pHddCtx->pvosContext,
2490 pHddStaCtx->conn_info.staId[0],
2491 &prevTLState);
2492
2493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2494 "for StaId=%d. Changing TL state to AUTHENTICATED from"
2495 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302496
2497 // Connections that do not need Upper layer authentication,
2498 // transition TL to 'Authenticated' state after the keys are set.
2499 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2500 pHddStaCtx->conn_info.staId[ 0 ],
2501 WLANTL_STA_AUTHENTICATED );
2502
2503 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302504
2505 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2506 hdd_postTLPacketPendingInd(pAdapter,
2507 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05302508 //Need to call offload because when roaming happen at that time fwr
2509 //clean offload info as part of the DelBss
2510 // No need to configure offload if host was not suspended
2511 spin_lock(&pHddCtx->filter_lock);
2512 if(pHddCtx->hdd_wlan_suspended)
2513 {
2514 spin_unlock(&pHddCtx->filter_lock);
2515 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2516 }
2517 else
2518 {
2519 spin_unlock(&pHddCtx->filter_lock);
2520 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302521 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2522 {
2523 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2524 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302525 }
2526 else
2527 {
2528 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2529 pHddStaCtx->conn_info.staId[ 0 ]);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302530 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2531 {
2532 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2533 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302534 }
2535
2536 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302539 else
2540 {
2541 // possible disassoc after issuing set key and waiting set key complete
2542 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2543 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002544
Jeff Johnson295189b2012-06-20 16:38:30 -07002545 EXIT();
2546 return( eHAL_STATUS_SUCCESS );
2547}
2548/**============================================================================
2549 *
2550 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2551 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002552static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002553 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002554{
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2556
2557 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2558 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2559 {
2560 struct iw_michaelmicfailure msg;
2561 union iwreq_data wreq;
2562 memset(&msg, '\0', sizeof(msg));
2563 msg.src_addr.sa_family = ARPHRD_ETHER;
2564 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002565 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2566 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002567
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2569 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002570 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 msg.flags = IW_MICFAILURE_PAIRWISE;
2572 memset(&wreq, 0, sizeof(wreq));
2573 wreq.data.length = sizeof(msg);
2574 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002576 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2578 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2579 NL80211_KEYTYPE_GROUP :
2580 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002581 pRoamInfo->u.pMICFailureInfo->keyId,
2582 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002583 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002584
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002586
Jeff Johnson295189b2012-06-20 16:38:30 -07002587 return( eHAL_STATUS_SUCCESS );
2588}
2589
2590/**============================================================================
2591 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002592 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002594
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002596static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2597 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 eCsrRoamResult roamResult )
2599{
2600 VOS_STATUS vosStatus;
2601
2602 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2603 switch( roamResult )
2604 {
2605 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2606 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002607 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002608 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002609
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002610 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002611 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2612 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2613 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002615
Nirav Shah7e3c8132015-06-22 23:51:42 +05302616 if ( !roamSaveIbssStation( pAdapter, pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 {
2618 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2619 "New IBSS peer but we already have the max we can handle. Can't register this one" );
2620 break;
2621 }
2622
2623 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2624
Shailender Karmuchia734f332013-04-19 14:02:48 -07002625 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2626 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2627 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2628
2629 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05302630 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 pRoamInfo,
2632 pRoamInfo->staId,
2633 (v_MACADDR_t *)pRoamInfo->peerMac,
2634 pRoamInfo->pBssDesc );
2635 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2636 {
2637 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002638 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 vosStatus, vosStatus );
2640 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002641 pHddStaCtx->ibss_sta_generation++;
2642 memset(&staInfo, 0, sizeof(staInfo));
2643 staInfo.filled = 0;
2644 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2645
2646 cfg80211_new_sta(pAdapter->dev,
2647 (const u8 *)pRoamInfo->peerMac,
2648 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002649
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002650 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2651 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2652 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2653 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2654 {
2655 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302656
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002657 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2658 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2659
2660 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002661 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002662 pHddStaCtx->ibss_enc_key.encType);
2663
2664 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2665 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2666
2667 if ( VOS_STATUS_SUCCESS != vosStatus )
2668 {
2669 hddLog(VOS_TRACE_LEVEL_ERROR,
2670 "%s: sme_RoamSetKey failed, returned %d",
2671 __func__, vosStatus);
2672 return VOS_STATUS_E_FAILURE;
2673 }
2674 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302676 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002677 netif_tx_start_all_queues(pAdapter->dev);
2678 break;
2679 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002680
Jeff Johnson295189b2012-06-20 16:38:30 -07002681 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2682 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002683
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002685
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2689 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002690 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002691
Ravi Joshicc57ed42013-10-12 16:31:25 -07002692 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 {
2694 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2695 "IBSS peer departed by cannot find peer in our registration table with TL" );
2696 }
2697
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002698 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002699 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2700 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2701 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2702 pRoamInfo->staId );
2703
Katya Nigam47528772015-02-11 12:24:49 +05302704 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002705
2706 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002707 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002708
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002709 cfg80211_del_sta(pAdapter->dev,
2710 (const u8 *)&pRoamInfo->peerMac,
2711 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002712 break;
2713 }
2714 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2715 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002716 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2717 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302719 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002720 netif_tx_disable(pAdapter->dev);
2721 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302722 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2723 "%s: Set HDD connState to eConnectionState_NotConnected",
2724 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002725 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002726
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 // Send the bssid address to the wext.
2728 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2729 // clean up data path
2730 hdd_disconnect_tx_rx(pAdapter);
2731 break;
2732 }
2733 default:
2734 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002735
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002737
Jeff Johnson295189b2012-06-20 16:38:30 -07002738 return( eHAL_STATUS_SUCCESS );
2739}
2740
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002741#ifdef FEATURE_WLAN_TDLS
2742/**============================================================================
2743 *
2744 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2745 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2746 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002747
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002748 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002749VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2750 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002751{
2752 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002753 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002754 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2755 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002756 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2757 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002758 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2759 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002760
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002761 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2762 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002763 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002764 "%s not connected. ignored", __func__);
2765 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002766 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002767
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002768 /*
2769 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2770 * be peer MAC, here we are wokrking on direct Link
2771 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002772 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002773
2774 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002775
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002776 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002777 sizeof(tSirMacAddr) );
2778
2779 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2780 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2781
2782 /* set the QoS field appropriately ..*/
2783 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2784 : (staDesc.ucQosEnabled = 0) ;
2785
2786 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002787 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002788
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002789 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002790
2791 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002792 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002793
Shailender Karmuchia734f332013-04-19 14:02:48 -07002794 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002795 * UMA is ready we inform TL to do frame translation.
2796 */
2797 staDesc.ucSwFrameTXXlation = 1;
2798 staDesc.ucSwFrameRXXlation = 1;
2799 staDesc.ucAddRmvLLC = 1;
2800
2801 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002802 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002803
2804 /* tdls Direct Link do not need bcastSig */
2805 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002806
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002807#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2808 if(staDesc.ucProtectedFrame)
2809 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2810 else
2811 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2812#endif
2813
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302814 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002815
Shailender Karmuchia734f332013-04-19 14:02:48 -07002816 /* Register the Station with TL... */
2817 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2818 hdd_rx_packet_cbk,
2819 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002820 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002821
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002822 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2823 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002824 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002825 "%s: WLANTL_RegisterSTAClient() failed to register. "
2826 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002827 return vosStatus;
2828 }
2829
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002830 if ( cfg_param->dynSplitscan &&
2831 ( VOS_TIMER_STATE_RUNNING !=
2832 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2833 {
2834 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2835 cfg_param->trafficMntrTmrForSplitScan);
2836 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002837 return( vosStatus );
2838}
2839
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05302840VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002841{
2842 VOS_STATUS vosStatus;
2843 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2844 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2845 {
2846 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2847 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002848 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002849 __func__, staId, vosStatus, vosStatus );
2850 }
2851 return( vosStatus );
2852}
2853
2854
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002855/*
2856 * HDD interface between SME and TL to ensure TDLS client registration with
2857 * TL in case of new TDLS client is added and deregistration at the time
2858 * TDLS client is deleted.
2859 */
2860
Shailender Karmuchia734f332013-04-19 14:02:48 -07002861eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2862 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002863 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002864 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002865 eCsrRoamResult roamResult)
2866{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002867 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002868 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002869 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002870
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002872 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2873 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2874 "ADD_TDLS_PEER" :
2875 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2876 "DEL_TDLS_PEER" :
2877 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2878 "DEL_TDLS_PEER_IND" :
2879 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2880 "DEL_ALL_TDLS_PEER_IND" :
2881 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2882 "UPDATE_TDLS_PEER" :
2883 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2884 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2885 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002886 switch( roamResult )
2887 {
2888 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2889 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002890 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2891 {
2892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002893 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002894 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002895 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002896 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002897
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002898 /* check if there is available index for this new TDLS STA */
2899 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2900 {
2901 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2902 {
2903 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2904 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2905
2906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002907 ("TDLS: STA IDX at %d is %d "
2908 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002909 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002910 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002911
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002912 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002913 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2914 status = eHAL_STATUS_SUCCESS ;
2915 break ;
2916 }
2917 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002918 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002919 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002920 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002921 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2922 "wlan_hdd_tdls_set_sta_id() failed");
2923 return VOS_FALSE;
2924 }
2925
2926 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302927 /* store the ucast signature , if required for further reference. */
2928
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002929 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302930 /* start TDLS client registration with TL */
2931 status = hdd_roamRegisterTDLSSTA( pAdapter,
2932 pRoamInfo->peerMac,
2933 pRoamInfo->staId,
2934 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05302935 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002936 }
2937 else
2938 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002939 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002941 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002942 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002943 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002944 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002945 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002946 break ;
2947 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002948 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2949 {
2950 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2951 {
2952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2953 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2954 }
2955 /* store the ucast signature which will be used later when
2956 * registering to TL
2957 */
2958 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2959 complete(&pAdapter->tdls_add_station_comp);
2960 break;
2961 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302962 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
2963 {
2964 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2965 {
2966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2967 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
2968 }
2969 complete(&pAdapter->tdls_link_establish_req_comp);
2970 break;
2971 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002972 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002973 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002974 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002975 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002976 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002977 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2978 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002979 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002981 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2982
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302983 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05302984 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002985 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05302986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2987 " Current status for peer" MAC_ADDRESS_STR "is %d",
2988 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05302989 if (TDLS_IS_CONNECTED(curr_peer) ||
2990 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05302991 {
2992 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2993 }
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05302994 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002995 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002996 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002997
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002998 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2999 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3000 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003001 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003002 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003003 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003004 break ;
3005 }
3006 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003007 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003008 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003009 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003010 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3011 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003012 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003013 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3014 "%s: Sending teardown to supplicant with reason code %u",
3015 __func__, pRoamInfo->reasonCode);
3016
3017#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303018 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003019 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003020#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003021 status = eHAL_STATUS_SUCCESS ;
3022 break ;
3023 }
3024 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3025 {
3026 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003027 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003028 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003029 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3030 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003031 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003033 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003034 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003035 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003036 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
3037 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3038 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003039
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003040 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003041 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003042 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3043 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003044
3045 status = eHAL_STATUS_SUCCESS ;
3046 }
3047 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303048 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003049 break ;
3050 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003051 default:
3052 {
3053 break ;
3054 }
3055 }
3056
3057 return status ;
3058}
3059#endif
3060
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003061static void iw_full_power_cbfn (void *pContext, eHalStatus status)
3062{
3063 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3064 hdd_context_t *pHddCtx = NULL;
3065 int ret;
3066
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303067 ENTER();
3068
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003069 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3070 {
3071 hddLog(VOS_TRACE_LEVEL_ERROR,
3072 "%s: Bad param, pAdapter [%p]",
3073 __func__, pAdapter);
3074 return;
3075 }
3076
3077 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3078 ret = wlan_hdd_validate_context(pHddCtx);
3079 if (0 != ret)
3080 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003081 return;
3082 }
3083
3084 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3085 {
3086 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3087 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303088
3089 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003090}
3091
Shailender Karmuchia734f332013-04-19 14:02:48 -07003092eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3094{
3095 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
3096 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303097 hdd_wext_state_t *pWextState = NULL;
3098 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003099 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07003100 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003101
3102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003103 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003104 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003105
3106 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303107 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003108 {
3109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303110 "invalid adapter or adapter has invalid magic");
3111 return eHAL_STATUS_FAILURE;
3112 }
3113
3114 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3115 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3116
3117 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3118 {
3119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3120 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003121 return eHAL_STATUS_FAILURE;
3122 }
3123
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 switch( roamStatus )
3125 {
3126 case eCSR_ROAM_SESSION_OPENED:
3127 if(pAdapter != NULL)
3128 {
3129 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
3130 complete(&pAdapter->session_open_comp_var);
3131 }
3132 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003133
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003134#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
3135 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07003137 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 * interface down */
3139 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303140 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
3141 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05303142 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3144 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
3145 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3147 }
3148 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05303149 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003150 break;
3151
3152 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003153 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07003154 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07003155 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 // eCSR_ROAM_SHOULD_ROAM will be received.
3157 // Where in we will not mark the link down
3158 // Also we want to stop tx at this point when we will be
3159 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003160 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 {
3162 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303163 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303165 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3166 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3167 {
3168 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
3169 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003170 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303171 * Deregister this STA with TL, but do not flush the packets
3172 * for this STA from wmm_tx_queue. Since there is no valid STA
3173 * for these packets they will not be transmitted. Eventually
3174 * after the reassociation is successful, these packets will be
3175 * transmitted after registering STA with TL again. This ensures
3176 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003177 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303178 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
3179 pHddStaCtx->conn_info.staId[0]);
3180 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003181 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3183 FL("WLANTL_ClearSTAClient failed for staID %d."
3184 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
3185 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003186 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 }
3189 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003190 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 break;
3192#endif
3193
3194 case eCSR_ROAM_SHOULD_ROAM:
3195 // Dont need to do anything
3196 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 struct net_device *dev = pAdapter->dev;
3198 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3199 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303200 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003202#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 if (pHddStaCtx->ft_carrier_on == FALSE)
3204 {
3205#endif
3206 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003207#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003208 }
3209#endif
3210
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003211#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 //We should clear all sta register with TL, for now, only one.
3213 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
3214 if ( !VOS_IS_STATUS_SUCCESS(status ) )
3215 {
3216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3217 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
3218 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003219 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003221#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 }
3223 break;
3224 case eCSR_ROAM_LOSTLINK:
3225 case eCSR_ROAM_DISASSOCIATED:
3226 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3228 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05303229 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3231 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07003232 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3233 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303234 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07003235 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08003236
3237 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
3238 pHddCtx->configuredMcastBcastFilter =
3239 pHddCtx->sus_res_mcastbcast_filter;
3240 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
3241 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303242
Amar Singhald53568e2013-09-26 11:03:45 -07003243 hddLog(VOS_TRACE_LEVEL_INFO,
3244 "offload: disassociation happening, restoring configuredMcastBcastFilter");
3245 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
3246 pHddCtx->configuredMcastBcastFilter);
3247 hddLog(VOS_TRACE_LEVEL_INFO,
3248 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3250 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003251#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303252 /* Call to clear any MC Addr List filter applied after
3253 * successful connection.
3254 */
3255 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003256#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003257 }
3258 break;
3259 case eCSR_ROAM_IBSS_LEAVE:
3260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3261 "****eCSR_ROAM_IBSS_LEAVE****");
3262 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3263 break;
3264 case eCSR_ROAM_ASSOCIATION_COMPLETION:
3265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3266 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303267 // To Do - address probable memory leak with WEP encryption upon successful association
3268 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303270 //Clear saved connection information in HDD
3271 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303273 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003274
3275 break;
3276 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003277 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 pRoamInfo, roamId, roamStatus, roamResult );
3279 break;
3280 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07003281 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
3282 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003283 break;
3284
3285 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
3286 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003287 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003288
3289 case eCSR_ROAM_MIC_ERROR_IND:
3290 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3291 break;
3292
3293 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003294 {
3295 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3296
3297 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003298 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
3299 (TRUE == pHddCtx->hdd_wlan_suspended) &&
3300 (eCSR_ROAM_RESULT_NONE == roamResult))
3301 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003302 /* Send DTIM period to the FW; only if the wlan is already
3303 in suspend. This is the case with roaming (reassoc),
3304 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
3305 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
3306 before the ENTER_BMPS_REQ ensures Listen Interval is
3307 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003308 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003309
3310 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003311 if due to unexpected scenario, if we are in BMPS,
3312 then trigger Exit and Enter BMPS to take DTIM period
3313 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003314 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
3315 {
3316 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
3317
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003318 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3319 iw_full_power_cbfn, pAdapter,
3320 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003321 }
3322 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303323
3324 if ((pHddCtx) &&
3325 FULL_POWER == pmcGetPmcState(pHddCtx->hHal) &&
3326 VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
3327 {
3328 hddLog( LOG1, FL("Device in full power."
3329 "Stop and start traffic timer for roaming"));
3330 pmcStopTrafficTimer(pHddCtx->hHal);
3331 if (pmcStartTrafficTimer(pHddCtx->hHal,
3332 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
3333 {
3334 hddLog(LOGP, FL("Cannot start traffic timer"));
3335 }
3336 }
3337
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003338 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05303339 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003340 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 break;
3342#ifdef WLAN_FEATURE_VOWIFI_11R
3343 case eCSR_ROAM_FT_RESPONSE:
3344 hdd_SendFTEvent(pAdapter);
3345 break;
3346#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07003347#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003348 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003349 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07003350 {
3351 /* Notify the supplicant of a new candidate */
3352 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
3353 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003354 break;
3355#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003356
Yue Maef608272013-04-08 23:09:17 -07003357#ifdef FEATURE_WLAN_LFR_METRICS
3358 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
3359 /* This event is to notify pre-auth initiation */
3360 if (VOS_STATUS_SUCCESS !=
3361 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
3362 {
3363 halStatus = eHAL_STATUS_FAILURE;
3364 }
3365 break;
3366 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
3367 /* This event will notify pre-auth completion in case of success */
3368 if (VOS_STATUS_SUCCESS !=
3369 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3370 pRoamInfo, 1))
3371 {
3372 halStatus = eHAL_STATUS_FAILURE;
3373 }
3374 break;
3375 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
3376 /* This event will notify pre-auth completion in case of failure. */
3377 if (VOS_STATUS_SUCCESS !=
3378 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3379 pRoamInfo, 0))
3380 {
3381 halStatus = eHAL_STATUS_FAILURE;
3382 }
3383 break;
3384 case eCSR_ROAM_HANDOVER_SUCCESS:
3385 /* This event is to notify handover success.
3386 It will be only invoked on success */
3387 if (VOS_STATUS_SUCCESS !=
3388 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
3389 {
3390 halStatus = eHAL_STATUS_FAILURE;
3391 }
3392 break;
3393#endif
3394
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 case eCSR_ROAM_INDICATE_MGMT_FRAME:
3396 hdd_indicateMgmtFrame( pAdapter,
3397 pRoamInfo->nFrameLength,
3398 pRoamInfo->pbFrames,
3399 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05303400 pRoamInfo->rxChan,
3401 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 break;
3403 case eCSR_ROAM_REMAIN_CHAN_READY:
3404 hdd_remainChanReadyHandler( pAdapter );
3405 break;
3406 case eCSR_ROAM_SEND_ACTION_CNF:
3407 hdd_sendActionCnf( pAdapter,
3408 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
3409 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003410#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08003411 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003412 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08003413 roamId, roamStatus, roamResult );
3414 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003415 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
3416 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
3417 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003418#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003419#ifdef WLAN_FEATURE_11W
3420 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
3421 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
3422 pRoamInfo->pbFrames,
3423 pRoamInfo->frameType);
3424 break;
3425#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003426#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003427 case eCSR_ROAM_TSM_IE_IND:
3428 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
3429 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
3430 break;
3431
3432 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
3433 {
3434 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
3435 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
3436 {
3437 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
3438 }
3439 break;
3440 }
3441
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003442 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003443 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003444 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003445 break;
3446 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003447
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003448 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003449 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003450 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003451 break;
3452 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003453#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05303454 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
3455 {
3456 pAdapter->maxRateFlags = roamResult;
3457 break;
3458 }
3459 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 break;
3461 }
3462 return( halStatus );
3463}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003464eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003465{
3466 eCsrAuthType auth_type;
3467 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003468 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003469 {
3470 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003471 } else
3472 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 {
3474 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003475 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003476#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003477 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 {
3479 // Check for 11r FT Authentication with PSK
3480 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003481 } else
3482 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 {
3484 // Check for 11R FT Authentication with 802.1X
3485 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003486 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003487#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003488#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003489 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 {
3491 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3492 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003493#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003494#ifdef WLAN_FEATURE_11W
3495 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3496 {
3497 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3498 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303499 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
3500 {
3501 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3502 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003503#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003504 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3506 }
3507 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003508}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003509
Shailender Karmuchia734f332013-04-19 14:02:48 -07003510eCsrAuthType
3511hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003512{
3513 eCsrAuthType auth_type;
3514 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003515 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 {
3517 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003518 } else
3519 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003520 {
3521 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003522 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003523#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003524 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003525 {
3526 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003527 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003528#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003529 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3531 }
3532 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3533 return auth_type;
3534}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003535
Shailender Karmuchia734f332013-04-19 14:02:48 -07003536eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003537hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003538{
3539 eCsrEncryptionType cipher_type;
3540 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003541 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003542 {
3543 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003544 }
3545 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 {
3547 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003548 }
3549 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 {
3551 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003552 }
3553 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 {
3555 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003556 }
3557 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3558 {
3559 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3560 }
3561 else
3562 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3564 }
3565 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3566 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003567}
Jeff Johnson295189b2012-06-20 16:38:30 -07003568/* To find if the MAC address is NULL */
3569static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3570{
3571 int i;
3572 for (i = 0; i < length; i++)
3573 {
3574 if (0x00 != (macAddr[i]))
3575 {
3576 return FALSE;
3577 }
3578 }
3579 return TRUE;
3580} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003581
Shailender Karmuchia734f332013-04-19 14:02:48 -07003582eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003583hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003584{
3585 eCsrEncryptionType cipher_type;
3586 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003587 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003588 {
3589 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003590 } else
3591 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003592 {
3593 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003594 } else
3595 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 {
3597 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003598 } else
3599 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003600 {
3601 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003602 } else
3603 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003605 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3606 } else
3607 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003608 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3609 }
3610 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3611 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003612}
Jeff Johnson295189b2012-06-20 16:38:30 -07003613
Shailender Karmuchia734f332013-04-19 14:02:48 -07003614static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3615 struct ether_addr *pBssid,
3616 eCsrEncryptionType *pEncryptType,
3617 eCsrEncryptionType *mcEncryptType,
3618 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003619#ifdef WLAN_FEATURE_11W
3620 u_int8_t *pMfpRequired,
3621 u_int8_t *pMfpCapable,
3622#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003623 u_int16_t gen_ie_len,
3624 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003625{
3626 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003627 eHalStatus result;
3628 tDot11fIERSN dot11RSNIE;
3629 tDot11fIEWPA dot11WPAIE;
3630 tANI_U32 i;
3631 tANI_U8 *pRsnIe;
3632 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003634 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003635
3636 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3637 flag to 0 */
3638 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3639 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3640
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003642 if ( gen_ie[0] == DOT11F_EID_RSN)
3643 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003645 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3647 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303648 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3649 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 return -EINVAL;
3651 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003652 // Skip past the EID byte and length byte
3653 pRsnIe = gen_ie + 2;
3654 RSNIeLen = gen_ie_len - 2;
3655 // Unpack the RSN IE
3656 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3657 pRsnIe,
3658 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003660 // Copy out the encryption and authentication types
3661 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003662 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003663 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003664 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003665 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 but probably I suspect we can do something different*/
3667 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003668 // Just translate the FIRST one
3669 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3670 //dot11RSNIE.pwise_cipher_suite_count
3671 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3672 //dot11RSNIE.gp_cipher_suite_count
3673 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003674#ifdef WLAN_FEATURE_11W
3675 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3676 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3677#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003678 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003679 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003680 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003681 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003682 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303683 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003684 break;
3685 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003686 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003687 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303688 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003689 break;
3690 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003691 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 // For right now, I assume setASSOCIATE() has passed in the bssid.
3693 vos_mem_copy(PMKIDCache[i].BSSID,
3694 pBssid, ETHER_ADDR_LEN);
3695 vos_mem_copy(PMKIDCache[i].PMKID,
3696 dot11RSNIE.pmkid[i],
3697 CSR_RSN_PMKID_SIZE);
3698 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003699
3700 if (updatePMKCache)
3701 {
3702 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003703 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003704 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003705 // Finally set the PMKSA ID Cache in CSR
3706 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3707 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303708 dot11RSNIE.pmkid_count,
3709 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07003710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 }
3712 else if (gen_ie[0] == DOT11F_EID_WPA)
3713 {
3714 // Validity checks
3715 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3716 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3717 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303718 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3719 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 return -EINVAL;
3721 }
3722 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003723 pRsnIe = gen_ie + 2 + 4;
3724 RSNIeLen = gen_ie_len - (2 + 4);
3725 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3727 pRsnIe,
3728 RSNIeLen,
3729 &dot11WPAIE);
3730 // Copy out the encryption and authentication types
3731 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003732 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003734 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 //dot11WPAIE.auth_suite_count
3736 // Just translate the FIRST one
3737 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3738 //dot11WPAIE.unicast_cipher_count
3739 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3740 //dot11WPAIE.unicast_cipher_count
3741 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3742 }
3743 else
3744 {
3745 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003746 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003747 }
3748 return 0;
3749}
3750int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3751{
3752 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3753 v_U32_t status = 0;
3754 eCsrEncryptionType RSNEncryptType;
3755 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003756#ifdef WLAN_FEATURE_11W
3757 u_int8_t RSNMfpRequired;
3758 u_int8_t RSNMfpCapable;
3759#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 struct ether_addr bSsid; // MAC address of assoc peer
3761 // MAC address of assoc peer
3762 // But, this routine is only called when we are NOT associated.
3763 vos_mem_copy(bSsid.ether_addr_octet,
3764 pWextState->roamProfile.BSSIDs.bssid,
3765 sizeof(bSsid.ether_addr_octet));
3766 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3767 {
3768 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003769 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 else
3771 {
3772 return 0;
3773 }
3774 // The actual processing may eventually be more extensive than this.
3775 // Right now, just consume any PMKIDs that are sent in by the app.
3776 status = hdd_ProcessGENIE(pAdapter,
3777 &bSsid, // MAC address of assoc peer
3778 &RSNEncryptType,
3779 &mcRSNEncryptType,
3780 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003781#ifdef WLAN_FEATURE_11W
3782 &RSNMfpRequired,
3783 &RSNMfpCapable,
3784#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003785 pWextState->WPARSNIE[1]+2,
3786 pWextState->WPARSNIE);
3787 if (status == 0)
3788 {
3789 // Now copy over all the security attributes you have parsed out
3790 pWextState->roamProfile.EncryptionType.numEntries = 1;
3791 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003792
Jeff Johnson295189b2012-06-20 16:38:30 -07003793 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3794 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003795
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003796 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3797 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3798 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3799 {
3800 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3801 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3802 either AES/TKIP based on group cipher configuration
3803 mentioned in the wpa_supplicant.conf.*/
3804
3805 /*Set the unicast cipher same as multicast cipher*/
3806 pWextState->roamProfile.EncryptionType.encryptionType[0]
3807 = mcRSNEncryptType;
3808 }
3809
Chet Lanctot186b5732013-03-18 10:26:30 -07003810#ifdef WLAN_FEATURE_11W
3811 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3812 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3813#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003814 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 }
3816 return 0;
3817}
3818int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3819{
3820 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3821 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3822 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3823 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003824
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003826 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003827
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 switch( pHddStaCtx->conn_info.authType)
3829 {
3830 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003831#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 case eCSR_AUTH_TYPE_CCKM_WPA:
3833 case eCSR_AUTH_TYPE_CCKM_RSN:
3834#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003835 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3836
Jeff Johnson295189b2012-06-20 16:38:30 -07003837 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003838 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003839 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003840
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003841#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003842 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3843 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3844 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003845 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003846 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3847 } else
3848 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003849 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003850 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 } else
3852#endif
3853 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3854 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003855 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3856 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3858 == IW_AUTH_KEY_MGMT_PSK) {
3859 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003860 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003862 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003863 }
3864 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003865#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003866 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3867 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3868 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003869 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003870 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003872 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003873 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003874 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 } else
3876#endif
3877
3878#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003879 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3880 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003881 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003882 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003883 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003884 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3886 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003887 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003888 } else
3889#endif
3890
Chet Lanctot186b5732013-03-18 10:26:30 -07003891#ifdef WLAN_FEATURE_11W
3892 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3893 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3894 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303895 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
3896 pRoamProfile->AuthType.authType[0] =
3897 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3898 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003899#endif
3900
Shailender Karmuchia734f332013-04-19 14:02:48 -07003901 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003903 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3904 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3906 == IW_AUTH_KEY_MGMT_PSK) {
3907 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003908 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003910 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003912 break;
3913
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003915
3916 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 break;
3918 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003919
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003920#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08003921 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003922#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3924 break;
3925 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003926
Jeff Johnson295189b2012-06-20 16:38:30 -07003927 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003928 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003929
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 EXIT();
3931 return 0;
3932}
3933
3934/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003935
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303936 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003938 to the CSR roam profile.
3939
Jeff Johnson295189b2012-06-20 16:38:30 -07003940 \param - dev - Pointer to the net device.
3941 - info - Pointer to the iw_request_info.
3942 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003943 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003945
Jeff Johnson295189b2012-06-20 16:38:30 -07003946 --------------------------------------------------------------------------*/
3947
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303948int __iw_set_essid(struct net_device *dev,
3949 struct iw_request_info *info,
3950 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003951{
3952 v_U32_t status = 0;
3953 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303954 hdd_adapter_t *pAdapter;
3955 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 v_U32_t roamId;
3957 tCsrRoamProfile *pRoamProfile;
3958 eMib_dot11DesiredBssType connectedBssType;
3959 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303960 tHalHandle hHal;
3961 hdd_station_ctx_t *pHddStaCtx;
3962 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003963
Jeff Johnson295189b2012-06-20 16:38:30 -07003964 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303965 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3966 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303969 "%s: Adapter is NULL",__func__);
3970 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003971 }
3972
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303973 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3974 ret = wlan_hdd_validate_context(pHddCtx);
3975 if (0 != ret)
3976 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303977 return ret;
3978 }
3979
3980 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3981 if (NULL == hHal)
3982 {
3983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3984 "%s: Hal Context is NULL",__func__);
3985 return -EINVAL;
3986 }
3987 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3988 if (NULL == pHddStaCtx)
3989 {
3990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3991 "%s: STA Context is NULL",__func__);
3992 return -EINVAL;
3993 }
3994 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3995 if (NULL == pWextState)
3996 {
3997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3998 "%s: pWextState is NULL",__func__);
3999 return -EINVAL;
4000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004001 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
4002 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
4003 return -EBUSY;
4004 }
4005 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
4006 return -EINVAL;
4007 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004008 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 {
4010 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
4011 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
4012 {
4013 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004014 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4016 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
4017
4018 if(VOS_STATUS_SUCCESS == vosStatus)
4019 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
4020 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4021 }
4022 }
4023 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004024 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 {
4026 return -EINVAL;
4027 }
4028 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004029 /** when cfg80211 defined, wpa_supplicant wext driver uses
4030 zero-length, null-string ssid for force disconnection.
4031 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 driver MUST return success */
4033 if ( 0 == wrqu->essid.length ) {
4034 return 0;
4035 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004036
4037 status = hdd_wmm_get_uapsd_mask(pAdapter,
4038 &pWextState->roamProfile.uapsd_mask);
4039 if (VOS_STATUS_SUCCESS != status)
4040 {
4041 pWextState->roamProfile.uapsd_mask = 0;
4042 }
4043 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004044
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004046
4047 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
4049 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
4050 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004051
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 //set gen ie
4053 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
4054
4055 //set auth
4056 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
4057 }
4058#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004059 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 if (pAdapter->wapi_info.nWapiMode)
4061 {
4062 switch (pAdapter->wapi_info.wapiAuthMode)
4063 {
4064 case WAPI_AUTH_MODE_PSK:
4065 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004066 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 pRoamProfile->AuthType.numEntries = 1;
4068 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4069 break;
4070 }
4071 case WAPI_AUTH_MODE_CERT:
4072 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004073 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 pRoamProfile->AuthType.numEntries = 1;
4075 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4076 break;
4077 }
4078 } // End of switch
4079 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
4080 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
4081 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004082 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 pRoamProfile->EncryptionType.numEntries = 1;
4084 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4085 pRoamProfile->mcEncryptionType.numEntries = 1;
4086 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4087 }
4088 }
4089#endif /* FEATURE_WLAN_WAPI */
4090 /* if previous genIE is not NULL, update AssocIE */
4091 if (0 != pWextState->genIE.length)
4092 {
4093 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
4094 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
4095 pWextState->genIE.length);
4096 pWextState->assocAddIE.length = pWextState->genIE.length;
4097 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
4098 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
4099
4100 /* clear previous genIE after use it */
4101 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
4102 }
4103
4104 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
4105 pWextState->roamProfile.bWPSAssociation = FALSE;
4106
4107 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
4108 pWextState->roamProfile.nAddIEAssocLength))
4109 pWextState->roamProfile.bWPSAssociation = TRUE;
4110
4111
4112 // Disable auto BMPS entry by PMC until DHCP is done
4113 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
4114
Shailender Karmuchia734f332013-04-19 14:02:48 -07004115 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004117
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004118 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
4119 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004120 hdd_select_cbmode(pAdapter,
4121 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
4122 }
4123 status = sme_RoamConnect( hHal,pAdapter->sessionId,
4124 &(pWextState->roamProfile), &roamId);
4125 pRoamProfile->ChannelInfo.ChannelList = NULL;
4126 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004127
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004128 EXIT();
4129 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004130}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004131
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304132int iw_set_essid(struct net_device *dev,
4133 struct iw_request_info *info,
4134 union iwreq_data *wrqu, char *extra)
4135{
4136 int ret;
4137
4138 vos_ssr_protect(__func__);
4139 ret = __iw_set_essid(dev, info, wrqu, extra);
4140 vos_ssr_unprotect(__func__);
4141
4142 return ret;
4143}
4144
Jeff Johnson295189b2012-06-20 16:38:30 -07004145/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004146
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304147 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004148 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004149
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 \param - dev - Pointer to the net device.
4151 - info - Pointer to the iw_request_info.
4152 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004153 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004155
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304157int __iw_get_essid(struct net_device *dev,
4158 struct iw_request_info *info,
4159 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004160{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304161 hdd_adapter_t *pAdapter;
4162 hdd_context_t *pHddCtx;
4163 hdd_wext_state_t *wextBuf;
4164 hdd_station_ctx_t *pHddStaCtx;
4165 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304166
Jeff Johnson295189b2012-06-20 16:38:30 -07004167 ENTER();
4168
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304169 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4170 if (NULL == pAdapter)
4171 {
4172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4173 "%s: Adapter is NULL",__func__);
4174 return -EINVAL;
4175 }
4176
4177 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4178 ret = wlan_hdd_validate_context(pHddCtx);
4179 if (0 != ret)
4180 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304181 return ret;
4182 }
4183
4184 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4185 if (NULL == pHddStaCtx)
4186 {
4187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4188 "%s: STA Context is NULL",__func__);
4189 return -EINVAL;
4190 }
4191
4192 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4193 if (NULL == wextBuf)
4194 {
4195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4196 "%s: wextBuf is NULL",__func__);
4197 return -EINVAL;
4198 }
4199
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
4201 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
4202 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
4203 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
4204 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
4205 {
4206 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
4207 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
4208 dwrq->flags = 1;
4209 } else {
4210 memset(extra, 0, dwrq->length);
4211 dwrq->length = 0;
4212 dwrq->flags = 0;
4213 }
4214 EXIT();
4215 return 0;
4216}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304217
4218int iw_get_essid(struct net_device *dev,
4219 struct iw_request_info *info,
4220 struct iw_point *dwrq, char *extra)
4221{
4222 int ret;
4223
4224 vos_ssr_protect(__func__);
4225 ret = __iw_get_essid(dev, info, dwrq, extra);
4226 vos_ssr_unprotect(__func__);
4227
4228 return ret;
4229}
Jeff Johnson295189b2012-06-20 16:38:30 -07004230/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004231
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304232 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004234
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 \param - dev - Pointer to the net device.
4236 - info - Pointer to the iw_request_info.
4237 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004238 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004240
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304242int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
4243 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004244{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304245 hdd_adapter_t *pAdapter;
4246 hdd_context_t *pHddCtx;
4247 hdd_wext_state_t *pWextState;
4248 hdd_station_ctx_t *pHddStaCtx;
4249 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004250 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07004251 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304252 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004253
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004255
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304256 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4257 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004258 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4260 "%s: Adapter is NULL",__func__);
4261 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004262 }
4263
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304264 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4265 ret = wlan_hdd_validate_context(pHddCtx);
4266 if (0 != ret)
4267 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304268 return ret;
4269 }
4270
4271 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4272 if (NULL == pHddStaCtx)
4273 {
4274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4275 "%s: STA Context is NULL",__func__);
4276 return -EINVAL;
4277 }
4278
4279 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4280 if (NULL == pWextState)
4281 {
4282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4283 "%s: pWextState is NULL",__func__);
4284 return -EINVAL;
4285 }
4286
4287 pRoamProfile = &pWextState->roamProfile;
4288
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 switch(wrqu->param.flags & IW_AUTH_INDEX)
4290 {
4291 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004292
Jeff Johnson295189b2012-06-20 16:38:30 -07004293 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004294
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004296
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 case IW_AUTH_CIPHER_PAIRWISE:
4298 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004299 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004300 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4303 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004305 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
4306 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004307 }
4308
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004310
4311 if( (IW_AUTH_KEY_MGMT_802_1X
4312 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
4314 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004315 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 else
4317 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004318 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4319 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004320 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004321
4322 if( ( IW_AUTH_KEY_MGMT_802_1X
4323 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004324 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4325 /*Dynamic WEP key*/
4326 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4327 else
4328 /*Static WEP key*/
4329 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004330
Jeff Johnson295189b2012-06-20 16:38:30 -07004331 }
4332 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004333
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004335 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004336 return -EINVAL;
4337 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004338
Jeff Johnson295189b2012-06-20 16:38:30 -07004339 pRoamProfile->EncryptionType.numEntries = 1;
4340 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 break;
4343 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004344 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
4346 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4347 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004348
Jeff Johnson295189b2012-06-20 16:38:30 -07004349 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4350 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
4351 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004352
4353 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
4355 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004356
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004358
4359 if( ( IW_AUTH_KEY_MGMT_802_1X
4360 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
4361 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4362
Jeff Johnson295189b2012-06-20 16:38:30 -07004363 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004364
4365 else
4366 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004367 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004368
4369 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
4370 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004372 if( ( IW_AUTH_KEY_MGMT_802_1X
4373 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07004374 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4375 {
4376 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4377 }
4378 else
4379 {
4380 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4381 }
4382 }
4383 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004384
Jeff Johnson295189b2012-06-20 16:38:30 -07004385 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004386 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 return -EINVAL;
4388 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004389
Jeff Johnson295189b2012-06-20 16:38:30 -07004390 pRoamProfile->mcEncryptionType.numEntries = 1;
4391 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
4392 }
4393 break;
4394
4395 case IW_AUTH_80211_AUTH_ALG:
4396 {
4397 /*Save the auth algo here and set auth type to SME Roam profile
4398 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004399 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004401
Jeff Johnson295189b2012-06-20 16:38:30 -07004402 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
4403 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
4404
4405 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
4406 /*Not supported*/
4407 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4408 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4409 }
4410 break;
4411
4412 case IW_AUTH_KEY_MGMT:
4413 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004414#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004415#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
4416 /*Check for CCKM AKM type */
4417 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004418 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
4419 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004420 /* Set the CCKM bit in authKeyMgmt */
4421 /* Right now, this breaks all ref to authKeyMgmt because our
4422 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07004423 */
4424 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
4425 /*Set the key management to 802.1X*/
4426 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004427 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4429 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
4430 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
4431 /*Save the key management*/
4432 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
4433 //pWextState->authKeyMgmt = wrqu->param.value;
4434 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4435 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4436 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
4437 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
4438 /*Save the key management anyway*/
4439 pWextState->authKeyMgmt = wrqu->param.value;
4440 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
4441 /*Save the key management*/
4442 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
4443 //pWextState->authKeyMgmt = wrqu->param.value;
4444 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4445 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4446 }
4447#else
4448 /*Save the key management*/
4449 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004450#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 }
4452 break;
4453
4454 case IW_AUTH_TKIP_COUNTERMEASURES:
4455 {
4456 if(wrqu->param.value) {
4457 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4458 "Counter Measure started %d", wrqu->param.value);
4459 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
4460 }
4461 else {
4462 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4463 "Counter Measure stopped=%d", wrqu->param.value);
4464 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4465 }
4466 }
4467 break;
4468 case IW_AUTH_DROP_UNENCRYPTED:
4469 case IW_AUTH_WPA_ENABLED:
4470 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
4471 case IW_AUTH_ROAMING_CONTROL:
4472 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004473
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004475
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004476 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004477 wrqu->param.flags & IW_AUTH_INDEX);
4478 break;
4479 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004480
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 EXIT();
4482 return 0;
4483}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304484
4485int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
4486 union iwreq_data *wrqu, char *extra)
4487{
4488 int ret;
4489
4490 vos_ssr_protect(__func__);
4491 ret = __iw_set_auth(dev, info, wrqu, extra);
4492 vos_ssr_unprotect(__func__);
4493
4494 return ret;
4495}
4496
Jeff Johnson295189b2012-06-20 16:38:30 -07004497/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004498
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304499 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004501
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 \param - dev - Pointer to the net device.
4503 - info - Pointer to the iw_request_info.
4504 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004505 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004507
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304509int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4510 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004511{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304512 hdd_adapter_t* pAdapter;
4513 hdd_wext_state_t *pWextState;
4514 tCsrRoamProfile *pRoamProfile;
4515 hdd_context_t *pHddCtx;
4516 int ret = 0;
4517
Jeff Johnson295189b2012-06-20 16:38:30 -07004518 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004519
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304520 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4521 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004522 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4524 "%s: Adapter is NULL",__func__);
4525 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004526 }
4527
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304528 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4529 ret = wlan_hdd_validate_context(pHddCtx);
4530 if (0 != ret)
4531 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304532 return ret;
4533 }
4534
4535 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4536 if (NULL == pWextState)
4537 {
4538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4539 "%s: pWextState is NULL",__func__);
4540 return -EINVAL;
4541 }
4542 pRoamProfile = &pWextState->roamProfile;
4543
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 switch(pRoamProfile->negotiatedAuthType)
4545 {
4546 case eCSR_AUTH_TYPE_WPA_NONE:
4547 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4548 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
4549 break;
4550 case eCSR_AUTH_TYPE_WPA:
4551 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4552 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
4553 break;
4554#ifdef WLAN_FEATURE_VOWIFI_11R
4555 case eCSR_AUTH_TYPE_FT_RSN:
4556#endif
4557 case eCSR_AUTH_TYPE_RSN:
4558 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4559 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
4560 break;
4561 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4562 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4563 break;
4564 case eCSR_AUTH_TYPE_SHARED_KEY:
4565 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
4566 break;
4567 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004568 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4570 break;
4571 case eCSR_AUTH_TYPE_AUTOSWITCH:
4572 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4573 break;
4574 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304575 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4577 return -EIO;
4578#ifdef WLAN_FEATURE_VOWIFI_11R
4579 case eCSR_AUTH_TYPE_FT_RSN_PSK:
4580#endif
4581 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07004582#ifdef WLAN_FEATURE_11W
4583 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05304584 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07004585#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05304586 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4588 return -EIO;
4589 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304590 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4592 return -EIO;
4593 }
4594 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
4595 {
4596 switch(pRoamProfile->negotiatedUCEncryptionType)
4597 {
4598 case eCSR_ENCRYPT_TYPE_NONE:
4599 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4600 break;
4601 case eCSR_ENCRYPT_TYPE_WEP40:
4602 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4603 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4604 break;
4605 case eCSR_ENCRYPT_TYPE_TKIP:
4606 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4607 break;
4608 case eCSR_ENCRYPT_TYPE_WEP104:
4609 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4610 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4611 break;
4612 case eCSR_ENCRYPT_TYPE_AES:
4613 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4614 break;
4615 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304616 hddLog(LOG1, "%s called with unknown auth type %d ",
4617 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 return -EIO;
4619 }
4620 }
4621
Shailender Karmuchia734f332013-04-19 14:02:48 -07004622 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004623 {
4624 switch(pRoamProfile->negotiatedMCEncryptionType)
4625 {
4626 case eCSR_ENCRYPT_TYPE_NONE:
4627 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4628 break;
4629 case eCSR_ENCRYPT_TYPE_WEP40:
4630 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4631 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4632 break;
4633 case eCSR_ENCRYPT_TYPE_TKIP:
4634 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4635 break;
4636 case eCSR_ENCRYPT_TYPE_WEP104:
4637 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4638 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4639 break;
4640 case eCSR_ENCRYPT_TYPE_AES:
4641 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4642 break;
4643 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304644 hddLog(LOG1, "%s called with unknown auth type %d ",
4645 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004646 return -EIO;
4647 }
4648 }
4649
4650 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004651 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 EXIT();
4653 return 0;
4654}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304655
4656int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4657 union iwreq_data *wrqu,char *extra)
4658{
4659 int ret;
4660
4661 vos_ssr_protect(__func__);
4662 ret = __iw_get_auth(dev, info, wrqu, extra);
4663 vos_ssr_unprotect(__func__);
4664
4665 return ret;
4666}
4667
Jeff Johnson295189b2012-06-20 16:38:30 -07004668/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004669
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304670 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07004671 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004672 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004673
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 \param - dev - Pointer to the net device.
4675 - info - Pointer to the iw_request_info.
4676 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004677 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004678 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004679
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304681int __iw_set_ap_address(struct net_device *dev,
4682 struct iw_request_info *info,
4683 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004684{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304685 hdd_station_ctx_t *pHddStaCtx;
4686 hdd_adapter_t *pAdapter;
4687 hdd_context_t *pHddCtx;
4688 v_U8_t *pMacAddress = NULL;
4689 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304690
Jeff Johnson295189b2012-06-20 16:38:30 -07004691 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304692
4693 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4694 if (NULL == pAdapter)
4695 {
4696 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4697 "%s: Adapter is NULL", __func__);
4698 return -EINVAL;
4699 }
4700 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4701 ret = wlan_hdd_validate_context(pHddCtx);
4702 if (0 != ret)
4703 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304704 return ret;
4705 }
4706 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4707 if (NULL == pHddStaCtx)
4708 {
4709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4710 "%s: pHddStaCtx is NULL", __func__);
4711 return -EINVAL;
4712 }
4713
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4716 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07004718
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304719 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004720 return 0;
4721}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304722
4723int iw_set_ap_address(struct net_device *dev,
4724 struct iw_request_info *info,
4725 union iwreq_data *wrqu, char *extra)
4726{
4727 int ret;
4728
4729 vos_ssr_protect(__func__);
4730 ret = __iw_set_ap_address(dev, info, wrqu, extra);
4731 vos_ssr_unprotect(__func__);
4732
4733 return ret;
4734}
4735
Jeff Johnson295189b2012-06-20 16:38:30 -07004736/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004737
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304738 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004739 This function returns the BSSID to the wpa_supplicant
4740 \param - dev - Pointer to the net device.
4741 - info - Pointer to the iw_request_info.
4742 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004743 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004744 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004745
Jeff Johnson295189b2012-06-20 16:38:30 -07004746 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304747int __iw_get_ap_address(struct net_device *dev,
4748 struct iw_request_info *info,
4749 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004750{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304751 hdd_station_ctx_t *pHddStaCtx;
4752 hdd_adapter_t *pAdapter;
4753 hdd_context_t *pHddCtx;
4754 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304755
Jeff Johnson295189b2012-06-20 16:38:30 -07004756 ENTER();
4757
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304758 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4759 if (NULL == pAdapter)
4760 {
4761 hddLog(VOS_TRACE_LEVEL_ERROR,
4762 "%s: Adapter is NULL", __func__);
4763 return -EINVAL;
4764 }
4765 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4766 ret = wlan_hdd_validate_context(pHddCtx);
4767 if (0 != ret)
4768 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304769 return ret;
4770 }
4771 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4772 if (NULL == pHddStaCtx)
4773 {
4774 hddLog(VOS_TRACE_LEVEL_ERROR,
4775 "%s: pHddStaCtx is NULL", __func__);
4776 return -EINVAL;
4777 }
4778
Jeff Johnson295189b2012-06-20 16:38:30 -07004779 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4780 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4781 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004782 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004783 }
4784 else
4785 {
4786 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4787 }
4788 EXIT();
4789 return 0;
4790}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004791
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304792int iw_get_ap_address(struct net_device *dev,
4793 struct iw_request_info *info,
4794 union iwreq_data *wrqu, char *extra)
4795{
4796 int ret;
4797
4798 vos_ssr_protect(__func__);
4799 ret = __iw_get_ap_address(dev, info, wrqu, extra);
4800 vos_ssr_unprotect(__func__);
4801
4802 return ret;
4803}
4804
Chet Lanctot186b5732013-03-18 10:26:30 -07004805#ifdef WLAN_FEATURE_11W
4806/**---------------------------------------------------------------------------
4807
4808 \brief hdd_indicateUnprotMgmtFrame -
4809 This function forwards the unprotected management frame to the supplicant
4810 \param - pAdapter - Pointer to HDD adapter
4811 - nFrameLength - Length of the unprotected frame being passed
4812 - pbFrames - Pointer to the frame buffer
4813 - frameType - 802.11 frame type
4814 \return - nothing
4815
4816 --------------------------------------------------------------------------*/
4817void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4818 tANI_U32 nFrameLength,
4819 tANI_U8* pbFrames,
4820 tANI_U8 frameType )
4821{
4822 tANI_U8 type = 0;
4823 tANI_U8 subType = 0;
4824
4825 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4826 __func__, frameType, nFrameLength);
4827
4828 /* Sanity Checks */
4829 if (NULL == pAdapter)
4830 {
4831 hddLog( LOGE, FL("pAdapter is NULL"));
4832 return;
4833 }
4834
4835 if (NULL == pAdapter->dev)
4836 {
4837 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4838 return;
4839 }
4840
4841 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4842 {
4843 hddLog( LOGE, FL("pAdapter has invalid magic"));
4844 return;
4845 }
4846
4847 if( !nFrameLength )
4848 {
4849 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4850 return;
4851 }
4852
4853 if (NULL == pbFrames) {
4854 hddLog( LOGE, FL("pbFrames is NULL"));
4855 return;
4856 }
4857
4858 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4859 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4860
4861 /* Get pAdapter from Destination mac address of the frame */
4862 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
4863 {
4864 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
4865 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4866 }
4867 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
4868 {
4869 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
4870 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4871 }
4872 else
4873 {
4874 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
4875 return;
4876 }
4877}
4878#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004879
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004880#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004881void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
4882 tANI_U8 state,
4883 tANI_U16 measInterval )
4884{
4885 union iwreq_data wrqu;
4886 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004887 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004888
4889 if (NULL == pAdapter)
4890 return;
4891
4892 // create the event
4893 memset(&wrqu, '\0', sizeof(wrqu));
4894 memset(buf, '\0', sizeof(buf));
4895
4896 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
4897 tid, state, measInterval);
4898
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004899 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004900
4901 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004902 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004903 // send the event
4904 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4905}
4906
4907void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4908{
4909 union iwreq_data wrqu;
4910 char buf[IW_CUSTOM_MAX + 1];
4911 char *pos = buf;
4912 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4913
4914 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4915 return;
4916
4917 // create the event
4918 memset(&wrqu, '\0', sizeof(wrqu));
4919 memset(buf, '\0', sizeof(buf));
4920
4921 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304922 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
4923 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
4924 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
4925 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004926
4927 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4928 pos += nBytes;
4929 freeBytes -= nBytes;
4930
4931 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
4932 pos += WNI_CFG_BSSID_LEN;
4933 freeBytes -= WNI_CFG_BSSID_LEN;
4934
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004935 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4936 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004937
4938 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004939 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004940
4941 // send the event
4942 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4943}
4944
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004945void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004946{
4947 union iwreq_data wrqu;
4948 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004949 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004950
4951 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4952 return;
4953
4954 // create the event
4955 memset(&wrqu, '\0', sizeof(wrqu));
4956 memset(buf, '\0', sizeof(buf));
4957
4958 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
4959
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004960 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004961
4962 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004963 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004964
4965 // send the event
4966 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4967}
4968
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004969void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
4970 const tANI_U16 measurementToken,
4971 const tANI_BOOLEAN flag,
4972 const tANI_U8 numBss)
4973{
4974 union iwreq_data wrqu;
4975 char buf[IW_CUSTOM_MAX];
4976 char *pos = buf;
4977 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4978
4979 memset(&wrqu, '\0', sizeof(wrqu));
4980 memset(buf, '\0', sizeof(buf));
4981
4982 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
4983 numBss);
4984
4985 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4986 flag, numBss);
4987
4988 wrqu.data.pointer = buf;
4989 wrqu.data.length = nBytes;
4990 // send the event
4991 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4992}
4993
4994
4995static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004996 const tCsrRoamInfo *pRoamInfo)
4997{
4998 union iwreq_data wrqu;
4999 char buf[IW_CUSTOM_MAX + 1];
5000 char *pos = buf;
5001 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5002 tANI_U8 i = 0, len = 0;
5003 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
5004 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005005 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
5006 tANI_U8 ieLenByte = 1;
5007 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
5008#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005009
5010 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5011 return;
5012
5013 /* Custom event can pass maximum of 256 bytes of data,
5014 based on the IE len we need to identify how many BSS info can
5015 be filled in to custom event data */
5016 /*
5017 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
5018 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
5019 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
5020 */
5021
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005022 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005023 {
5024 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
5025 /* If the measurement is none and no scan results found,
5026 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005027 hdd_indicateEseBcnReportNoResults(pAdapter,
5028 pRoamInfo->pEseBcnReportRsp->measurementToken,
5029 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005030 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005031 }
5032 else
5033 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005034 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005035 {
5036 memset(&wrqu, '\0', sizeof(wrqu));
5037 memset(buf, '\0', sizeof(buf));
5038 tot_bcn_ieLen = 0;
5039 sendBss = 0;
5040 pos = buf;
5041 freeBytes = IW_CUSTOM_MAX;
5042
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005043 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005044 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005045 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
5046 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005047 {
5048 break;
5049 }
5050 tot_bcn_ieLen += len;
5051 sendBss++;
5052 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
5053 "IeLength(%d) Length of Ie(%d) totLen(%d)",
5054 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005055 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005056 tot_bcn_ieLen);
5057 }
5058
5059 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
5060 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005061 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5062 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005063
5064 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005065 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5066 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005067 pos += nBytes;
5068 freeBytes -= nBytes;
5069
5070 /* Copy total Beacon report data length */
5071 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
5072 pos += sizeof(tot_bcn_ieLen);
5073 freeBytes -= sizeof(tot_bcn_ieLen);
5074
5075 for (i = 0; i < sendBss; i++)
5076 {
5077 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305078 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
5079 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005080 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005081 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
5082 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
5083 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
5084 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
5085 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
5086 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
5087 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
5088 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
5089 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
5090 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
5091 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
5092 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
5093 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
5094 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
5095 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
5096 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005097
5098 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005099 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
5100 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005101 pos += len;
5102 freeBytes -= len;
5103
5104 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005105 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005106 vos_mem_copy(pos, (char*)&len, sizeof(len));
5107 pos += sizeof(len);
5108 freeBytes -= sizeof(len);
5109
5110 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005111 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005112 pos += len;
5113 freeBytes -= len;
5114 }
5115
5116 wrqu.data.pointer = buf;
5117 wrqu.data.length = strlen(buf);
5118
5119 // send the event
5120 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5121 lastSent += sendBss;
5122 }
5123 }
5124}
5125
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005126#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005127